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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e21010b4e759db5c1502593760f8480381ed63fd
4
- data.tar.gz: c6549debc54796bf1151ee522d85caef6b6db7a2
3
+ metadata.gz: ad86813fd975be2313a38f97a4c04f91dca90dc0
4
+ data.tar.gz: 19160d4496e5e5cbf13f1e2e149885ef8ebd6000
5
5
  SHA512:
6
- metadata.gz: 342af109c4ede135af5f555073dcb2b10c1bdef9b1873598e5fc84dd5c57d517e8d6d5f51c4a856695f10fd0ead95ab68a19acd060c8acda82564bf95a5de2e0
7
- data.tar.gz: 9abf7e144000af5631f23440abc8557210a67dbc935793ab3add786ba838ae77f19c5f5a428932f92c6a596c6892b68d7051c2dbd0a5afc32c07d4f1d91ff74c
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
@@ -3,5 +3,8 @@ source 'https://rubygems.org'
3
3
 
4
4
  gemspec
5
5
 
6
+ gem 'anima'
7
+ gem 'morpher'
8
+
6
9
  gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
7
10
  eval_gemfile 'Gemfile.devtools'
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 13
3
- total_score: 718
3
+ total_score: 727
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::LocalVariableScope#visit
131
+ - Unparser::AST::LocalVariableScopeEnumerator#visit
132
+ - Unparser::AST::LocalVariableScope#match
131
133
  enabled: true
@@ -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
- key, _value = *pair
84
- if key.type == :sym && key.children.first.to_s =~ BAREWORD
85
- n(:pair_colon, pair.children)
83
+ if pair.type == :kwsplat
84
+ pair
86
85
  else
87
- n(:pair_rocket, pair.children)
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
 
@@ -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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'unparser'
5
- gem.version = '0.1.11'
5
+ gem.version = '0.1.12'
6
6
 
7
7
  gem.authors = ['Markus Schirp']
8
8
  gem.email = 'mbj@schir-dso.com'
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.11
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 00:00:00.000000000 Z
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser