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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/parser/lexer.rl +1 -1
- data/lib/parser/source/buffer.rb +3 -3
- data/lib/parser/version.rb +1 -1
- data/test/test_encoding.rb +15 -6
- data/test/test_lexer.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef56ab825b77544fdfbc486ccb592cede5bd7da3
|
4
|
+
data.tar.gz: 30dcf6e9bd3566babf73ba48b026cd7521f32f07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/parser/source/buffer.rb
CHANGED
@@ -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::
|
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*([
|
28
|
+
if encoding_line =~ /^#.*coding\s*[:=]\s*([A-Za-z0-9_-]+)/
|
29
29
|
Encoding.find($1)
|
30
30
|
else
|
31
|
-
|
31
|
+
Encoding::UTF_8
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
data/lib/parser/version.rb
CHANGED
data/test/test_encoding.rb
CHANGED
@@ -9,11 +9,12 @@ class TestEncoding < Minitest::Test
|
|
9
9
|
|
10
10
|
if defined?(Encoding)
|
11
11
|
def test_default
|
12
|
-
assert_equal Encoding::
|
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\
|
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::
|
37
|
+
assert_equal Encoding::UTF_8, recognize("")
|
29
38
|
end
|
30
39
|
|
31
40
|
def test_no_comment
|
32
|
-
assert_equal Encoding::
|
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::
|
37
|
-
assert_equal Encoding::
|
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, "
|
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.
|
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-
|
11
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|