parser 2.5.0.2 → 2.5.0.3

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: 1497971563a08dc36f4f331db195ebbe9d157082
4
- data.tar.gz: 6af1b9d7f17195f6306c6de045c547ebc4dc77e4
3
+ metadata.gz: 2b09926b92e95874cfa6295ffa913a0d282c063d
4
+ data.tar.gz: 10036043ab11e9fd97f36ddf29615f8f25247b78
5
5
  SHA512:
6
- metadata.gz: 0c87434346083e12a82d091d0e274ff0ef3766aac84704fad1d1b5f734bf1a884187c46570c474136bc04d0fb24122cdfc76eb5d32f0e4c79d1d31f986c8d110
7
- data.tar.gz: bae16691e9e99837d7fc31551b31b4f2e98e0729ebf92a401a595b3b942e65de4b6819341e93e89c27cf9fa56951edd02b5201b63b77e9ec023e67e3b1f57768
6
+ metadata.gz: 78ade228a7b0d40884bd06a6b2241d1282693f15d359bf73e0ae4f56e08b90da90586ecca947666fdf00b5d2a6a9ec7851627cd870a00cab49eafe6368c245fa
7
+ data.tar.gz: f4109e28f013c637ad30b616115037264756b05eadfde190987564831b1f3ef9071cfafc764b731098639524f28c06d80738437a8c60f4d0062de3cf52daf1ec
@@ -1,6 +1,13 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ Not released (2018-03-06)
5
+ -------------------------
6
+
7
+ Bugs fixed:
8
+ * Accept `BEGIN` and `END` as correct method name (#463) (Masataka Pocke Kuwabara)
9
+ * Parser::Source::Buffer: Fixed parsing of encoding comment when the file contains only shebang. (Ilya Bylich)
10
+
4
11
  v2.5.0.2 (2018-02-22)
5
12
  ---------------------
6
13
 
@@ -48,7 +48,7 @@ module Parser
48
48
  CurrentRuby = Ruby23
49
49
 
50
50
  when /^2\.4\./
51
- current_version = '2.4.0'
51
+ current_version = '2.4.3'
52
52
  if RUBY_VERSION != current_version
53
53
  warn_syntax_deviation 'parser/ruby24', current_version
54
54
  end
@@ -467,6 +467,7 @@ class Parser::Lexer
467
467
  'if' => :kIF, 'unless' => :kUNLESS,
468
468
  'while' => :kWHILE, 'until' => :kUNTIL,
469
469
  'rescue' => :kRESCUE, 'defined?' => :kDEFINED,
470
+ 'BEGIN' => :klBEGIN, 'END' => :klEND,
470
471
  }
471
472
 
472
473
  %w(class module def undef begin end then elsif else ensure case when
@@ -2219,7 +2220,13 @@ class Parser::Lexer
2219
2220
  e_rbrace | e_rparen | ']'
2220
2221
  => {
2221
2222
  emit_table(PUNCTUATION)
2222
- @cond.lexpop; @cmdarg.pop
2223
+
2224
+ @cond.lexpop
2225
+ if @version < 24
2226
+ @cmdarg.lexpop
2227
+ else
2228
+ @cmdarg.pop
2229
+ end
2223
2230
 
2224
2231
  if tok == '}'.freeze
2225
2232
  fnext expr_endarg;
@@ -230,7 +230,7 @@ module Parser
230
230
  end
231
231
 
232
232
  def coerce_encoding(string)
233
- string.dup.force_encoding(Encoding::BINARY)
233
+ string.b
234
234
  end
235
235
 
236
236
  def clear_buffer
@@ -63,7 +63,7 @@ module Parser
63
63
  encoding_line = first_line
64
64
  end
65
65
 
66
- return nil if encoding_line[0] != '#'
66
+ return nil if encoding_line.nil? || encoding_line[0] != '#'
67
67
 
68
68
  if (result = ENCODING_RE.match(encoding_line))
69
69
  Encoding.find(result[3] || result[4] || result[6])
@@ -103,7 +103,7 @@ module Parser
103
103
  end
104
104
 
105
105
  def initialize(name, first_line = 1)
106
- @name = name
106
+ @name = name.to_s
107
107
  @source = nil
108
108
  @first_line = first_line
109
109
 
@@ -17,7 +17,7 @@ module Parser
17
17
  # - The TreeRewriter policy closest to Rewriter's behavior is:
18
18
  # different_replacements: :raise,
19
19
  # swallowed_insertions: :raise,
20
- # overlapping_deletions: :accept
20
+ # crossing_deletions: :accept
21
21
  #
22
22
  # @!attribute [r] source_buffer
23
23
  # @return [Source::Buffer]
@@ -273,7 +273,7 @@ module Parser
273
273
 
274
274
  def check_range_validity(range)
275
275
  if range.begin_pos < 0 || range.end_pos > @source_buffer.source.size
276
- raise IndexError, "The range #{action.range} is outside the bounds of the source"
276
+ raise IndexError, "The range #{range} is outside the bounds of the source"
277
277
  end
278
278
  range
279
279
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parser
4
- VERSION = '2.5.0.2'
4
+ VERSION = '2.5.0.3'
5
5
  end
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_dependency 'ast', '~> 2.4.0'
37
37
 
38
- spec.add_development_dependency 'bundler', '~> 1.16'
38
+ spec.add_development_dependency 'bundler', '~> 1.15'
39
39
  spec.add_development_dependency 'rake', '~> 10.0'
40
40
  spec.add_development_dependency 'racc', '= 1.4.14'
41
41
  spec.add_development_dependency 'cliver', '~> 0.3.2'
@@ -27,6 +27,7 @@ class TestEncoding < Minitest::Test
27
27
 
28
28
  def test_shebang
29
29
  assert_equal Encoding::KOI8_R, recognize("#!/bin/foo\n# coding:koi8-r\nfoobar")
30
+ assert_nil recognize("#!/bin/foo\n")
30
31
  end
31
32
 
32
33
  def test_case
@@ -1804,6 +1804,14 @@ class TestParser < Minitest::Test
1804
1804
  assert_parses(
1805
1805
  s(:def, :until, s(:args), nil),
1806
1806
  %q{def until; end})
1807
+
1808
+ assert_parses(
1809
+ s(:def, :BEGIN, s(:args), nil),
1810
+ %q{def BEGIN; end})
1811
+
1812
+ assert_parses(
1813
+ s(:def, :END, s(:args), nil),
1814
+ %q{def END; end})
1807
1815
  end
1808
1816
 
1809
1817
  def test_defs
@@ -5272,7 +5280,7 @@ class TestParser < Minitest::Test
5272
5280
  def test_bom
5273
5281
  assert_parses(
5274
5282
  s(:int, 1),
5275
- %Q{\xef\xbb\xbf1}.dup.force_encoding(Encoding::BINARY),
5283
+ %Q{\xef\xbb\xbf1}.b,
5276
5284
  %q{},
5277
5285
  %w(1.9 2.0 2.1))
5278
5286
  end
@@ -5284,8 +5292,7 @@ class TestParser < Minitest::Test
5284
5292
  s(:send, nil, :puts, s(:lvar, :"проверка"))),
5285
5293
  %Q{# coding:koi8-r
5286
5294
  \xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 = 42
5287
- puts \xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1}.dup.
5288
- force_encoding(Encoding::BINARY),
5295
+ puts \xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1}.b,
5289
5296
  %q{},
