tomlrb 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -2
- data/bin/console +1 -2
- data/lib/tomlrb.rb +1 -1
- data/lib/tomlrb/generated_parser.rb +2 -2
- data/lib/tomlrb/handler.rb +2 -1
- data/lib/tomlrb/parser.y +2 -2
- data/lib/tomlrb/string_utils.rb +17 -7
- data/lib/tomlrb/version.rb +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: 68ff6a39fb4b176a95742a9e4ac1479b043f1a3a
|
4
|
+
data.tar.gz: f194abd1850832fd2db66c1e27e037a9c8c76e41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45d1317b8f190b1ad5f8d4446e3433c9c2caa36b6dfddf7798a89a7d9c7d14f6a28a257bb46cf695b23f13b762d4cfcd0e3ad8141e209a1f111a8784a13af8f6
|
7
|
+
data.tar.gz: a0b2e86ae8b3a260820895a655bdb94aa280a1de2322f4307c84bb7056e1a53af5edcd6ee42f829bb78ec91f9bc395857e4e2e2b87523c9c5c94cccdc814f5e3
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/bin/console
CHANGED
data/lib/tomlrb.rb
CHANGED
@@ -522,14 +522,14 @@ module_eval(<<'.,.,', 'parser.y', 100)
|
|
522
522
|
|
523
523
|
module_eval(<<'.,.,', 'parser.y', 101)
|
524
524
|
def _reduce_54(val, _values, result)
|
525
|
-
result = StringUtils.
|
525
|
+
result = StringUtils.strip_spaces(val[0])
|
526
526
|
result
|
527
527
|
end
|
528
528
|
.,.,
|
529
529
|
|
530
530
|
module_eval(<<'.,.,', 'parser.y', 102)
|
531
531
|
def _reduce_55(val, _values, result)
|
532
|
-
result =
|
532
|
+
result = val[0]
|
533
533
|
result
|
534
534
|
end
|
535
535
|
.,.,
|
data/lib/tomlrb/handler.rb
CHANGED
@@ -35,7 +35,7 @@ module Tomlrb
|
|
35
35
|
@array_names << stringified_identifier
|
36
36
|
last_identifier = identifiers.pop
|
37
37
|
elsif @array_names.include?(stringified_identifier)
|
38
|
-
raise ParseError
|
38
|
+
raise ParseError, 'Cannot define a normal table with the same name as an already established array'
|
39
39
|
end
|
40
40
|
|
41
41
|
yield(identifiers)
|
@@ -64,6 +64,7 @@ module Tomlrb
|
|
64
64
|
def end_(type)
|
65
65
|
array = []
|
66
66
|
while (value = @stack.pop) != [type]
|
67
|
+
raise ParseError, 'Unclosed table' unless value
|
67
68
|
array.unshift(value)
|
68
69
|
end
|
69
70
|
array
|
data/lib/tomlrb/parser.y
CHANGED
@@ -99,6 +99,6 @@ rule
|
|
99
99
|
string
|
100
100
|
: STRING_MULTI { result = StringUtils.replace_escaped_chars(StringUtils.multiline_replacements(val[0])) }
|
101
101
|
| STRING_BASIC { result = StringUtils.replace_escaped_chars(val[0]) }
|
102
|
-
| STRING_LITERAL_MULTI { result = StringUtils.
|
103
|
-
| STRING_LITERAL { result =
|
102
|
+
| STRING_LITERAL_MULTI { result = StringUtils.strip_spaces(val[0]) }
|
103
|
+
| STRING_LITERAL { result = val[0] }
|
104
104
|
;
|
data/lib/tomlrb/string_utils.rb
CHANGED
@@ -1,18 +1,28 @@
|
|
1
1
|
module Tomlrb
|
2
2
|
class StringUtils
|
3
3
|
|
4
|
+
SPECIAL_CHARS = {
|
5
|
+
'\\t' => "\t",
|
6
|
+
'\\b' => "\b",
|
7
|
+
'\\f' => "\f",
|
8
|
+
'\\n' => "\n",
|
9
|
+
'\\r' => "\r",
|
10
|
+
'\\"' => '"',
|
11
|
+
'\\\\' => '\\'
|
12
|
+
}.freeze
|
13
|
+
|
4
14
|
def self.multiline_replacements(str)
|
5
15
|
strip_spaces(str).gsub(/\\\n\s+/, '')
|
6
16
|
end
|
7
17
|
|
8
18
|
def self.replace_escaped_chars(str)
|
9
|
-
str
|
10
|
-
.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
19
|
+
str.gsub(/\\(u[\da-fA-F]{4}|U[\da-fA-F]{8}|.)/) do |m|
|
20
|
+
if m.size == 2
|
21
|
+
SPECIAL_CHARS[m] || (raise Tomlrb::ParseError.new "Escape sequence #{m} is reserved")
|
22
|
+
else
|
23
|
+
m[2..-1].to_i(16).chr(Encoding::UTF_8)
|
24
|
+
end
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
def self.strip_spaces(str)
|
data/lib/tomlrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomlrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francois Bernier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A racc based toml parser
|
14
14
|
email:
|