unparser 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +5 -1
- data/Gemfile +3 -0
- data/config/flay.yml +1 -1
- data/config/reek.yml +3 -1
- data/lib/unparser/cli/source.rb +17 -0
- data/lib/unparser/emitter/literal/hash.rb +8 -4
- data/lib/unparser/emitter/splat.rb +21 -0
- data/spec/unit/unparser_spec.rb +16 -0
- data/unparser.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad86813fd975be2313a38f97a4c04f91dca90dc0
|
4
|
+
data.tar.gz: 19160d4496e5e5cbf13f1e2e149885ef8ebd6000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a689f724e095ff85b0a5398e3a9f111d3ba422bec3614afefc6f1906171059154606ab90d39b6a3581806a9892d59c9ad6b1c102ee88bbce8fbd1deff5f6f406
|
7
|
+
data.tar.gz: 2a8cd18a6623539df988d61e7bfd9c2cd800eb6f539ed1e2d8b9a15c54a43ebded2ad18419756aac5797f6e4fac99c2258dba6dd32f1f24240cc27b249e582bc
|
data/Changelog.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# v0.1.12 2014-04-13
|
2
|
+
|
3
|
+
* Add support for 2.1 kwsplat
|
4
|
+
|
1
5
|
# v0.1.11 2014-04-11
|
2
6
|
|
3
7
|
* Fix performance on local variable scope inspection
|
@@ -9,7 +13,7 @@
|
|
9
13
|
|
10
14
|
# v0.1.9 2014-01-14
|
11
15
|
|
12
|
-
* Fix emit of proc { |(a) }
|
16
|
+
* Fix emit of proc { |(a)| }
|
13
17
|
|
14
18
|
# v0.1.8 2014-01-11
|
15
19
|
|
data/Gemfile
CHANGED
data/config/flay.yml
CHANGED
data/config/reek.yml
CHANGED
@@ -121,11 +121,13 @@ ControlParameter:
|
|
121
121
|
# False positive:
|
122
122
|
- Unparser::Emitter#emit_body
|
123
123
|
- Unparser::Emitter#conditional_parentheses
|
124
|
+
- Unparser::AST::LocalVariableScope#match
|
124
125
|
enabled: true
|
125
126
|
NilCheck:
|
126
127
|
enabled: false
|
127
128
|
LongYieldList:
|
128
129
|
max_params: 1
|
129
130
|
exclude:
|
130
|
-
- Unparser::AST::
|
131
|
+
- Unparser::AST::LocalVariableScopeEnumerator#visit
|
132
|
+
- Unparser::AST::LocalVariableScope#match
|
131
133
|
enabled: true
|
data/lib/unparser/cli/source.rb
CHANGED
@@ -256,6 +256,23 @@ module Unparser
|
|
256
256
|
memoize :original_source
|
257
257
|
|
258
258
|
end # File
|
259
|
+
|
260
|
+
# Source passed in as node
|
261
|
+
class Node < self
|
262
|
+
include Concord.new(:original_ast)
|
263
|
+
|
264
|
+
# Return original source
|
265
|
+
#
|
266
|
+
# @return [String]
|
267
|
+
#
|
268
|
+
# @api private
|
269
|
+
#
|
270
|
+
def original_source
|
271
|
+
Unparser.unparse(original_ast)
|
272
|
+
end
|
273
|
+
memoize :original_source
|
274
|
+
end # Node
|
275
|
+
|
259
276
|
end # Source
|
260
277
|
end # CLI
|
261
278
|
end # Unparser
|
@@ -80,11 +80,15 @@ module Unparser
|
|
80
80
|
#
|
81
81
|
def effective_body
|
82
82
|
children.map do |pair|
|
83
|
-
|
84
|
-
|
85
|
-
n(:pair_colon, pair.children)
|
83
|
+
if pair.type == :kwsplat
|
84
|
+
pair
|
86
85
|
else
|
87
|
-
|
86
|
+
key, _value = *pair
|
87
|
+
if key.type == :sym && key.children.first.to_s =~ BAREWORD
|
88
|
+
n(:pair_colon, pair.children)
|
89
|
+
else
|
90
|
+
n(:pair_rocket, pair.children)
|
91
|
+
end
|
88
92
|
end
|
89
93
|
end
|
90
94
|
end
|
@@ -2,6 +2,27 @@
|
|
2
2
|
|
3
3
|
module Unparser
|
4
4
|
class Emitter
|
5
|
+
# Emitter for splats
|
6
|
+
class KwSplat < self
|
7
|
+
|
8
|
+
handle :kwsplat
|
9
|
+
|
10
|
+
children :subject
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
# Perform dispatch
|
15
|
+
#
|
16
|
+
# @return [undefined]
|
17
|
+
#
|
18
|
+
# @api private
|
19
|
+
#
|
20
|
+
def dispatch
|
21
|
+
write(T_SPLAT, T_SPLAT)
|
22
|
+
visit(subject)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
5
26
|
# Emitter for splats
|
6
27
|
class Splat < self
|
7
28
|
|
data/spec/unit/unparser_spec.rb
CHANGED
@@ -71,6 +71,22 @@ describe Unparser do
|
|
71
71
|
assert_round_trip(strip(input), versions)
|
72
72
|
end
|
73
73
|
|
74
|
+
context 'kwargs' do
|
75
|
+
assert_source <<-RUBY, %w(2.1)
|
76
|
+
def foo(bar:, baz:)
|
77
|
+
end
|
78
|
+
RUBY
|
79
|
+
|
80
|
+
assert_source <<-RUBY, %w(2.1)
|
81
|
+
foo(**bar)
|
82
|
+
RUBY
|
83
|
+
|
84
|
+
assert_source <<-RUBY, %w(2.1)
|
85
|
+
def foo(bar:, baz: "value")
|
86
|
+
end
|
87
|
+
RUBY
|
88
|
+
end
|
89
|
+
|
74
90
|
context 'literal' do
|
75
91
|
context 'fixnum' do
|
76
92
|
assert_generates s(:int, 1), '1'
|
data/unparser.gemspec
CHANGED
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.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|