Skip to content

Commit

Permalink
Support Ruby 2.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Aug 23, 2022
1 parent 8ff9ab0 commit 0302779
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
fail-fast: false
matrix:
ruby:
- '2.7'
- '2.7.0'
- '3.0'
- '3.1'
- head
Expand Down
12 changes: 6 additions & 6 deletions lib/syntax_tree/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2132,8 +2132,7 @@ def format(q)
in [
Paren[
contents: {
body: [ArrayLiteral[contents: { parts: [_, _, *] }] => array]
}
body: [ArrayLiteral[contents: { parts: [_, _, *] }] => array] }
]
]
# Here we have a single argument that is a set of parentheses wrapping
Expand Down Expand Up @@ -5116,8 +5115,10 @@ def format(q)
q.breakable
contents.call
end
q.breakable
q.text("}")

# Doing this because Ruby 2.7 before 2.7.3 did not support a newline
# character before the closing brace.
q.text(" }")
end
end
end
Expand Down Expand Up @@ -5204,8 +5205,7 @@ def call(q, node)
false
in {
statements: { body: [truthy] },
consequent: Else[statements: { body: [falsy] }]
}
consequent: Else[statements: { body: [falsy] }] }
ternaryable?(truthy) && ternaryable?(falsy)
else
false
Expand Down
2 changes: 1 addition & 1 deletion syntax_tree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
.reject { |f| f.match(%r{^(test|spec|features)/}) }
end

spec.required_ruby_version = ">= 2.7.3"
spec.required_ruby_version = ">= 2.7.0"

spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/args_forward.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%
% # >= 2.7.3
def foo(...)
bar(:baz, ...)
end
Expand Down
9 changes: 8 additions & 1 deletion test/fixtures/hshptn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@
case foo
in **bar
end
%
% # >= 2.7.3
case foo
in {
foo:, # comment1
bar: # comment2
}
baz
end
-
case foo
in {
foo:, # comment1
bar: } # comment2
baz
end
%
case foo
in Foo[bar:]
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def foo(*)
%
def foo(*rest)
end
%
% # >= 2.7.3
def foo(...)
end
%
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize
@called = nil
end

def method_missing(called, ...)
def method_missing(called, *, **)
@called = called
end
end
Expand Down

0 comments on commit 0302779

Please sign in to comment.