unparser 0.0.15 → 0.0.16

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: fcc5300960fb746ffaeee812c9d21214d27abe4f
4
- data.tar.gz: 44b23113a26b5621647687ede360f478a561f56d
3
+ metadata.gz: 5a584013dc79bab624a49c0ce4e8b788d8b62412
4
+ data.tar.gz: b43573081cef30e216c7ee0caf856d51b97b20f2
5
5
  SHA512:
6
- metadata.gz: ea844db930580529a6e45a935b6fd756da832c8578251040303deffe7057bb62efdca72e700cdb03d96c623744aacc3f7fb4b540203690a17e10a92fa5805edf
7
- data.tar.gz: d398a4881888cc974bcaef1ecd255d5ef382b71f0061c8f2816a159383aa162b9d92f927e1eef6d7a59858156631842f02c753b82131bc18c4d187f3c32127af
6
+ metadata.gz: 34c5b966271853e563b7f3b9d6126aff72234e85f32ba3358bdc3dab4530d9a3041762ae94c184e88f191511bcd4e85e16ac09c3006e9f9011ad4cec9d4a9c56
7
+ data.tar.gz: ea0188da6b1b3311dbe36363b092905b336b4555c9536301f83f7b6406553b06f6cf7aba089230117b0819f356d6f97f65381a41650c29ebbce94e85e1c71eca
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'devtools', :git => 'https://github.com/rom-rb/devtools.git'
6
- eval File.read('Gemfile.devtools')
6
+ eval_gemfile 'Gemfile.devtools'
data/Gemfile.devtools CHANGED
@@ -3,7 +3,7 @@
3
3
  group :development do
4
4
  gem 'rake', '~> 10.1.0'
5
5
  gem 'rspec', '~> 2.14.1'
6
- gem 'yard', '~> 0.8.6.2'
6
+ gem 'yard', '~> 0.8.7'
7
7
  end
8
8
 
9
9
  group :yard do
@@ -14,11 +14,11 @@ group :guard do
14
14
  gem 'guard', '~> 1.8.1'
15
15
  gem 'guard-bundler', '~> 1.0.0'
16
16
  gem 'guard-rspec', '~> 3.0.2'
17
- # gem 'guard-rubocop', '~> 0.2.0'
17
+ gem 'guard-rubocop', '~> 0.2.0'
18
18
  gem 'guard-mutant', '~> 0.0.1'
19
19
 
20
20
  # file system change event handling
21
- gem 'listen', '~> 1.2.2'
21
+ gem 'listen', '~> 1.3.0'
22
22
  gem 'rb-fchange', '~> 0.0.6', require: false
23
23
  gem 'rb-fsevent', '~> 0.9.3', require: false
24
24
  gem 'rb-inotify', '~> 0.9.0', require: false
@@ -31,21 +31,17 @@ end
31
31
 
32
32
  group :metrics do
33
33
  gem 'coveralls', '~> 0.6.7'
34
- gem 'flay', '~> 2.3.1'
34
+ gem 'flay', '~> 2.4.0'
35
35
  gem 'flog', '~> 4.1.1'
36
- gem 'reek', '~> 1.3.1', git: 'https://github.com/troessner/reek.git'
37
- # gem 'rubocop', '~> 0.10.0', git: 'https://github.com/bbatsov/rubocop.git'
36
+ gem 'reek', '~> 1.3.2'
37
+ gem 'rubocop', '~> 0.11.0'
38
38
  gem 'simplecov', '~> 0.7.1'
39
- gem 'yardstick', '~> 0.9.6'
39
+ gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
40
40
 
41
41
  platforms :ruby_19, :ruby_20 do
42
- gem 'mutant', '~> 0.3.0.beta17'
42
+ gem 'mutant', git: 'https://github.com/mbj/mutant.git'
43
43
  gem 'yard-spellcheck', '~> 0.1.5'
44
44
  end
45
-
46
- platforms :rbx do
47
- gem 'pelusa', '~> 0.2.2'
48
- end
49
45
  end
50
46
 
51
47
  group :benchmarks do
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 13
3
- total_score: 377
3
+ total_score: 383
data/config/reek.yml CHANGED
@@ -19,7 +19,8 @@ TooManyMethods:
19
19
  enabled: true
20
20
  max_methods: 10
21
21
  UncommunicativeMethodName:
22
- accept: []
22
+ accept:
23
+ - s
23
24
  exclude: []
24
25
  enabled: true
25
26
  reject:
@@ -58,6 +59,7 @@ NestedIterators:
58
59
  ignore_iterators: []
59
60
  exclude:
60
61
  - Unparser::Emitter#self.children
62
+ - Unparser::Emitter::Literal::Regexp#dispatch
61
63
  enabled: true
62
64
  max_allowed_nesting: 1
63
65
  TooManyStatements:
@@ -9,7 +9,7 @@ module Unparser
9
9
  BINARY_OPERATORS = %w(
10
10
  + - * / & | && || << >> ==
11
11
  === != <= < <=> > >= =~ !~ ^
12
- **
12
+ ** %
13
13
  ).map(&:to_sym).to_set
14
14
 
15
15
  WS = ' '
@@ -138,8 +138,6 @@ module Unparser
138
138
  #
139
139
  attr_reader :node
140
140
 
141
- private
142
-
143
141
  # Return buffer
144
142
  #
145
143
  # @return [Buffer] buffer
@@ -158,6 +156,8 @@ module Unparser
158
156
  attr_reader :parent
159
157
  protected :parent
160
158
 
159
+ private
160
+
161
161
  # Emit contents of block within parentheses
162
162
  #
163
163
  # @return [undefined]
@@ -334,6 +334,18 @@ module Unparser
334
334
  parent && parent.node && parent.node.type
