toml-rb 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/toml/errors.rb +1 -1
- data/lib/toml/string.rb +22 -16
- data/test/grammar_test.rb +2 -2
- data/toml-rb.gemspec +1 -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: c08aa29a171d7d63f32f49b003ba684889066e10
|
4
|
+
data.tar.gz: 6e691196c2fbf7f76d84bd9e3d9c4f404dc4b44b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afc71aad3baf66c57e2e5edb067a3bf03855a35abb9f983e6b1300d3d7ca1ebfdcdb7fce5a82fc04067300ee84f1b7b9563832bc98ff9d97a9156ce5a6bd921a
|
7
|
+
data.tar.gz: 7e779c92833849403f5b805883126611212d43582a9e852395254eb99d78831d1d5cae33d4485eb1faf8f62ea0306fe85bb77000f176833835cfabdfdff96130
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ toml-rb
|
|
6
6
|
[](https://codeclimate.com/github/emancu/toml-rb)
|
7
7
|
[](https://gemnasium.com/emancu/toml-rb)
|
8
8
|
|
9
|
-
A [TOML](https://github.com/
|
9
|
+
A [TOML](https://github.com/toml-lang/toml) parser using [Citrus](http://mjackson.github.io/citrus) library.
|
10
10
|
|
11
11
|
TOML specs supported: `0.4.0`
|
12
12
|
|
data/lib/toml/errors.rb
CHANGED
data/lib/toml/string.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
module TOML
|
2
2
|
# Used in primitive.citrus
|
3
3
|
module BasicString
|
4
|
+
SPECIAL_CHARS = {
|
5
|
+
'\\0' => "\0",
|
6
|
+
'\\t' => "\t",
|
7
|
+
'\\b' => "\b",
|
8
|
+
'\\f' => "\f",
|
9
|
+
'\\n' => "\n",
|
10
|
+
'\\r' => "\r",
|
11
|
+
'\\"' => '"',
|
12
|
+
'\\\\' => '\\'
|
13
|
+
}.freeze
|
14
|
+
|
4
15
|
def value
|
5
16
|
aux = TOML::BasicString.transform_escaped_chars first.value
|
6
17
|
|
@@ -10,26 +21,21 @@ module TOML
|
|
10
21
|
# Replace the unicode escaped characters with the corresponding character
|
11
22
|
# e.g. \u03B4 => ?
|
12
23
|
def self.decode_unicode(str)
|
13
|
-
str
|
14
|
-
m[0...-6] + [m[-4..-1].to_i(16)].pack('U')
|
15
|
-
end
|
24
|
+
[str[2..-1].to_i(16)].pack('U')
|
16
25
|
end
|
17
26
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
.gsub(/\\r/, "\r")
|
27
|
+
def self.transform_escaped_chars(str)
|
28
|
+
str.gsub(/\\(u[\da-fA-F]{4}|U[\da-fA-F]{8}|.)/) do |m|
|
29
|
+
if m.size == 2
|
30
|
+
SPECIAL_CHARS[m] || parse_error(m)
|
31
|
+
else
|
32
|
+
decode_unicode(m).force_encoding('UTF-8')
|
33
|
+
end
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
29
|
-
def self.
|
30
|
-
|
31
|
-
str = decode_unicode(str)
|
32
|
-
str.gsub(/\\\\/, '\\').encode('utf-8')
|
37
|
+
def self.parse_error(m)
|
38
|
+
fail ParseError.new "Escape sequence #{m} is reserved"
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
data/test/grammar_test.rb
CHANGED
@@ -79,8 +79,8 @@ class GrammarTest < Minitest::Test
|
|
79
79
|
match = TOML::Document.parse('"\0 \" \t \n \r"', root: :string)
|
80
80
|
assert_equal("\0 \" \t \n \r", match.value)
|
81
81
|
|
82
|
-
match = TOML::Document.parse('"C
|
83
|
-
assert_equal('C:\\Documents\\
|
82
|
+
match = TOML::Document.parse('"C:\\\\Documents\\\\nada.exe"', root: :string)
|
83
|
+
assert_equal('C:\\Documents\\nada.exe', match.value)
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_bool
|
data/toml-rb.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toml-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emiliano Mancuso
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: citrus
|