ripper_ruby_parser 1.1.2 → 1.2.0
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 +5 -5
- data/CHANGELOG.md +19 -0
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/lib/ripper_ruby_parser.rb +0 -7
- data/lib/ripper_ruby_parser/commenting_ripper_parser.rb +112 -34
- data/lib/ripper_ruby_parser/parser.rb +26 -12
- data/lib/ripper_ruby_parser/sexp_handlers.rb +4 -1
- data/lib/ripper_ruby_parser/sexp_handlers/arguments.rb +7 -6
- data/lib/ripper_ruby_parser/sexp_handlers/arrays.rb +4 -2
- data/lib/ripper_ruby_parser/sexp_handlers/assignment.rb +39 -43
- data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +93 -69
- data/lib/ripper_ruby_parser/sexp_handlers/conditionals.rb +30 -24
- data/lib/ripper_ruby_parser/sexp_handlers/hashes.rb +7 -9
- data/lib/ripper_ruby_parser/sexp_handlers/helper_methods.rb +51 -71
- data/lib/ripper_ruby_parser/sexp_handlers/literals.rb +72 -56
- data/lib/ripper_ruby_parser/sexp_handlers/loops.rb +14 -13
- data/lib/ripper_ruby_parser/sexp_handlers/method_calls.rb +19 -13
- data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +19 -22
- data/lib/ripper_ruby_parser/sexp_handlers/operators.rb +47 -35
- data/lib/ripper_ruby_parser/sexp_processor.rb +72 -85
- data/lib/ripper_ruby_parser/version.rb +1 -1
- data/test/end_to_end/line_numbering_test.rb +1 -1
- data/test/end_to_end/samples_comparison_test.rb +0 -1
- data/test/pt_testcase/pt_test.rb +4 -6
- data/test/{unit → ripper_ruby_parser}/commenting_ripper_parser_test.rb +82 -25
- data/test/{unit → ripper_ruby_parser}/parser_test.rb +37 -170
- data/test/{unit/parser_assignment_test.rb → ripper_ruby_parser/sexp_handlers/assignment_test.rb} +1 -1
- data/test/{unit/parser_blocks_test.rb → ripper_ruby_parser/sexp_handlers/blocks_test.rb} +267 -2
- data/test/{unit/parser_conditionals_test.rb → ripper_ruby_parser/sexp_handlers/conditionals_test.rb} +125 -17
- data/test/{unit/parser_literals_test.rb → ripper_ruby_parser/sexp_handlers/literals_test.rb} +10 -12
- data/test/{unit/parser_loops_test.rb → ripper_ruby_parser/sexp_handlers/loops_test.rb} +1 -1
- data/test/{unit/parser_method_calls_test.rb → ripper_ruby_parser/sexp_handlers/method_calls_test.rb} +10 -10
- data/test/{unit/parser_operators_test.rb → ripper_ruby_parser/sexp_handlers/operators_test.rb} +22 -2
- data/test/{unit → ripper_ruby_parser}/sexp_processor_test.rb +49 -48
- data/test/{unit → ripper_ruby_parser}/version_test.rb +0 -0
- data/test/samples/misc.rb +4 -0
- data/test/test_helper.rb +4 -4
- metadata +28 -42
- data/test/end_to_end/error_conditions_test.rb +0 -51
File without changes
|
data/test/test_helper.rb
CHANGED
@@ -11,11 +11,11 @@ require 'ripper_ruby_parser'
|
|
11
11
|
|
12
12
|
module MiniTest
|
13
13
|
class Spec
|
14
|
-
def formatted
|
14
|
+
def formatted(exp)
|
15
15
|
exp.to_s.gsub(/\), /, "),\n")
|
16
16
|
end
|
17
17
|
|
18
|
-
def to_comments
|
18
|
+
def to_comments(exp)
|
19
19
|
inner = exp.map do |sub_exp|
|
20
20
|
if sub_exp.is_a? Sexp
|
21
21
|
to_comments sub_exp
|
@@ -32,7 +32,7 @@ module MiniTest
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def assert_parsed_as
|
35
|
+
def assert_parsed_as(sexp, code)
|
36
36
|
parser = RipperRubyParser::Parser.new
|
37
37
|
result = parser.parse code
|
38
38
|
if sexp.nil?
|
@@ -42,7 +42,7 @@ module MiniTest
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def assert_parsed_as_before
|
45
|
+
def assert_parsed_as_before(code)
|
46
46
|
oldparser = RubyParser.new
|
47
47
|
newparser = RipperRubyParser::Parser.new
|
48
48
|
expected = oldparser.parse code.dup
|
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.
|
4
|
+
version: 1.2.0
|
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: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sexp_processor
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
description: |2
|
98
84
|
RipperRubyParser is a parser for Ruby based on Ripper that aims to be a
|
99
85
|
drop-in replacement for RubyParser.
|
@@ -128,25 +114,25 @@ files:
|
|
128
114
|
- lib/ripper_ruby_parser/version.rb
|
129
115
|
- test/end_to_end/comments_test.rb
|
130
116
|
- test/end_to_end/comparison_test.rb
|
131
|
-
- test/end_to_end/error_conditions_test.rb
|
132
117
|
- test/end_to_end/lib_comparison_test.rb
|
133
118
|
- test/end_to_end/line_numbering_test.rb
|
134
119
|
- test/end_to_end/samples_comparison_test.rb
|
135
120
|
- test/end_to_end/test_comparison_test.rb
|
136
121
|
- test/pt_testcase/pt_test.rb
|
122
|
+
- test/ripper_ruby_parser/commenting_ripper_parser_test.rb
|
123
|
+
- test/ripper_ruby_parser/parser_test.rb
|
124
|
+
- test/ripper_ruby_parser/sexp_handlers/assignment_test.rb
|
125
|
+
- test/ripper_ruby_parser/sexp_handlers/blocks_test.rb
|
126
|
+
- test/ripper_ruby_parser/sexp_handlers/conditionals_test.rb
|
127
|
+
- test/ripper_ruby_parser/sexp_handlers/literals_test.rb
|
128
|
+
- test/ripper_ruby_parser/sexp_handlers/loops_test.rb
|
129
|
+
- test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb
|
130
|
+
- test/ripper_ruby_parser/sexp_handlers/operators_test.rb
|
131
|
+
- test/ripper_ruby_parser/sexp_processor_test.rb
|
132
|
+
- test/ripper_ruby_parser/version_test.rb
|
137
133
|
- test/samples/inline.rb
|
134
|
+
- test/samples/misc.rb
|
138
135
|
- test/test_helper.rb
|
139
|
-
- test/unit/commenting_ripper_parser_test.rb
|
140
|
-
- test/unit/parser_assignment_test.rb
|
141
|
-
- test/unit/parser_blocks_test.rb
|
142
|
-
- test/unit/parser_conditionals_test.rb
|
143
|
-
- test/unit/parser_literals_test.rb
|
144
|
-
- test/unit/parser_loops_test.rb
|
145
|
-
- test/unit/parser_method_calls_test.rb
|
146
|
-
- test/unit/parser_operators_test.rb
|
147
|
-
- test/unit/parser_test.rb
|
148
|
-
- test/unit/sexp_processor_test.rb
|
149
|
-
- test/unit/version_test.rb
|
150
136
|
homepage: http://www.github.com/mvz/ripper_ruby_parser
|
151
137
|
licenses:
|
152
138
|
- MIT
|
@@ -161,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
147
|
requirements:
|
162
148
|
- - ">="
|
163
149
|
- !ruby/object:Gem::Version
|
164
|
-
version: 2.
|
150
|
+
version: 2.2.0
|
165
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
152
|
requirements:
|
167
153
|
- - ">="
|
@@ -169,29 +155,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
155
|
version: '0'
|
170
156
|
requirements: []
|
171
157
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.7.3
|
173
159
|
signing_key:
|
174
160
|
specification_version: 4
|
175
161
|
summary: Parse with Ripper, produce sexps that are compatible with RubyParser.
|
176
162
|
test_files:
|
177
163
|
- test/end_to_end/comments_test.rb
|
178
164
|
- test/end_to_end/comparison_test.rb
|
179
|
-
- test/end_to_end/error_conditions_test.rb
|
180
165
|
- test/end_to_end/lib_comparison_test.rb
|
181
166
|
- test/end_to_end/line_numbering_test.rb
|
182
167
|
- test/end_to_end/samples_comparison_test.rb
|
183
168
|
- test/end_to_end/test_comparison_test.rb
|
184
169
|
- test/pt_testcase/pt_test.rb
|
170
|
+
- test/ripper_ruby_parser/commenting_ripper_parser_test.rb
|
171
|
+
- test/ripper_ruby_parser/parser_test.rb
|
172
|
+
- test/ripper_ruby_parser/sexp_handlers/assignment_test.rb
|
173
|
+
- test/ripper_ruby_parser/sexp_handlers/blocks_test.rb
|
174
|
+
- test/ripper_ruby_parser/sexp_handlers/conditionals_test.rb
|
175
|
+
- test/ripper_ruby_parser/sexp_handlers/literals_test.rb
|
176
|
+
- test/ripper_ruby_parser/sexp_handlers/loops_test.rb
|
177
|
+
- test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb
|
178
|
+
- test/ripper_ruby_parser/sexp_handlers/operators_test.rb
|
179
|
+
- test/ripper_ruby_parser/sexp_processor_test.rb
|
180
|
+
- test/ripper_ruby_parser/version_test.rb
|
185
181
|
- test/samples/inline.rb
|
182
|
+
- test/samples/misc.rb
|
186
183
|
- test/test_helper.rb
|
187
|
-
- test/unit/commenting_ripper_parser_test.rb
|
188
|
-
- test/unit/parser_assignment_test.rb
|
189
|
-
- test/unit/parser_blocks_test.rb
|
190
|
-
- test/unit/parser_conditionals_test.rb
|
191
|
-
- test/unit/parser_literals_test.rb
|
192
|
-
- test/unit/parser_loops_test.rb
|
193
|
-
- test/unit/parser_method_calls_test.rb
|
194
|
-
- test/unit/parser_operators_test.rb
|
195
|
-
- test/unit/parser_test.rb
|
196
|
-
- test/unit/sexp_processor_test.rb
|
197
|
-
- test/unit/version_test.rb
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe 'Handling errors' do
|
4
|
-
describe 'RipperRubyParser::Parser#parse' do
|
5
|
-
let :newparser do
|
6
|
-
RipperRubyParser::Parser.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'raises an error for an incomplete source' do
|
10
|
-
proc {
|
11
|
-
newparser.parse 'def foo'
|
12
|
-
}.must_raise RipperRubyParser::SyntaxError
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'raises an error for an invalid class name' do
|
16
|
-
proc {
|
17
|
-
newparser.parse('class foo; end')
|
18
|
-
}.must_raise RipperRubyParser::SyntaxError
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'raises an error aliasing $1 as foo' do
|
22
|
-
proc {
|
23
|
-
newparser.parse 'alias foo $1'
|
24
|
-
}.must_raise RipperRubyParser::SyntaxError
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'raises an error aliasing foo as $1' do
|
28
|
-
proc {
|
29
|
-
newparser.parse 'alias $1 foo'
|
30
|
-
}.must_raise RipperRubyParser::SyntaxError
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'raises an error aliasing $2 as $1' do
|
34
|
-
proc {
|
35
|
-
newparser.parse 'alias $1 $2'
|
36
|
-
}.must_raise RipperRubyParser::SyntaxError
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'raises an error assigning to $1' do
|
40
|
-
proc {
|
41
|
-
newparser.parse '$1 = foo'
|
42
|
-
}.must_raise RipperRubyParser::SyntaxError
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'raises an error using an invalid parameter name' do
|
46
|
-
proc {
|
47
|
-
newparser.parse 'def foo(BAR); end'
|
48
|
-
}.must_raise RipperRubyParser::SyntaxError
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|