ripper_ruby_parser 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/ripper_ruby_parser/sexp_handlers.rb +2 -0
- data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +7 -2
- data/lib/ripper_ruby_parser/sexp_handlers/literals.rb +15 -242
- data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +15 -13
- data/lib/ripper_ruby_parser/sexp_handlers/string_literals.rb +260 -0
- data/lib/ripper_ruby_parser/sexp_processor.rb +5 -38
- data/lib/ripper_ruby_parser/unescape.rb +23 -18
- data/lib/ripper_ruby_parser/version.rb +1 -1
- data/test/end_to_end/lib_comparison_test.rb +1 -12
- data/test/end_to_end/test_comparison_test.rb +1 -15
- data/test/ripper_ruby_parser/parser_test.rb +31 -8
- data/test/ripper_ruby_parser/sexp_handlers/assignment_test.rb +4 -17
- data/test/ripper_ruby_parser/sexp_handlers/blocks_test.rb +22 -0
- data/test/ripper_ruby_parser/sexp_handlers/literals_test.rb +5 -954
- data/test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb +0 -30
- data/test/ripper_ruby_parser/sexp_handlers/methods_test.rb +12 -4
- data/test/ripper_ruby_parser/sexp_handlers/string_literals_test.rb +973 -0
- data/test/ripper_ruby_parser/sexp_processor_test.rb +24 -0
- data/test/samples/misc.rb +4 -0
- data/test/samples/number.rb +2 -0
- data/test/samples/strings.rb +0 -1
- data/test/test_helper.rb +9 -5
- metadata +6 -3
@@ -285,6 +285,30 @@ describe RipperRubyParser::SexpProcessor do
|
|
285
285
|
nil)
|
286
286
|
end
|
287
287
|
end
|
288
|
+
|
289
|
+
it "processes a Ruby 2.5 style period Sexp" do
|
290
|
+
sexp = s(:call,
|
291
|
+
s(:vcall, s(:@ident, "foo", s(1, 0))),
|
292
|
+
:'.',
|
293
|
+
s(:@ident, "bar", s(1, 4)))
|
294
|
+
_(processor.process(sexp)).must_equal s(:call, s(:call, nil, :foo), :bar)
|
295
|
+
end
|
296
|
+
|
297
|
+
it "processes a Ruby 2.6 style period Sexp" do
|
298
|
+
sexp = s(:call,
|
299
|
+
s(:vcall, s(:@ident, "foo", s(1, 0))),
|
300
|
+
s(:@period, ".", s(1, 3)),
|
301
|
+
s(:@ident, "bar", s(1, 4)))
|
302
|
+
_(processor.process(sexp)).must_equal s(:call, s(:call, nil, :foo), :bar)
|
303
|
+
end
|
304
|
+
|
305
|
+
it "raises an error for an unknown call operator" do
|
306
|
+
sexp = s(:call,
|
307
|
+
s(:vcall, s(:@ident, "foo", s(1, 0))),
|
308
|
+
:'>.',
|
309
|
+
s(:@ident, "bar", s(1, 4)))
|
310
|
+
_(-> { processor.process(sexp) }).must_raise KeyError
|
311
|
+
end
|
288
312
|
end
|
289
313
|
|
290
314
|
describe "#extract_node_symbol" do
|
data/test/samples/misc.rb
CHANGED
data/test/samples/number.rb
CHANGED
data/test/samples/strings.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -73,9 +73,8 @@ module MiniTest
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
def assert_parsed_as(sexp, code,
|
76
|
+
def assert_parsed_as(sexp, code, with_line_numbers: false)
|
77
77
|
parser = RipperRubyParser::Parser.new
|
78
|
-
parser.extra_compatible = extra_compatible
|
79
78
|
result = parser.parse code
|
80
79
|
if sexp.nil?
|
81
80
|
assert_nil result
|
@@ -100,8 +99,13 @@ module MiniTest
|
|
100
99
|
end
|
101
100
|
end
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
|
102
|
+
Expectation.class_eval do
|
103
|
+
def must_be_parsed_as(sexp, with_line_numbers: false)
|
104
|
+
ctx.assert_parsed_as(sexp, target, with_line_numbers: with_line_numbers)
|
105
|
+
end
|
106
|
+
|
107
|
+
def must_be_parsed_as_before(with_line_numbers: false)
|
108
|
+
ctx.assert_parsed_as_before(target, with_line_numbers: with_line_numbers)
|
109
|
+
end
|
106
110
|
end
|
107
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripper_ruby_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sexp_processor
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/ripper_ruby_parser/sexp_handlers/method_calls.rb
|
107
107
|
- lib/ripper_ruby_parser/sexp_handlers/methods.rb
|
108
108
|
- lib/ripper_ruby_parser/sexp_handlers/operators.rb
|
109
|
+
- lib/ripper_ruby_parser/sexp_handlers/string_literals.rb
|
109
110
|
- lib/ripper_ruby_parser/sexp_processor.rb
|
110
111
|
- lib/ripper_ruby_parser/syntax_error.rb
|
111
112
|
- lib/ripper_ruby_parser/unescape.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb
|
128
129
|
- test/ripper_ruby_parser/sexp_handlers/methods_test.rb
|
129
130
|
- test/ripper_ruby_parser/sexp_handlers/operators_test.rb
|
131
|
+
- test/ripper_ruby_parser/sexp_handlers/string_literals_test.rb
|
130
132
|
- test/ripper_ruby_parser/sexp_processor_test.rb
|
131
133
|
- test/ripper_ruby_parser/version_test.rb
|
132
134
|
- test/samples/assignment.rb
|
@@ -160,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
162
|
- !ruby/object:Gem::Version
|
161
163
|
version: '0'
|
162
164
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
165
|
+
rubygems_version: 3.1.2
|
164
166
|
signing_key:
|
165
167
|
specification_version: 4
|
166
168
|
summary: Parse with Ripper, produce sexps that are compatible with RubyParser.
|
@@ -182,6 +184,7 @@ test_files:
|
|
182
184
|
- test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb
|
183
185
|
- test/ripper_ruby_parser/sexp_handlers/methods_test.rb
|
184
186
|
- test/ripper_ruby_parser/sexp_handlers/operators_test.rb
|
187
|
+
- test/ripper_ruby_parser/sexp_handlers/string_literals_test.rb
|
185
188
|
- test/ripper_ruby_parser/sexp_processor_test.rb
|
186
189
|
- test/ripper_ruby_parser/version_test.rb
|
187
190
|
- test/samples/assignment.rb
|