unparser 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +9 -1
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -31
- data/README.md +2 -3
- data/config/flay.yml +1 -1
- data/lib/unparser/ast.rb +1 -1
- data/lib/unparser/ast/local_variable_scope.rb +6 -6
- data/lib/unparser/cli.rb +1 -1
- data/lib/unparser/cli/source.rb +2 -2
- data/lib/unparser/constants.rb +1 -1
- data/lib/unparser/dsl.rb +1 -1
- data/lib/unparser/emitter.rb +2 -4
- data/lib/unparser/emitter/argument.rb +9 -13
- data/lib/unparser/emitter/literal/primitive.rb +1 -1
- data/lib/unparser/node_helpers.rb +4 -2
- data/lib/unparser/preprocessor.rb +1 -1
- data/spec/integrations.yml +5 -0
- data/spec/unit/unparser_spec.rb +12 -6
- data/unparser.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7b6ae43ecab2e1b02ad4688d19015cb19930b66c7c72b0d84603696a3bdd6a6
|
4
|
+
data.tar.gz: 21b9230570b7a1124c070b35c58c1704c3640d54581b07003fc9400b18a8f4ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 580f2639ae9a1bfe704be90ed16c390d6151bbfaf19644f84aa31012bb896a6e763cfc4e24573674df92c4329f68e3303e381ffa02097c818e66e6f42a28d2c2
|
7
|
+
data.tar.gz: 1bb2d10d2fa4f30e7b18ebe880d80e22b21e4fdf325518d3b9b65f2c2ec2f456307f74502a22399bad75f90a9ba26500ae553affd8ab71b126b9198a5cf15269
|
data/.circleci/config.yml
CHANGED
@@ -30,7 +30,15 @@ jobs:
|
|
30
30
|
steps:
|
31
31
|
- checkout
|
32
32
|
- run: bundle install
|
33
|
-
- run:
|
33
|
+
- run: |
|
34
|
+
bundle \
|
35
|
+
exec \
|
36
|
+
mutant \
|
37
|
+
--ignore-subject 'Unparser::AST::LocalVariableScope*' \
|
38
|
+
--since origin/master \
|
39
|
+
--zombie \
|
40
|
+
-- \
|
41
|
+
'Unparser*'
|
34
42
|
workflows:
|
35
43
|
version: 2
|
36
44
|
test:
|
data/Changelog.md
CHANGED
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem 'mutant', git: 'https://github.com/mbj/mutant.git'
|
7
|
+
gem 'mutant', git: 'https://github.com/mbj/mutant.git', branch: 'upgrade/parser'
|
8
8
|
|
9
9
|
source 'https://oss:Px2ENN7S91OmWaD5G7MIQJi1dmtmYrEh@gem.mutant.dev' do
|
10
10
|
gem 'mutant-license'
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/mbj/mutant.git
|
3
|
-
revision:
|
3
|
+
revision: f138cc7b16ed6dab728ef2e2f46731754086b9e8
|
4
|
+
branch: upgrade/parser
|
4
5
|
specs:
|
5
|
-
mutant (0.
|
6
|
+
mutant (0.9.1)
|
6
7
|
abstract_type (~> 0.0.7)
|
7
8
|
adamantium (~> 0.2.0)
|
8
9
|
anima (~> 0.3.1)
|
@@ -12,24 +13,21 @@ GIT
|
|
12
13
|
equalizer (~> 0.0.9)
|
13
14
|
ice_nine (~> 0.11.1)
|
14
15
|
memoizable (~> 0.4.2)
|
15
|
-
mutant-license (~> 0.0
|
16
|
-
parser (~> 2.6.
|
16
|
+
mutant-license (~> 0.1.0)
|
17
|
+
parser (~> 2.6.5)
|
17
18
|
procto (~> 0.0.2)
|
18
|
-
unparser (~> 0.4.
|
19
|
-
mutant-rspec (0.8.25)
|
20
|
-
mutant (~> 0.8.25)
|
21
|
-
rspec-core (>= 3.8.0, < 4.0.0)
|
19
|
+
unparser (~> 0.4.5)
|
22
20
|
|
23
21
|
PATH
|
24
22
|
remote: .
|
25
23
|
specs:
|
26
|
-
unparser (0.4.
|
24
|
+
unparser (0.4.6)
|
27
25
|
abstract_type (~> 0.0.7)
|
28
26
|
adamantium (~> 0.2.0)
|
29
27
|
concord (~> 0.1.5)
|
30
28
|
diff-lcs (~> 1.3)
|
31
29
|
equalizer (~> 0.0.9)
|
32
|
-
parser (~> 2.6.
|
30
|
+
parser (~> 2.6.5)
|
33
31
|
procto (~> 0.0.2)
|
34
32
|
|
35
33
|
GEM
|
@@ -58,15 +56,13 @@ GEM
|
|
58
56
|
equalizer (~> 0.0.9)
|
59
57
|
descendants_tracker (0.0.4)
|
60
58
|
thread_safe (~> 0.3, >= 0.3.1)
|
61
|
-
devtools (0.1.
|
59
|
+
devtools (0.1.24)
|
62
60
|
abstract_type (~> 0.0.7)
|
63
61
|
adamantium (~> 0.2.0)
|
64
62
|
anima (~> 0.3.0)
|
65
63
|
concord (~> 0.1.5)
|
66
64
|
flay (~> 2.12.0)
|
67
65
|
flog (~> 4.6.2)
|
68
|
-
mutant (~> 0.8.24)
|
69
|
-
mutant-rspec (~> 0.8.24)
|
70
66
|
procto (~> 0.0.3)
|
71
67
|
rake (~> 12.3.0)
|
72
68
|
reek (~> 5.3.0)
|
@@ -78,21 +74,21 @@ GEM
|
|
78
74
|
yard (~> 0.9.16)
|
79
75
|
yardstick (~> 0.9.9)
|
80
76
|
diff-lcs (1.3)
|
81
|
-
docile (1.3.
|
77
|
+
docile (1.3.2)
|
82
78
|
equalizer (0.0.11)
|
83
79
|
erubis (2.7.0)
|
84
|
-
flay (2.12.
|
80
|
+
flay (2.12.1)
|
85
81
|
erubis (~> 2.7.0)
|
86
82
|
path_expander (~> 1.0)
|
87
83
|
ruby_parser (~> 3.0)
|
88
84
|
sexp_processor (~> 4.0)
|
89
|
-
flog (4.6.
|
85
|
+
flog (4.6.4)
|
90
86
|
path_expander (~> 1.0)
|
91
87
|
ruby_parser (~> 3.1, > 3.1.0)
|
92
88
|
sexp_processor (~> 4.8)
|
93
89
|
ice_nine (0.11.2)
|
94
|
-
jaro_winkler (1.5.
|
95
|
-
json (2.
|
90
|
+
jaro_winkler (1.5.4)
|
91
|
+
json (2.3.0)
|
96
92
|
kwalify (0.7.2)
|
97
93
|
memoizable (0.4.2)
|
98
94
|
thread_safe (~> 0.3, >= 0.3.1)
|
@@ -105,16 +101,16 @@ GEM
|
|
105
101
|
equalizer (~> 0.0.9)
|
106
102
|
ice_nine (~> 0.11.0)
|
107
103
|
procto (~> 0.0.2)
|
108
|
-
mutant-license (0.0
|
109
|
-
parallel (1.
|
110
|
-
parser (2.6.
|
104
|
+
mutant-license (0.1.0)
|
105
|
+
parallel (1.19.1)
|
106
|
+
parser (2.6.5.0)
|
111
107
|
ast (~> 2.4.0)
|
112
|
-
path_expander (1.0
|
108
|
+
path_expander (1.1.0)
|
113
109
|
powerpack (0.1.2)
|
114
110
|
procto (0.0.3)
|
115
111
|
psych (3.1.0)
|
116
112
|
rainbow (3.0.0)
|
117
|
-
rake (12.3.
|
113
|
+
rake (12.3.3)
|
118
114
|
reek (5.3.2)
|
119
115
|
codeclimate-engine-rb (~> 0.4.0)
|
120
116
|
kwalify (~> 0.7.0)
|
@@ -125,18 +121,18 @@ GEM
|
|
125
121
|
rspec-core (~> 3.8.0)
|
126
122
|
rspec-expectations (~> 3.8.0)
|
127
123
|
rspec-mocks (~> 3.8.0)
|
128
|
-
rspec-core (3.8.
|
124
|
+
rspec-core (3.8.2)
|
129
125
|
rspec-support (~> 3.8.0)
|
130
|
-
rspec-expectations (3.8.
|
126
|
+
rspec-expectations (3.8.6)
|
131
127
|
diff-lcs (>= 1.2.0, < 2.0)
|
132
128
|
rspec-support (~> 3.8.0)
|
133
129
|
rspec-its (1.2.0)
|
134
130
|
rspec-core (>= 3.0.0)
|
135
131
|
rspec-expectations (>= 3.0.0)
|
136
|
-
rspec-mocks (3.8.
|
132
|
+
rspec-mocks (3.8.2)
|
137
133
|
diff-lcs (>= 1.2.0, < 2.0)
|
138
134
|
rspec-support (~> 3.8.0)
|
139
|
-
rspec-support (3.8.
|
135
|
+
rspec-support (3.8.3)
|
140
136
|
rubocop (0.61.1)
|
141
137
|
jaro_winkler (~> 1.5.1)
|
142
138
|
parallel (~> 1.10)
|
@@ -145,10 +141,10 @@ GEM
|
|
145
141
|
rainbow (>= 2.2.2, < 4.0)
|
146
142
|
ruby-progressbar (~> 1.7)
|
147
143
|
unicode-display_width (~> 1.4.0)
|
148
|
-
ruby-progressbar (1.10.
|
149
|
-
ruby_parser (3.
|
144
|
+
ruby-progressbar (1.10.1)
|
145
|
+
ruby_parser (3.14.1)
|
150
146
|
sexp_processor (~> 4.9)
|
151
|
-
sexp_processor (4.
|
147
|
+
sexp_processor (4.13.0)
|
152
148
|
simplecov (0.16.1)
|
153
149
|
docile (~> 1.1)
|
154
150
|
json (>= 1.8, < 3)
|
@@ -161,7 +157,7 @@ GEM
|
|
161
157
|
coercible (~> 1.0)
|
162
158
|
descendants_tracker (~> 0.0, >= 0.0.3)
|
163
159
|
equalizer (~> 0.0, >= 0.0.9)
|
164
|
-
yard (0.9.
|
160
|
+
yard (0.9.22)
|
165
161
|
yardstick (0.9.9)
|
166
162
|
yard (~> 0.8, >= 0.8.7.2)
|
167
163
|
|
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
unparser
|
2
2
|
========
|
3
3
|
|
4
|
-
[![Build Status](https://secure.travis-ci.org/mbj/unparser.
|
5
|
-
[![
|
6
|
-
[![Code Climate](https://codeclimate.com/github/mbj/unparser.png)](https://codeclimate.com/github/mbj/unparser)
|
4
|
+
[![Build Status](https://secure.travis-ci.org/mbj/unparser.svg?branch=master)](http://travis-ci.org/mbj/unparser)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/mbj/unparser.svg)](https://codeclimate.com/github/mbj/unparser)
|
7
6
|
[![Gem Version](https://img.shields.io/gem/v/unparser.svg)](https://rubygems.org/gems/unparser)
|
8
7
|
|
9
8
|
Generate equivalent source for ASTs from whitequarks [parser](https://github.com/whitequark/parser).
|
data/config/flay.yml
CHANGED
data/lib/unparser/ast.rb
CHANGED
@@ -56,8 +56,8 @@ module Unparser
|
|
56
56
|
|
57
57
|
# Test if local variables where first assigned in body and read by conditional
|
58
58
|
#
|
59
|
-
# @param [Parser::AST::Node] conditional
|
60
59
|
# @param [Parser::AST::Node] body
|
60
|
+
# @param [Parser::AST::Node] condition
|
61
61
|
#
|
62
62
|
# @api private
|
63
63
|
#
|
@@ -78,16 +78,16 @@ module Unparser
|
|
78
78
|
|
79
79
|
# Match node
|
80
80
|
#
|
81
|
-
# @param [Parser::AST::Node]
|
81
|
+
# @param [Parser::AST::Node] needle
|
82
82
|
# if block given
|
83
83
|
#
|
84
84
|
# @return [Boolean]
|
85
85
|
#
|
86
86
|
# @api private
|
87
87
|
#
|
88
|
-
def match(
|
88
|
+
def match(needle)
|
89
89
|
@items.each do |node, current, before|
|
90
|
-
return yield(current, before) if node.equal?(
|
90
|
+
return yield(current, before) if node.equal?(needle)
|
91
91
|
end
|
92
92
|
false
|
93
93
|
end
|
@@ -149,7 +149,7 @@ module Unparser
|
|
149
149
|
|
150
150
|
# Visit node and record local variable state
|
151
151
|
#
|
152
|
-
# @param [Parser::AST::Node]
|
152
|
+
# @param [Parser::AST::Node] node
|
153
153
|
#
|
154
154
|
# @return [undefined]
|
155
155
|
#
|
@@ -168,7 +168,7 @@ module Unparser
|
|
168
168
|
|
169
169
|
# Record local variable state
|
170
170
|
#
|
171
|
-
# @param [Parser::AST::Node]
|
171
|
+
# @param [Parser::AST::Node] node
|
172
172
|
#
|
173
173
|
# @return [undefined]
|
174
174
|
#
|
data/lib/unparser/cli.rb
CHANGED
data/lib/unparser/cli/source.rb
CHANGED
@@ -24,7 +24,7 @@ module Unparser
|
|
24
24
|
|
25
25
|
# Build generated source
|
26
26
|
#
|
27
|
-
# @param [Parser::AST::Node]
|
27
|
+
# @param [Parser::AST::Node] ast
|
28
28
|
#
|
29
29
|
# @api private
|
30
30
|
#
|
@@ -82,7 +82,7 @@ module Unparser
|
|
82
82
|
|
83
83
|
# Return stripped source
|
84
84
|
#
|
85
|
-
# @param [String]
|
85
|
+
# @param [String] source
|
86
86
|
#
|
87
87
|
# @return [String]
|
88
88
|
#
|
data/lib/unparser/constants.rb
CHANGED
data/lib/unparser/dsl.rb
CHANGED
data/lib/unparser/emitter.rb
CHANGED
@@ -79,7 +79,7 @@ module Unparser
|
|
79
79
|
|
80
80
|
# Register emitter for type
|
81
81
|
#
|
82
|
-
# @param [Symbol]
|
82
|
+
# @param [Symbol] types
|
83
83
|
#
|
84
84
|
# @return [undefined]
|
85
85
|
#
|
@@ -249,7 +249,6 @@ module Unparser
|
|
249
249
|
# Emit delimited body
|
250
250
|
#
|
251
251
|
# @param [Enumerable<Parser::AST::Node>] nodes
|
252
|
-
# @param [String] delimiter
|
253
252
|
#
|
254
253
|
# @return [undefined]
|
255
254
|
#
|
@@ -262,7 +261,6 @@ module Unparser
|
|
262
261
|
# Emit delimited body
|
263
262
|
#
|
264
263
|
# @param [Enumerable<Parser::AST::Node>] nodes
|
265
|
-
# @param [String] delimiter
|
266
264
|
#
|
267
265
|
# @return [undefined]
|
268
266
|
#
|
@@ -432,7 +430,7 @@ module Unparser
|
|
432
430
|
|
433
431
|
# Emit non nil body
|
434
432
|
#
|
435
|
-
# @param [Parser::AST::Node]
|
433
|
+
# @param [Parser::AST::Node] body
|
436
434
|
#
|
437
435
|
# @return [undefined]
|
438
436
|
#
|
@@ -240,7 +240,7 @@ module Unparser
|
|
240
240
|
|
241
241
|
handle :procarg0
|
242
242
|
|
243
|
-
|
243
|
+
PARENS = %i[restarg mlhs].freeze
|
244
244
|
|
245
245
|
private
|
246
246
|
|
@@ -251,22 +251,18 @@ module Unparser
|
|
251
251
|
# @api private
|
252
252
|
#
|
253
253
|
def dispatch
|
254
|
-
if
|
255
|
-
|
254
|
+
if needs_parens?
|
255
|
+
parentheses do
|
256
|
+
delimited(children)
|
257
|
+
end
|
256
258
|
else
|
257
|
-
|
259
|
+
delimited(children)
|
258
260
|
end
|
259
261
|
end
|
260
262
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
#
|
265
|
-
# @api private
|
266
|
-
#
|
267
|
-
def emit_multiple_children
|
268
|
-
parentheses do
|
269
|
-
delimited(children)
|
263
|
+
def needs_parens?
|
264
|
+
children.length > 1 || children.any? do |node|
|
265
|
+
PARENS.include?(node.type)
|
270
266
|
end
|
271
267
|
end
|
272
268
|
end
|
@@ -5,7 +5,8 @@ module Unparser
|
|
5
5
|
|
6
6
|
# Helper for building nodes
|
7
7
|
#
|
8
|
-
# @param [Symbol]
|
8
|
+
# @param [Symbol] type
|
9
|
+
# @param [Parser::AST::Node] children
|
9
10
|
#
|
10
11
|
# @return [Parser::AST::Node]
|
11
12
|
#
|
@@ -19,9 +20,10 @@ module Unparser
|
|
19
20
|
|
20
21
|
# Helper for building nodes
|
21
22
|
#
|
22
|
-
# @param [Symbol]
|
23
|
+
# @param [Symbol] type
|
23
24
|
#
|
24
25
|
# @return [Parser::AST::Node]
|
26
|
+
# @param [Array] children
|
25
27
|
#
|
26
28
|
# @api private
|
27
29
|
#
|
data/spec/integrations.yml
CHANGED
@@ -40,10 +40,12 @@
|
|
40
40
|
- core/env/element_reference_spec.rb
|
41
41
|
- core/io/readpartial_spec.rb
|
42
42
|
- core/io/shared/gets_ascii.rb
|
43
|
+
- core/kernel/shared/sprintf_encoding.rb
|
43
44
|
- core/marshal/dump_spec.rb
|
44
45
|
- core/marshal/fixtures/marshal_data.rb
|
45
46
|
- core/marshal/shared/load.rb
|
46
47
|
- core/random/bytes_spec.rb
|
48
|
+
- core/regexp/shared/new.rb
|
47
49
|
- core/regexp/shared/new_ascii.rb
|
48
50
|
- core/regexp/shared/new_ascii_8bit.rb
|
49
51
|
- core/regexp/shared/quote.rb
|
@@ -51,6 +53,8 @@
|
|
51
53
|
- core/string/casecmp_spec.rb
|
52
54
|
- core/string/codepoints_spec.rb
|
53
55
|
- core/string/count_spec.rb
|
56
|
+
- core/string/encode_spec.rb
|
57
|
+
- core/string/inspect_spec.rb
|
54
58
|
- core/string/shared/codepoints.rb
|
55
59
|
- core/string/shared/each_codepoint_without_block.rb
|
56
60
|
- core/string/shared/eql.rb
|
@@ -71,6 +75,7 @@
|
|
71
75
|
- language/regexp/escapes_spec.rb
|
72
76
|
- language/source_encoding_spec.rb
|
73
77
|
- language/string_spec.rb
|
78
|
+
- library/base64/decode64_spec.rb
|
74
79
|
- library/digest/md5/shared/constants.rb
|
75
80
|
- library/digest/md5/shared/sample.rb
|
76
81
|
- library/digest/sha1/shared/constants.rb
|
data/spec/unit/unparser_spec.rb
CHANGED
@@ -547,12 +547,6 @@ describe Unparser, mutant_expression: 'Unparser::Emitter*' do
|
|
547
547
|
foo.bar(*args)
|
548
548
|
RUBY
|
549
549
|
|
550
|
-
assert_source <<~'RUBY'
|
551
|
-
foo.bar do |(a)|
|
552
|
-
d
|
553
|
-
end
|
554
|
-
RUBY
|
555
|
-
|
556
550
|
assert_source <<~'RUBY'
|
557
551
|
foo.bar do |(a, b), c|
|
558
552
|
d
|
@@ -574,6 +568,18 @@ describe Unparser, mutant_expression: 'Unparser::Emitter*' do
|
|
574
568
|
end
|
575
569
|
RUBY
|
576
570
|
|
571
|
+
assert_source <<~'RUBY'
|
572
|
+
foo.bar do |*|
|
573
|
+
d
|
574
|
+
end
|
575
|
+
RUBY
|
576
|
+
|
577
|
+
assert_source <<~'RUBY'
|
578
|
+
foo.bar do |(*)|
|
579
|
+
d
|
580
|
+
end
|
581
|
+
RUBY
|
582
|
+
|
577
583
|
assert_source <<~'RUBY'
|
578
584
|
foo.bar do |((*))|
|
579
585
|
d
|
data/unparser.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'unparser'
|
3
|
-
gem.version = '0.4.
|
3
|
+
gem.version = '0.4.6'
|
4
4
|
|
5
5
|
gem.authors = ['Markus Schirp']
|
6
6
|
gem.email = 'mbj@schirp-dso.com'
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_dependency('equalizer', '~> 0.0.9')
|
22
22
|
gem.add_dependency('diff-lcs', '~> 1.3')
|
23
23
|
gem.add_dependency('concord', '~> 0.1.5')
|
24
|
-
gem.add_dependency('parser', '~> 2.6.
|
24
|
+
gem.add_dependency('parser', '~> 2.6.5')
|
25
25
|
gem.add_dependency('procto', '~> 0.0.2')
|
26
26
|
|
27
27
|
gem.add_development_dependency('anima', '~> 0.3.1')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unparser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abstract_type
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.6.
|
89
|
+
version: 2.6.5
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.6.
|
96
|
+
version: 2.6.5
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: procto
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|