unparser 0.1.16 → 0.2.0

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: 8311740d232b8385dfa4e602fdb037769593990f
4
- data.tar.gz: c2cbcfa29bc39e0affdaa3eb02acddd60a78ec85
3
+ metadata.gz: 0a41fab2f00404023369e2884e52cbfee6b9c185
4
+ data.tar.gz: b1a7581222eff7a3a688403181fce2a7f79f18f4
5
5
  SHA512:
6
- metadata.gz: 664dd07c08c822714a16c4c2ae9758cd270d3a643bebccfc4cee2c1a536cc5a4aa1eff6e80302dbc4438592b3d443787fc6400a4761eda3ef51f497087f4efb9
7
- data.tar.gz: a9af21984e94034f91b33d8b68b13a5ee045fe6d1e03459e45739c8eaeeedaabf0d3ce41e51957b08d8eec86894388739b97d336df0d428ec5ff8b123cf80901
6
+ metadata.gz: 80c8b0f4341d2d7db23b5d182ec844eecf87f693b6aea4d3763a09bc69b9441b33a884ba031b33be1029dcad43625fed2d658162445b0fc2fff2b1cad2e59df9
7
+ data.tar.gz: fbdcc36729c937e203c302064ea6543db2f704eb95ecd678af19b3b4a58b4a7248a177160315633da59ac8aff74315cc07168661749ce6c7b35964dc1c138521
data/.travis.yml CHANGED
@@ -1,15 +1,13 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  script: 'bundle exec rake ci'
3
4
  rvm:
4
- - 1.9.3
5
5
  - 2.0.0
6
- - 2.1.2
7
- - 2.1.3
6
+ - 2.1.4
7
+ - 2.2.0
8
8
  - rbx-2
9
9
  matrix:
10
10
  include:
11
- - rvm: jruby
12
- env: JRUBY_OPTS="$JRUBY_OPTS --debug --1.9" # for simplecov
13
11
  - rvm: jruby
14
12
  env: JRUBY_OPTS="$JRUBY_OPTS --debug --2.0" # for simplecov
15
13
  allow_failures:
data/Changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.1.17 2015-01-10
2
+
3
+ * Fix jruby complex / rational generation edge case
4
+ * Support generation under MRI 2.2
5
+
1
6
  # v0.1.16 2014-11-07
2
7
 
3
8
  * Add emitter for complex and rational literals
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ gem 'anima', '~> 0.2.0'
8
8
  gem 'morpher', '~> 0.2.2'
9
9
 
10
10
  gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
11
+ gem 'mutant', git: 'https://github.com/mbj/mutant.git'
11
12
  eval_gemfile 'Gemfile.devtools'
data/Gemfile.devtools CHANGED
@@ -1,69 +1,37 @@
1
- # encoding: utf-8
2
-
3
1
  group :development do
4
- gem 'rake', '~> 10.3.2'
5
- gem 'rspec', '~> 3.1.0'
6
- gem 'rspec-its', '~> 1.0.1'
7
- gem 'yard', '~> 0.8.7.4'
8
-
9
2
  platform :rbx do
10
3
  gem 'rubysl-singleton', '~> 2.0.0'
11
4
  end
12
5
  end
13
6
 
14
- group :yard do
15
- gem 'kramdown', '~> 1.3.3'
16
- end
17
-
18
7
  group :guard do
19
- gem 'guard', '~> 2.6.1'
20
- gem 'guard-bundler', '~> 2.0.0'
21
- gem 'guard-rspec', '~> 4.2.9'
22
- gem 'guard-rubocop', '~> 1.1.0'
8
+ gem 'guard', '~> 2.10.3'
9
+ gem 'guard-bundler', '~> 2.1.0'
10
+ gem 'guard-rspec', '~> 4.5.0'
11
+ gem 'guard-rubocop', '~> 1.2.0'
23
12
 
24
13
  # file system change event handling
25
- gem 'listen', '~> 2.7.7'
14
+ gem 'listen', '~> 2.8.4'
26
15
  gem 'rb-fchange', '~> 0.0.6', require: false
27
16
  gem 'rb-fsevent', '~> 0.9.4', require: false
28
17
  gem 'rb-inotify', '~> 0.9.5', require: false
29
18
 
30
19
  # notification handling
31
- gem 'libnotify', '~> 0.8.3', require: false
20
+ gem 'libnotify', '~> 0.9.0', require: false
32
21
  gem 'rb-notifu', '~> 0.0.4', require: false
33
- gem 'terminal-notifier-guard', '~> 1.5.3', require: false
22
+ gem 'terminal-notifier-guard', '~> 1.6.4', require: false
34
23
  end
