parser 2.0.0.beta4 → 2.0.0.beta5

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: b376a16dbd765d49118c18432b8134011d732f09
4
- data.tar.gz: 12cad6ee3c5f47b267b4b93d442e3e5ae80be478
3
+ metadata.gz: ef56ab825b77544fdfbc486ccb592cede5bd7da3
4
+ data.tar.gz: 30dcf6e9bd3566babf73ba48b026cd7521f32f07
5
5
  SHA512:
6
- metadata.gz: 5be76612d68a0692c0c3d2691bb83816b35aeda66d496cfebbb04c65a5dd0cacf8be7c6d739fbc0cbefff05f5f20b270fd3bd426c602f1ad32bcbf216102e6be
7
- data.tar.gz: b1fa6025f4b3311870f5403a7fab57cd9da3e851f89ebff271a5853e783e7c4790a153440c753f681054edf0f94ca2821e5f793427cbc2ed7ed1bef0d4a2dbc9
6
+ metadata.gz: 4274e893bce829d8736cb57659eae865c76b520903c3175d2b24475e90a2219596572972c179591677d37801b978fd855189df7e4405a30020e6cfa1d74e6193
7
+ data.tar.gz: c79fdcbe3ab0b0927773111ee0b5699bf337eb53fd4aad3911bcd1ca2801cd6f8d7d2cbdcc846031dd115bd24c910b383a92ca21c5395d85f8354f6d4c8109a6
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v2.0.0.beta5 (2013-06-08)
5
+ -------------------------
6
+
7
+ Bugs fixed:
8
+ * Source::Buffer: better magic encoding comment recognition (fixes #65). (Peter Zotov)
9
+ * lexer.rl: "{success?: true}" (fixes #66). (Peter Zotov)
10
+ * Source::Buffer: if in doubt, treat data as UTF-8 (closes #60). (Peter Zotov)
11
+
4
12
  v2.0.0.beta4 (2013-06-05)
5
13
  -------------------------
6
14
 
data/lib/parser/lexer.rl CHANGED
@@ -1488,7 +1488,7 @@ class Parser::Lexer
1488
1488
  # RUBY 1.9 HASH LABELS
1489
1489
  #
1490
1490
 
1491
- bareword ':' ( c_any - ':' )
1491
+ bareword [?!]? ':' ( c_any - ':' )
1492
1492
  => {
1493
1493
  fhold;
1494
1494
 
@@ -7,7 +7,7 @@ module Parser
7
7
  attr_reader :name, :first_line
8
8
 
9
9
  def self.recognize_encoding(string)
10
- return Encoding::BINARY if string.empty?
10
+ return Encoding::UTF_8 if string.empty?
11
11
 
12
12
  # extract the first two lines in an efficient way
13
13
  string =~ /(.*)\n?(.*\n)?/
@@ -25,10 +25,10 @@ module Parser
25
25
  encoding_line = first_line
26
26
  end
27
27
 
28
- if encoding_line =~ /^#.*coding[:=]\s*([a-z0-9_-]+)/
28
+ if encoding_line =~ /^#.*coding\s*[:=]\s*([A-Za-z0-9_-]+)/
29
29
  Encoding.find($1)
30
30
  else
31
- string.encoding
31
+ Encoding::UTF_8
32
32
  end
33
33
  end
34
34
 
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '2.0.0.beta4'
2
+ VERSION = '2.0.0.beta5'
3
3
  end
@@ -9,11 +9,12 @@ class TestEncoding < Minitest::Test
9
9
 
10
10
  if defined?(Encoding)
11
11
  def test_default
12
- assert_equal Encoding::BINARY, recognize("foobar")
12
+ assert_equal Encoding::UTF_8, recognize("foobar")
13
13
  end
14
14
 
15
15
  def test_bom
16
- assert_equal Encoding::UTF_8, recognize("\xef\xbb\xbffoobar")
16
+ assert_equal Encoding::UTF_8, recognize("\xef\xbb\xbf\nfoobar")
17
+ assert_equal Encoding::UTF_8, recognize("\xef\xbb\xbf# coding:koi8-r\nfoobar")
17
18
  end
18
19
 
19
20
  def test_magic_comment
@@ -24,17 +25,25 @@ class TestEncoding < Minitest::Test
24
25
  assert_equal Encoding::KOI8_R, recognize("#!/bin/foo\n# coding:koi8-r\nfoobar")
25
26
  end
26
27
 
28
+ def test_case
29
+ assert_equal Encoding::KOI8_R, recognize("#!/bin/foo\n# coding:KoI8-r\nfoobar")
30
+ end
31
+
32
+ def test_space
33
+ assert_equal Encoding::KOI8_R, recognize("#!/bin/foo\n# coding : koi8-r\nfoobar")
34
+ end
35
+
27
36
  def test_empty
28
- assert_equal Encoding::BINARY, recognize("")
37
+ assert_equal Encoding::UTF_8, recognize("")
29
38
  end
30
39
 
31
40
  def test_no_comment
32
- assert_equal Encoding::BINARY, recognize(%{require 'cane/encoding_aware_iterator'})
41
+ assert_equal Encoding::UTF_8, recognize(%{require 'cane/encoding_aware_iterator'})
33
42
  end
34
43
 
35
44
  def test_adjacent
36
- assert_equal Encoding::BINARY, recognize("# codingkoi8-r")
37
- assert_equal Encoding::BINARY, recognize("# coding koi8-r")
45
+ assert_equal Encoding::UTF_8, recognize("# codingkoi8-r")
46
+ assert_equal Encoding::UTF_8, recognize("# coding koi8-r")
38
47
  end
39
48
  end
40
49
  end
data/test/test_lexer.rb CHANGED
@@ -239,6 +239,15 @@ class TestLexer < Minitest::Test
239
239
  :tIDENTIFIER, "b")
240
240
  end
241
241
 
242
+ def test_label_fid__19
243
+ setup_lexer 19
244
+
245
+ util_lex_token("{a?:true",
246
+ :tLBRACE, '{',
247
+ :tLABEL, 'a?',
248
+ :kTRUE, 'true')
249
+ end
250
+
242
251
  def test_command_start__19
243
252
  setup_lexer 19
244
253
 
@@ -2513,7 +2522,7 @@ class TestLexer < Minitest::Test
2513
2522
  util_lex_token("<<FIN\r\nfoo\r\nFIN\r\n",
2514
2523
  :tSTRING_BEG, "\"",
2515
2524
  :tSTRING_CONTENT, "foo\r\n",
2516
- :tSTRING_END, "EOS",
2525
+ :tSTRING_END, "FIN",
2517
2526
  :tNL, nil)
2518
2527
  end
2519
2528
 
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.0.0.beta4
4
+ version: 2.0.0.beta5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-05 00:00:00.000000000 Z
11
+ date: 2013-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast