Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, truffleruby]
ruby: [2.2, 2.3, 2.4, 2.5, 2.6, 2.7, '3.0', 3.1, head, truffleruby]
include:
- { ruby: jruby-9.3, allow-failure: true }
steps:
Expand Down
2 changes: 2 additions & 0 deletions mustermann/lib/mustermann/ast/expander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def error_for(values)
# @see Mustermann::AST::Translator#expand
# @!visibility private
ruby2_keywords def escape(string, *args)
return super unless string.respond_to?(:=~)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's just nil/false, I'd simplify to return super unless string or integrate it in the ternary below.
Or are other types seen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the build failures, it's Integers: https://github.com/magni-/mustermann/runs/7425121555?check_suite_focus=true#step:5:14

e.g.

   9) Mustermann::Expander supports combining different pattern styles
     Failure/Error: expander.expand(bar: 23).should be == "/23"
     NoMethodError:
       undefined method `=~' for 23:Integer
     # ./mustermann/lib/mustermann/ast/expander.rb:128:in `escape'
     # ./mustermann/lib/mustermann/ast/expander.rb:99:in `block in expand'
     # ./mustermann/lib/mustermann/ast/expander.rb:99:in `each'
     # ./mustermann/lib/mustermann/ast/expander.rb:99:in `expand'
     # ./mustermann/lib/mustermann/expander.rb:150:in `expand'
     # ./mustermann/spec/expander_spec.rb:26:in `block (2 levels) in <top (required)>'


# URI::Parser is pretty slow, let's not send every string to it, even if it's unnecessary
string =~ /\A\w*\Z/ ? string : super
end
Expand Down
4 changes: 2 additions & 2 deletions mustermann/lib/mustermann/ast/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def self.constant_name(name)
# Helper for creating a new instance and calling #parse on it.
# @return [Mustermann::AST::Node]
# @!visibility private
def self.parse(*args, &block)
new(*args).tap { |n| n.parse(&block) }
def self.parse(payload = nil, **options, &block)
new(payload, **options).tap { |n| n.parse(&block) }
Comment on lines +38 to +39

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

end

# @!visibility private
Expand Down