335
335
  end
336
336
 
337
+ # Helper for building nodes
338
+ #
339
+ # @param [Symbol]
340
+ #
341
+ # @return [Parser::AST::Node]
342
+ #
343
+ # @api private
344
+ #
345
+ def s(type, *children)
346
+ Parser::AST::Node.new(type, *children)
347
+ end
348
+
337
349
  # Emitter that fully relies on parser source maps
338
350
  class SourceMap < self
339
351
 
@@ -8,7 +8,7 @@ module Unparser
8
8
  :eflipflop => '...',
9
9
  ).freeze
10
10
 
11
- handle *MAP.keys
11
+ handle(*MAP.keys)
12
12
 
13
13
  children :left, :right
14
14
 
@@ -8,7 +8,7 @@ module Unparser
8
8
  :postexe => K_POSTEXE
9
9
  }.freeze
10
10
 
11
- handle *MAP.keys
11
+ handle(*MAP.keys)
12
12
 
13
13
  children :body
14
14
 
@@ -8,6 +8,29 @@ module Unparser
8
8
  OPEN = '#{'.freeze
9
9
  CLOSE = '}'.freeze
10
10
 
11
+ # Emitter for interpolated nodes
12
+ class Interpolation < self
13
+
14
+ handle :interpolated
15
+
16
+ children :subject
17
+
18
+ private
19
+
20
+ # Perform dispatch
21
+ #
22
+ # @return [undefined]
23
+ #
24
+ # @api private
25
+ #
26
+ def dispatch
27
+ write(OPEN)
28
+ visit(subject)
29
+ write(CLOSE)
30
+ end
31
+
32
+ end
33
+
11
34
  private
12
35
 
13
36
  # Perform dispatch
@@ -9,7 +9,7 @@ module Unparser
9
9
  :erange => '...'
10
10
  )
11
11
 
12
- handle *TOKENS.keys
12
+ handle(*TOKENS.keys)
13
13
 
14
14
  children :begin_node, :end_node
15
15
 
@@ -18,11 +18,42 @@ module Unparser
18
18
  #
19
19
  def dispatch
20
20
  parentheses(DELIMITER, DELIMITER) do
21
- visit(dynamic_body)
21
+ # stupid for now
22
+ body.each do |child|
23
+ write_body(child)
24
+ end
25
+ #visit(dynamic_body)
22
26
  end
23
27
  visit(children.last)
24
28
  end
25
29
 
30
+ # Return non regopt children
31
+ #
32
+ # @return [Array<Parser::AST::Node>]
33
+ #
34
+ # @api private
35
+ #
36
+ def body
37
+ children[0..-2]
38
+ end
39
+
40
+ # Write specific body component
41
+ #
42
+ # @param [Parser::AST::Node] node
43
+ #
44
+ # @return [undefined]
45
+ #
46
+ # @api private
47
+ #
48
+ def write_body(node)
49
+ case node.type
50
+ when :str
51
+ write(escape(node).children.first)
52
+ else
53
+ visit(s(:interpolated, [node]))
54
+ end
55
+ end
56
+
26
57
  # Return dynamic body
27
58
  #
28
59
  # @return [undefined]
@@ -11,7 +11,7 @@ module Unparser
11
11
  :or_asgn => '||='
12
12
  )
13
13
 
14
- handle *MAP.keys
14
+ handle(*MAP.keys)
15
15
 
16
16
  private
17
17
 
@@ -13,7 +13,7 @@ module Unparser
13
13
  :until_post => K_UNTIL
14
14
  }.freeze
15
15
 
16
- handle *MAP.keys
16
+ handle(*MAP.keys)
17
17
 
18
18
  # Perform dispatch
19
19
  #
@@ -36,7 +36,7 @@ module Unparser
36
36
  :until => K_UNTIL
37
37
  }.freeze
38
38
 
39
- handle *MAP.keys
39
+ handle(*MAP.keys)
40
40
 
41
41
  children :condition, :body
42
42
 
@@ -120,7 +120,10 @@ describe Unparser, 'spike' do
120
120
  assert_source '/foo/'
121
121
  assert_source %q(/[^-+',.\/:@[:alnum:]\[\]\x80-\xff]+/)
122
122
  assert_source '/foo#{@bar}/'
123
- assert_source '/foo#{@bar}/im'
123
+ assert_source '/foo#{@bar}/imx'
124
+ assert_source "/\n/"
125
+ assert_source '/\n/'
126
+ assert_source "/\n/x"
124
127
  assert_generates '%r(/)', '/\//'
125
128
  assert_generates '%r(\))', '/)/'
126
129
  assert_generates '%r(#{@bar}baz)', '/#{@bar}baz/'
data/unparser.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'unparser'
5
- s.version = '0.0.15'
5
+ s.version = '0.0.16'
6
6
 
7
7
  s.authors = ['Markus Schirp']
8
8
  s.email = 'mbj@schir-dso.com'
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.extra_rdoc_files = %w(README.md)
18
18
  s.executables = [ 'test-unparser' ]
19
19
 
20
- s.add_dependency('parser', '~> 2.0.0.pre5')
20
+ s.add_dependency('parser', '~> 2.0.0.pre6')
21
21
  s.add_dependency('concord', '~> 0.1.1')
22
22
  s.add_dependency('adamantium', '~> 0.0.10')
23
23
  s.add_dependency('equalizer', '~> 0.0.5')
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.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-01 00:00:00.000000000 Z
11
+ date: 2013-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.pre5
19
+ version: 2.0.0.pre6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0.pre5
26
+ version: 2.0.0.pre6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: concord
29
29
  requirement: !ruby/object:Gem::Requirement