35
24
 
36
25
  group :metrics do
37
- gem 'coveralls', '~> 0.7.0'
38
- gem 'flay', '~> 2.5.0'
39
- gem 'flog', '~> 4.2.1'
40
- gem 'reek', '~> 1.3.7'
41
- gem 'rubocop', '~> 0.26.1'
42
- gem 'simplecov', '~> 0.7.1'
43
- gem 'yardstick', '~> 0.9.9'
44
-
45
- platforms :mri do
46
- gem 'mutant', '~> 0.6.3'
47
- gem 'mutant-rspec', '~> 0.6.3'
48
- end
49
-
50
- platforms :ruby_19, :ruby_20 do
51
- gem 'yard-spellcheck', '~> 0.1.5'
52
- end
53
-
54
26
  platform :rbx do
55
27
  gem 'json', '~> 1.8.1'
56
- gem 'racc', '~> 1.4.11'
57
- gem 'rubysl-logger', '~> 2.0.0'
28
+ gem 'racc', '~> 1.4.12'
29
+ gem 'rubysl-logger', '~> 2.1.0'
58
30
  gem 'rubysl-open-uri', '~> 2.0.0'
59
31
  gem 'rubysl-prettyprint', '~> 2.0.3'
60
32
  end
61
33
  end
62
34
 
63
- group :benchmarks do
64
- gem 'rbench', '~> 0.2.3'
65
- end
66
-
67
35
  platform :jruby do
68
36
  group :jruby do
69
37
  gem 'jruby-openssl', '~> 0.9.4'
data/README.md CHANGED
@@ -110,8 +110,7 @@ Install the gem `unparser` via your prefered method.
110
110
  People
111
111
  ------
112
112
 
