Skip to content

Commit 0302779

Browse files
committed
Support Ruby 2.7.0
1 parent 8ff9ab0 commit 0302779

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
fail-fast: false
99
matrix:
1010
ruby:
11-
- '2.7'
11+
- '2.7.0'
1212
- '3.0'
1313
- '3.1'
1414
- head

lib/syntax_tree/node.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -2132,8 +2132,7 @@ def format(q)
21322132
in [
21332133
Paren[
21342134
contents: {
2135-
body: [ArrayLiteral[contents: { parts: [_, _, *] }] => array]
2136-
}
2135+
body: [ArrayLiteral[contents: { parts: [_, _, *] }] => array] }
21372136
]
21382137
]
21392138
# Here we have a single argument that is a set of parentheses wrapping
@@ -5116,8 +5115,10 @@ def format(q)
51165115
q.breakable
51175116
contents.call
51185117
end
5119-
q.breakable
5120-
q.text("}")
5118+
5119+
# Doing this because Ruby 2.7 before 2.7.3 did not support a newline
5120+
# character before the closing brace.
5121+
q.text(" }")
51215122
end
51225123
end
51235124
end
@@ -5204,8 +5205,7 @@ def call(q, node)
52045205
false
52055206
in {
52065207
statements: { body: [truthy] },
5207-
consequent: Else[statements: { body: [falsy] }]
5208-
}
5208+
consequent: Else[statements: { body: [falsy] }] }
52095209
ternaryable?(truthy) && ternaryable?(falsy)
52105210
else
52115211
false

syntax_tree.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
1919
.reject { |f| f.match(%r{^(test|spec|features)/}) }
2020
end
2121

22-
spec.required_ruby_version = ">= 2.7.3"
22+
spec.required_ruby_version = ">= 2.7.0"
2323

2424
spec.bindir = "exe"
2525
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }

test/fixtures/args_forward.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%
1+
% # >= 2.7.3
22
def foo(...)
33
bar(:baz, ...)
44
end

test/fixtures/hshptn.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,21 @@
3030
case foo
3131
in **bar
3232
end
33-
%
33+
% # >= 2.7.3
3434
case foo
3535
in {
3636
foo:, # comment1
3737
bar: # comment2
3838
}
3939
baz
4040
end
41+
-
42+
case foo
43+
in {
44+
foo:, # comment1
45+
bar: } # comment2
46+
baz
47+
end
4148
%
4249
case foo
4350
in Foo[bar:]

test/fixtures/params.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def foo(*)
1616
%
1717
def foo(*rest)
1818
end
19-
%
19+
% # >= 2.7.3
2020
def foo(...)
2121
end
2222
%

test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def initialize
2626
@called = nil
2727
end
2828

29-
def method_missing(called, ...)
29+
def method_missing(called, *, **)
3030
@called = called
3131
end
3232
end

0 commit comments

Comments
 (0)