5290
5297
  %w(1.9 2.0 2.1))
5291
5298
  end
@@ -6767,6 +6774,16 @@ class TestParser < Minitest::Test
6767
6774
  %q{m [] do end},
6768
6775
  %q{},
6769
6776
  ALL_VERSIONS)
6777
+
6778
+ assert_parses(
6779
+ s(:block,
6780
+ s(:send, nil, :m,
6781
+ s(:array),
6782
+ s(:int, 1)),
6783
+ s(:args), nil),
6784
+ %q{m [], 1 do end},
6785
+ %q{},
6786
+ ALL_VERSIONS)
6770
6787
  end
6771
6788
 
6772
6789
  def test_bug_435
@@ -8,6 +8,12 @@ class TestSourceBuffer < Minitest::Test
8
8
  end
9
9
 
10
10
  def test_initialize
11
+ buffer = Parser::Source::Buffer.new(nil)
12
+ assert_equal '', buffer.name
13
+
14
+ buffer = Parser::Source::Buffer.new(Pathname('a/b'))
15
+ assert_equal 'a/b', buffer.name
16
+
11
17
  buffer = Parser::Source::Buffer.new('(string)')
12
18
  assert_equal '(string)', buffer.name
13
19
  assert_equal 1, buffer.first_line
@@ -421,7 +421,7 @@ class TestSourceRewriter < Minitest::Test
421
421
  end
422
422
 
423
423
 
424
- def test_overlapping_delete
424
+ def test_crossing_delete
425
425
  assert_equal 'faz',
426
426
  @rewriter.
427
427
  remove(range(1, 4)).
@@ -126,15 +126,6 @@ DIAGNOSTIC
126
126
  DIAGNOSTIC
127
127
  end
128
128
 
129
- def test_multiple_actions
130
- assert_actions_result 'puts({:hello => [:everybody]})',
131
- [:replace, @comma_space, ' => '],
132
- [:wrap, @hello.join(@world), '{', '}'],
133
- [:replace, @world, ':everybody'],
134
- [:wrap, @world, '[', ']']
135
- end
136
-
137
-
138
129
  def test_multiple_actions
139
130
  assert_actions_result 'puts({:hello => [:everybody]})',
140
131
  [:replace, @comma_space, ' => '],
@@ -174,4 +165,9 @@ DIAGNOSTIC
174
165
  (rewriter):1: ^~~~~ ~~~~
175
166
  DIAGNOSTIC
176
167
  end
168
+
169
+ def test_out_of_range_ranges
170
+ rewriter = Parser::Source::TreeRewriter.new(@buf)
171
+ assert_raises(IndexError) { rewriter.insert_before(range(0, 100), 'hola') }
172
+ end
177
173
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0.2
4
+ version: 2.5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - whitequark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-22 00:00:00.000000000 Z
11
+ date: 2018-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.16'
33
+ version: '1.15'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.16'
40
+ version: '1.15'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement