toml-rb 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toml/grammars/document.citrus +6 -4
- data/lib/toml/grammars/primitive.citrus +9 -3
- data/lib/toml/keygroup.rb +1 -1
- data/lib/toml/keyvalue.rb +1 -1
- data/lib/toml/table_array.rb +1 -1
- data/test/grammar_test.rb +16 -1
- 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: 49771b4d2a6fdf577cafa264b5da35661c74610f
|
4
|
+
data.tar.gz: c4d4032d52979ef02600913a61719ec28164c435
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75df0a53ca6c3c98a9b8e9a53a4201538fb6e2d3afe9f19f8edf7f1016fa95ddf8b6ceb93d6e6961a53b86a2465b3c0b186fc60d3a505ca3d64e1d3f64957f0f
|
7
|
+
data.tar.gz: 8bf0535e21dce48b87e5ffa774be8155c8427278db6f2a8bcaaf790b6f2591f4e680c2d5ed61e2b9a63cbf3cbfae88fbd9dd34f957644ebf1b9ffdf7a9f287f5
|
@@ -7,15 +7,15 @@ grammar TOML::Document
|
|
7
7
|
end
|
8
8
|
|
9
9
|
rule table_array
|
10
|
-
(space? '[[' (
|
10
|
+
(space? '[[' stripped_key ("." stripped_key)* ']]' comment?) <TOML::TableArrayParser>
|
11
11
|
end
|
12
12
|
|
13
13
|
rule keygroup
|
14
|
-
(space? '[' (
|
14
|
+
(space? '[' stripped_key ("." stripped_key)* ']' comment?) <TOML::KeygroupParser>
|
15
15
|
end
|
16
16
|
|
17
17
|
rule keyvalue
|
18
|
-
(
|
18
|
+
(stripped_key '=' space? v:(toml_values) comment?) <TOML::KeyvalueParser>
|
19
19
|
end
|
20
20
|
|
21
21
|
rule inline_table
|
@@ -34,5 +34,7 @@ grammar TOML::Document
|
|
34
34
|
primitive | inline_table | array | inline_table_array
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
rule stripped_key
|
38
|
+
(space? key space?) { captures[:key].first.value }
|
39
|
+
end
|
38
40
|
end
|
@@ -34,8 +34,8 @@ grammar TOML::Primitive
|
|
34
34
|
##
|
35
35
|
|
36
36
|
rule datetime
|
37
|
-
(date_skeleton ("Z" | date_offset | [,\.] frac:(/\d/1*6) date_offset)) {
|
38
|
-
skeleton = captures[:
|
37
|
+
( skeleton:(datetime_skeleton | date_skeleton) ("Z" | date_offset | [,\.] frac:(/\d/1*6) date_offset?)? ) {
|
38
|
+
skeleton = captures[:skeleton].first
|
39
39
|
y,m,d,h,mi,s = skeleton.value
|
40
40
|
offset = captures[:date_offset].first || "+00:00"
|
41
41
|
sec_frac = captures[:frac].first || 0
|
@@ -45,7 +45,7 @@ grammar TOML::Primitive
|
|
45
45
|
}
|
46
46
|
end
|
47
47
|
|
48
|
-
rule
|
48
|
+
rule datetime_skeleton
|
49
49
|
(y:/\d\d\d\d/ "-" m:/\d\d/ "-" d:/\d\d/ "T" h:/\d\d/ ":" mi:/\d\d/ ":" s:/\d\d/) {
|
50
50
|
[:y,:m,:d,:h,:mi,:s].map{ |s| capture(s).value }
|
51
51
|
}
|
@@ -55,6 +55,12 @@ grammar TOML::Primitive
|
|
55
55
|
offset:(sign /\d\d/ ":" /\d\d/)
|
56
56
|
end
|
57
57
|
|
58
|
+
rule date_skeleton
|
59
|
+
(y:/\d\d\d\d/ "-" m:/\d\d/ "-" d:/\d\d/) {
|
60
|
+
[:y,:m,:d].map{ |s| capture(s).value } + [0, 0, 0]
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
58
64
|
##
|
59
65
|
# Number rules
|
60
66
|
##
|
data/lib/toml/keygroup.rb
CHANGED
data/lib/toml/keyvalue.rb
CHANGED
data/lib/toml/table_array.rb
CHANGED
data/test/grammar_test.rb
CHANGED
@@ -34,8 +34,12 @@ class GrammarTest < Minitest::Test
|
|
34
34
|
assert_equal(['first key', 'second key'],
|
35
35
|
match.value.instance_variable_get('@nested_keys'))
|
36
36
|
|
37
|
+
match = TOML::Document.parse('[ owner . emancu ]', root: :keygroup)
|
38
|
+
assert_equal(%w(owner emancu),
|
39
|
+
match.value.instance_variable_get('@nested_keys'))
|
40
|
+
|
37
41
|
assert_raises Citrus::ParseError do
|
38
|
-
TOML::Document.parse('[ owner
|
42
|
+
TOML::Document.parse('[ owner emancu ]', root: :keygroup)
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -189,6 +193,8 @@ class GrammarTest < Minitest::Test
|
|
189
193
|
assert_equal([1, 3], match.value)
|
190
194
|
end
|
191
195
|
|
196
|
+
# Dates are really hard to test from JSON, due the imposibility to represent
|
197
|
+
# datetimes without quotes.
|
192
198
|
def test_datetime
|
193
199
|
match = TOML::Document.parse('1986-08-28T15:15:00Z', root: :datetime)
|
194
200
|
assert_equal(Time.utc(1986, 8, 28, 15, 15), match.value)
|
@@ -198,6 +204,15 @@ class GrammarTest < Minitest::Test
|
|
198
204
|
|
199
205
|
match = TOML::Document.parse('1986-08-28T15:15:00.123-03:00', root: :datetime)
|
200
206
|
assert_equal(Time.utc(1986, 8, 28, 18, 15, 0.123), match.value)
|
207
|
+
|
208
|
+
match = TOML::Document.parse('1986-08-28', root: :datetime)
|
209
|
+
assert_equal(Time.utc(1986, 8, 28, 0, 0, 0), match.value)
|
210
|
+
|
211
|
+
match = TOML::Document.parse('1986-08-28T15:15:00', root: :datetime)
|
212
|
+
assert_equal(Time.utc(1986, 8, 28, 15, 15), match.value)
|
213
|
+
|
214
|
+
match = TOML::Document.parse('1986-08-28T15:15:00.999999', root: :datetime)
|
215
|
+
assert_equal(Time.utc(1986, 8, 28, 15, 15, 0.999999), match.value)
|
201
216
|
end
|
202
217
|
|
203
218
|
def test_inline_table
|
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.11
|
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: 2016-
|
12
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: citrus
|