113
- * [Markus Schirp (mbj)](https://github.com/mbj) Author
114
- * [Trent Ogren (misfo)](https://github.com/misfo) Adding comment reproduction
113
+ Various people contributed to this repository. See [Contributors](https://github.com/mbj/unparser/graphs/contributors).
115
114
 
116
115
  Contributing
117
116
  -------------
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 13
3
- total_score: 679
3
+ total_score: 674
data/config/rubocop.yml CHANGED
@@ -15,6 +15,9 @@ MethodLength:
15
15
  CountComments: false
16
16
  Max: 17
17
17
 
18
+ AbcSize:
19
+ Max: 18
20
+
18
21
  # Avoid more than `Max` levels of nesting.
19
22
  BlockNesting:
20
23
  Max: 3
@@ -74,7 +77,13 @@ Blocks:
74
77
  Enabled: false
75
78
 
76
79
  # I like to have an empty line before closing the currently opened body
77
- EmptyLinesAroundBody:
80
+ EmptyLinesAroundBlockBody:
81
+ Enabled: false
82
+
83
+ EmptyLinesAroundClassBody:
84
+ Enabled: false
85
+
86
+ EmptyLinesAroundModuleBody:
78
87
  Enabled: false
79
88
 
80
89
  # I like my style more
@@ -446,7 +446,7 @@ module Unparser
446
446
  #
447
447
  # @api private
448
448
  #
449
- def emit_body(body = body)
449
+ def emit_body(body = body())
450
450
  unless body
451
451
  buffer.indent
452
452
  nl
@@ -494,7 +494,7 @@ module Unparser
494
494
  #
495
495
  # @api private
496
496
  #
497
- def run(emitter, node = node)
497
+ def run(emitter, node = node())
498
498
  emitter.new(node, self).write_to_buffer
499
499
  end
500
500
 
@@ -83,8 +83,8 @@ module Unparser
83
83
  util = self.class
84
84
  string = node.children.first
85
85
  segment = string
86
- .gsub(REPLACEMENTS, ESCAPES)
87
- .gsub(util::DELIMITER, util::REPLACEMENT)
86
+ .gsub(REPLACEMENTS, ESCAPES)
87
+ .gsub(util::DELIMITER, util::REPLACEMENT)
88
88
  write(segment)
89
89
  end
90
90
 
@@ -93,7 +93,7 @@ module Unparser
93
93
  integer = value.to_i
94
94
  float = value.to_f
95
95
 
96
- write_rational(integer.to_f.equal?(float) ? integer : float)
96
+ write_rational(integer.to_f.eql?(float) ? integer : float)
97
97
  end
98
98
 
99
99
  # Write rational format
@@ -105,7 +105,7 @@ module Unparser
105
105
  #
106
106
  def emit_normal_operation
107
107
  parentheses(*INDEX_PARENS) do
108
- delimited(indices)
108
+ delimited_plain(indices)
109
109
  end
110
110
  write(WS, T_ASN, WS)
111
111
  visit(value)
@@ -184,7 +184,7 @@ module Unparser
184
184
  register :float
185
185
  register :int
186
186
 
187
- NEG_INFINITY = Float::INFINITY - 1
187
+ NEG_INFINITY = -(Float::INFINITY - 1)
188
188
 
189
189
  # Return preprocessor result
190
190
  #
@@ -197,7 +197,7 @@ module Unparser
197
197
  case value
198
198
  when Float::INFINITY
199
199
  s(:const, s(:const, nil, :Float), :INFINITY)
200
- when -NEG_INFINITY
200
+ when NEG_INFINITY
201
201
  s(:send, s(:const, s(:const, nil, :Float), :INFINITY), :-@)
202
202
  else
203
203
  node
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,10 @@ require 'morpher'
8
8
  require 'devtools/spec_helper'
9
9
 
10
10
  require 'parser/current'
11
+ require 'parser/ruby19'
12
+ require 'parser/ruby20'
11
13
  require 'parser/ruby21'
14
+ require 'parser/ruby22'
12
15
 
13
16
  module SpecHelper
14
17
  def s(type, *children)
@@ -26,4 +29,5 @@ end
26
29
  RSpec.configure do |config|
27
30
  config.include(SpecHelper)
28
31
  config.extend(SpecHelper)
32
+ config.raise_errors_for_deprecations!
29
33
  end
@@ -8,7 +8,8 @@ describe Unparser do
8
8
  PARSERS = IceNine.deep_freeze(
9
9
  '1.9' => Parser::Ruby19,
10
10
  '2.0' => Parser::Ruby20,
11
- '2.1' => Parser::Ruby21
11
+ '2.1' => Parser::Ruby21,
12
+ '2.2' => Parser::Ruby22
12
13
  )
13
14
 
14
15
  RUBIES = PARSERS.keys.freeze
@@ -28,7 +29,7 @@ describe Unparser do
28
29
  def assert_round_trip(input, parser)
29
30
  ast, comments = parser.parse_with_comments(input)
30
31
  generated = Unparser.unparse(ast, comments)
31
- generated.should eql(input)
32
+ expect(generated).to eql(input)
32
33
  generated_ast, _ = parser.parse_with_comments(generated)
33
34
  expect(ast == generated_ast).to be(true)
34
35
  end
@@ -41,9 +42,9 @@ describe Unparser do
41
42
 
42
43
  def assert_generates_from_ast(parser, ast_with_comments, expected)
43
44
  generated = Unparser.unparse(*ast_with_comments)
44
- generated.should eql(expected)
45
+ expect(generated).to eql(expected)
45
46
  ast, comments = parser.parse_with_comments(generated)
46
- Unparser.unparse(ast, comments).should eql(expected)
47
+ expect(Unparser.unparse(ast, comments)).to eql(expected)
47
48
  end
48
49
 
49
50
  def self.assert_unterminated(expression)
@@ -111,25 +112,29 @@ describe Unparser do
111
112
  assert_generates '-10e10000000000', '-Float::INFINITY'
112
113
  end
113
114
 
114
- context 'rational' do
115
- assert_terminated '1r', %w(2.1)
116
- assert_generates '1.0r', '1r', %w(2.1)
117
- assert_generates '-0r', '0r', %w(2.1)
115
+ # Rubies < 2.0 do not have these literals, parser can parse them
116
+ # but there are subtible differencies. Excluding them under those rubies.
117
+ if RUBY_VERSION >= '2.0'
118
+ context 'rational' do
119
+ assert_terminated '1r', %w(2.1)
120
+ assert_generates '1.0r', '1r', %w(2.1)
121
+ assert_generates '-0r', '0r', %w(2.1)
118
122
 
119
- assert_terminated '1.5r', %w(2.1)
120
- assert_terminated '1.3r', %w(2.1)
121
- end
123
+ assert_terminated '1.5r', %w(2.1)
124
+ assert_terminated '1.3r', %w(2.1)
125
+ end
122
126
 
123
- context 'rational' do
124
- %w(
125
- 5i
126
- -5i
127
- 0.6i
128
- -0.6i
129
- 1000000000000000000000000000000i
130
- 1ri
131
- ).each do |expression|
132
- assert_terminated(expression, %w(2.1))
127
+ context 'complex' do
128
+ %w(
129
+ 5i
130
+ -5i
131
+ 0.6i
132
+ -0.6i
133
+ 1000000000000000000000000000000i
134
+ 1ri
135
+ ).each do |expression|
136
+ assert_terminated(expression, %w(2.1))
137
+ end
133
138
  end
134
139
  end
135
140
 
@@ -1308,6 +1313,7 @@ describe Unparser do
1308
1313
  assert_source 'foo[index] = value'
1309
1314
  assert_source 'foo[*index] = value'
1310
1315
  assert_source 'foo[a, b] = value'
1316
+ assert_source 'foo[1..2] = value'
1311
1317
  assert_source 'foo.[]=()'
1312
1318
  assert_source 'foo[] = 1'
1313
1319
 
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.16'
5
+ gem.version = '0.2.0'
6
6
 
7
7
  gem.authors = ['Markus Schirp']
8
8
  gem.email = 'mbj@schir-dso.com'
@@ -17,12 +17,13 @@ Gem::Specification.new do |gem|
17
17
  gem.extra_rdoc_files = %w(README.md)
18
18
  gem.executables = [ 'unparser' ]
19
19
 
20
- gem.required_ruby_version = '>= 1.9.3'
20
+ gem.required_ruby_version = '>= 2.0.0'
21
21
 
22
- gem.add_dependency('parser', '~> 2.2.0.pre.7')
22
+ gem.add_dependency('parser', '~> 2.2.0.2')
23
23
  gem.add_dependency('procto', '~> 0.0.2')
24
24
  gem.add_dependency('concord', '~> 0.1.5')
25
25
  gem.add_dependency('adamantium', '~> 0.2.0')
26
26
  gem.add_dependency('equalizer', '~> 0.0.9')
27
27
  gem.add_dependency('abstract_type', '~> 0.0.7')
28
+ gem.add_dependency('diff-lcs', '~> 1.2.5')
28
29
  end
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.16
4
+ version: 0.2.0
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-11-07 00:00:00.000000000 Z
11
+ date: 2015-01-12 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.2.0.pre.7
19
+ version: 2.2.0.2
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.2.0.pre.7
26
+ version: 2.2.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: procto
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.0.7
97
+ - !ruby/object:Gem::Dependency
98
+ name: diff-lcs
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.5
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.5
97
111
  description: Generate equivalent source for parser gem AST nodes
98
112
  email: mbj@schir-dso.com
99
113
  executables:
@@ -187,7 +201,6 @@ files:
187
201
  - lib/unparser/finalize.rb
188
202
  - lib/unparser/node_helpers.rb
189
203
  - lib/unparser/preprocessor.rb
190
- - rubyspec.sh
191
204
  - spec/integration/unparser/corpus_spec.rb
192
205
  - spec/integrations.yml
193
206
  - spec/spec_helper.rb
@@ -218,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
231
  requirements:
219
232
  - - ">="
220
233
  - !ruby/object:Gem::Version
221
- version: 1.9.3
234
+ version: 2.0.0
222
235
  required_rubygems_version: !ruby/object:Gem::Requirement
223
236
  requirements:
224
237
  - - ">="
data/rubyspec.sh DELETED
@@ -1,20 +0,0 @@
1
- #!/bin/sh
2
- exec bundle exec bin/unparser ../rubyspec --fail-fast \
3
- --ignore '../rubyspec/core/array/pack/{b,h,u}_spec.rb' \
4
- --ignore '../rubyspec/language/versions/*1.8*' \
5
- --ignore '../rubyspec/core/array/pack/shared/float.rb' \
6
- --ignore '../rubyspec/core/array/pack/shared/integer.rb' \
7
- --ignore '../rubyspec/core/array/pack/{c,m,w}_spec.rb' \
8
- --ignore '../rubyspec/core/regexp/shared/new.rb' \
9
- --ignore '../rubyspec/core/regexp/shared/quote.rb' \
10
- --ignore '../rubyspec/core/encoding/compatible_spec.rb' \
11
- --ignore '../rubyspec/core/io/readpartial_spec.rb' \
12
- --ignore '../rubyspec/core/env/element_reference_spec.rb' \
13
- --ignore '../rubyspec/core/dir/pwd_spec.rb' \
14
- --ignore '../rubyspec/core/string/casecmp_spec.rb' \
15
- --ignore '../rubyspec/core/string/unpack/{b,c,h,m,u,w}_spec.rb' \
16
- --ignore '../rubyspec/core/string/unpack/b_spec.rb' \
17
- --ignore '../rubyspec/core/string/unpack/shared/float.rb' \
18
- --ignore '../rubyspec/core/string/unpack/shared/integer.rb' \
19
- --ignore '../rubyspec/core/symbol/casecmp_spec.rb' \
20
- $*