toml-rb 0.3.5 → 0.3.6
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/array.citrus +2 -2
- data/lib/toml/grammars/document.citrus +8 -8
- data/lib/toml/grammars/helper.citrus +1 -1
- data/lib/toml/grammars/primitive.citrus +6 -6
- data/lib/toml/inline_table.rb +12 -10
- data/lib/toml/keygroup.rb +5 -6
- data/lib/toml/keyvalue.rb +8 -7
- data/lib/toml/parser.rb +1 -1
- data/lib/toml/string.rb +33 -32
- data/lib/toml/table_array.rb +5 -5
- data/test/grammar_test.rb +47 -46
- data/test/toml_examples.rb +1 -1
- data/test/toml_test.rb +3 -3
- 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: 763a2531f36107f17c09cf4b60399de4487fce09
|
4
|
+
data.tar.gz: 891ced2d3c3dcd42baab838a0586c12b47976c2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8683b77c2b7dcdfc38c11af8d79ec376e6de7702cb977f3a53c0be0d2aa87151a1541eb54d3d91eef9730bcf8d011aee01820bf7185b6b4a3ba2705c94f53da
|
7
|
+
data.tar.gz: fe95e0553af526da664b7e8de0581a8c9b9f4eb0e1c1c636743cab830b59a555222c16e3518558bd9efe6e76eed9c29695bdb5b44c31660921d7564eeaf6d39a
|
@@ -1,29 +1,29 @@
|
|
1
|
-
grammar Document
|
2
|
-
include Primitive
|
3
|
-
include
|
1
|
+
grammar TOML::Document
|
2
|
+
include TOML::Primitive
|
3
|
+
include TOML::Arrays
|
4
4
|
|
5
5
|
rule document
|
6
6
|
(comment | table_array | keygroup | keyvalue | line_break)*
|
7
7
|
end
|
8
8
|
|
9
9
|
rule table_array
|
10
|
-
(space? '[[' (space? key space? "."?)+ ']]' space? comment?) <
|
10
|
+
(space? '[[' (space? key space? "."?)+ ']]' space? comment?) <TOML::TableArrayParser>
|
11
11
|
end
|
12
12
|
|
13
13
|
rule keygroup
|
14
|
-
(space? '[' (space? key space? "."?)+ ']' space? comment?) <
|
14
|
+
(space? '[' (space? key space? "."?)+ ']' space? comment?) <TOML::KeygroupParser>
|
15
15
|
end
|
16
16
|
|
17
17
|
rule keyvalue
|
18
|
-
(space? key space? '=' space? v:(toml_values) comment?) <
|
18
|
+
(space? key space? '=' space? v:(toml_values) comment?) <TOML::KeyvalueParser>
|
19
19
|
end
|
20
20
|
|
21
21
|
rule inline_table
|
22
|
-
(space? '{' (keyvalue (',' keyvalue)*)? space? '}' ) <
|
22
|
+
(space? '{' (keyvalue (',' keyvalue)*)? space? '}' ) <TOML::InlineTableParser>
|
23
23
|
end
|
24
24
|
|
25
25
|
rule inline_table_array
|
26
|
-
("[" array_comments inline_table_array_elements space ","? array_comments "]" indent?) <
|
26
|
+
("[" array_comments inline_table_array_elements space ","? array_comments "]" indent?) <TOML::InlineTableArrayParser>
|
27
27
|
end
|
28
28
|
|
29
29
|
rule inline_table_array_elements
|
@@ -1,5 +1,5 @@
|
|
1
|
-
grammar Primitive
|
2
|
-
include Helper
|
1
|
+
grammar TOML::Primitive
|
2
|
+
include TOML::Helper
|
3
3
|
|
4
4
|
rule primitive
|
5
5
|
string | bool | datetime | number
|
@@ -14,19 +14,19 @@ grammar Primitive
|
|
14
14
|
end
|
15
15
|
|
16
16
|
rule basic_string
|
17
|
-
(/(["])(?:\\?.)*?\1/ space) <
|
17
|
+
(/(["])(?:\\?.)*?\1/ space) <TOML::BasicString>
|
18
18
|
end
|
19
19
|
|
20
20
|
rule literal_string
|
21
|
-
(/(['])(?:\\?.)*?\1/ space) <
|
21
|
+
(/(['])(?:\\?.)*?\1/ space) <TOML::LiteralString>
|
22
22
|
end
|
23
23
|
|
24
24
|
rule multiline_string
|
25
|
-
('"""' line_break* text:~'"""' '"""' space) <
|
25
|
+
('"""' line_break* text:~'"""' '"""' space) <TOML::MultilineString>
|
26
26
|
end
|
27
27
|
|
28
28
|
rule multiline_literal
|
29
|
-
("'''" line_break* text:~"'''" "'''" space) <
|
29
|
+
("'''" line_break* text:~"'''" "'''" space) <TOML::MultilineLiteral>
|
30
30
|
end
|
31
31
|
|
32
32
|
##
|
data/lib/toml/inline_table.rb
CHANGED
@@ -8,7 +8,7 @@ module TOML
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def value(symbolize_keys = false)
|
11
|
-
if @symbolize_keys = symbolize_keys
|
11
|
+
if (@symbolize_keys = symbolize_keys)
|
12
12
|
tuple = ->(kv) { [kv.key.to_sym, visit_value(kv.value)] }
|
13
13
|
else
|
14
14
|
tuple = ->(kv) { [kv.key, visit_value(kv.value)] }
|
@@ -53,18 +53,20 @@ module TOML
|
|
53
53
|
@inline_tables.map { |it| it.value(symbolize_keys) }
|
54
54
|
end
|
55
55
|
end
|
56
|
-
end
|
57
56
|
|
58
|
-
module
|
59
|
-
|
60
|
-
|
57
|
+
module InlineTableParser
|
58
|
+
def value
|
59
|
+
TOML::InlineTable.new captures[:keyvalue].map(&:value)
|
60
|
+
end
|
61
61
|
end
|
62
|
-
end
|
63
62
|
|
64
|
-
module
|
65
|
-
|
66
|
-
|
63
|
+
module InlineTableArrayParser
|
64
|
+
def value
|
65
|
+
tables = captures[:inline_table_array_elements].map do |x|
|
66
|
+
x.captures[:inline_table]
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
+
TOML::InlineTableArray.new(tables.flatten.map(&:value)).value
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
data/lib/toml/keygroup.rb
CHANGED
@@ -26,11 +26,10 @@ module TOML
|
|
26
26
|
parser.visit_keygroup self
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
TOML::Keygroup.new(captures[:key].map(&:value))
|
29
|
+
# Used in document.citrus
|
30
|
+
module KeygroupParser
|
31
|
+
def value
|
32
|
+
TOML::Keygroup.new(captures[:key].map(&:value))
|
33
|
+
end
|
35
34
|
end
|
36
35
|
end
|
data/lib/toml/keyvalue.rb
CHANGED
@@ -12,7 +12,9 @@ module TOML
|
|
12
12
|
attr_reader :value, :symbolize_keys
|
13
13
|
|
14
14
|
def initialize(key, value)
|
15
|
-
@key
|
15
|
+
@key = key
|
16
|
+
@value = value
|
17
|
+
@symbolize_keys = false
|
16
18
|
end
|
17
19
|
|
18
20
|
def assign(hash, symbolize_keys = false)
|
@@ -47,11 +49,10 @@ module TOML
|
|
47
49
|
a_value.accept_visitor self
|
48
50
|
end
|
49
51
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
TOML::Keyvalue.new(capture(:key).value, capture(:v).value)
|
52
|
+
# Used in document.citrus
|
53
|
+
module KeyvalueParser
|
54
|
+
def value
|
55
|
+
TOML::Keyvalue.new(capture(:key).value, capture(:v).value)
|
56
|
+
end
|
56
57
|
end
|
57
58
|
end
|
data/lib/toml/parser.rb
CHANGED
@@ -10,7 +10,7 @@ module TOML
|
|
10
10
|
@symbolize_keys = options[:symbolize_keys]
|
11
11
|
|
12
12
|
begin
|
13
|
-
parsed = Document.parse(content)
|
13
|
+
parsed = TOML::Document.parse(content)
|
14
14
|
parsed.matches.map(&:value).compact.each { |m| m.accept_visitor(self) }
|
15
15
|
rescue Citrus::ParseError => e
|
16
16
|
raise ParseError.new(e.message)
|
data/lib/toml/string.rb
CHANGED
@@ -1,43 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
str
|
11
|
-
.gsub(/\\0/, "\0")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
module TOML
|
2
|
+
# Used in primitive.citrus
|
3
|
+
module BasicString
|
4
|
+
def value
|
5
|
+
aux = TOML::BasicString.transform_escaped_chars first.value
|
6
|
+
|
7
|
+
aux[1...-1]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.transform_escaped_chars(str)
|
11
|
+
str.gsub(/\\0/, "\0")
|
12
|
+
.gsub(/\\t/, "\t")
|
13
|
+
.gsub(/\\n/, "\n")
|
14
|
+
.gsub(/\\\"/, '"')
|
15
|
+
.gsub(/\\r/, "\r")
|
16
|
+
.gsub(/\\\\/, '\\')
|
17
|
+
end
|
17
18
|
end
|
18
|
-
end
|
19
19
|
|
20
|
-
module
|
21
|
-
|
22
|
-
|
20
|
+
module LiteralString
|
21
|
+
def value
|
22
|
+
first.value[1...-1]
|
23
|
+
end
|
23
24
|
end
|
24
|
-
end
|
25
25
|
|
26
|
-
module
|
27
|
-
|
28
|
-
|
26
|
+
module MultilineString
|
27
|
+
def value
|
28
|
+
aux = captures[:text].first.value
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
# Remove spaces on multilined Singleline strings
|
31
|
+
aux.gsub!(/\\\r?\n[\n\t\r ]*/, '')
|
32
32
|
|
33
|
-
|
33
|
+
TOML::BasicString.transform_escaped_chars aux
|
34
|
+
end
|
34
35
|
end
|
35
|
-
end
|
36
36
|
|
37
|
-
module
|
38
|
-
|
39
|
-
|
37
|
+
module MultilineLiteral
|
38
|
+
def value
|
39
|
+
aux = captures[:text].first.value
|
40
40
|
|
41
|
-
|
41
|
+
aux.gsub(/\\\r?\n[\n\t\r ]*/, '')
|
42
|
+
end
|
42
43
|
end
|
43
44
|
end
|
data/lib/toml/table_array.rb
CHANGED
@@ -31,11 +31,11 @@ module TOML
|
|
31
31
|
parser.visit_table_array self
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
35
34
|
|
36
|
-
# Used in document.citrus
|
37
|
-
module
|
38
|
-
|
39
|
-
|
35
|
+
# Used in document.citrus
|
36
|
+
module TableArrayParser
|
37
|
+
def value
|
38
|
+
TOML::TableArray.new(captures[:key].map(&:value))
|
39
|
+
end
|
40
40
|
end
|
41
41
|
end
|
data/test/grammar_test.rb
CHANGED
@@ -3,41 +3,41 @@ require_relative 'helper'
|
|
3
3
|
|
4
4
|
class GrammarTest < Test::Unit::TestCase
|
5
5
|
def test_comment
|
6
|
-
match = Document.parse(' # A comment', root: :comment)
|
6
|
+
match = TOML::Document.parse(' # A comment', root: :comment)
|
7
7
|
assert_equal(nil, match.value)
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_key
|
11
|
-
match = Document.parse('bad_key-', root: :key)
|
11
|
+
match = TOML::Document.parse('bad_key-', root: :key)
|
12
12
|
assert_equal('bad_key-', match.value)
|
13
13
|
|
14
|
-
match = Document.parse('"123.ʎǝʞ.#?"', root: :key)
|
14
|
+
match = TOML::Document.parse('"123.ʎǝʞ.#?"', root: :key)
|
15
15
|
assert_equal('123.ʎǝʞ.#?', match.value)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_keygroup
|
19
19
|
indentation_alternatives_for('[akey]') do |str|
|
20
|
-
match = Document.parse(str, root: :keygroup)
|
20
|
+
match = TOML::Document.parse(str, root: :keygroup)
|
21
21
|
assert_equal(TOML::Keygroup, match.value.class)
|
22
22
|
assert_equal(['akey'], match.value.instance_variable_get('@nested_keys'))
|
23
23
|
end
|
24
24
|
|
25
|
-
match = Document.parse('[owner.emancu]', root: :keygroup)
|
25
|
+
match = TOML::Document.parse('[owner.emancu]', root: :keygroup)
|
26
26
|
assert_equal(%w(owner emancu),
|
27
27
|
match.value.instance_variable_get('@nested_keys'))
|
28
28
|
|
29
|
-
match = Document.parse('["owner.emancu"]', root: :keygroup)
|
29
|
+
match = TOML::Document.parse('["owner.emancu"]', root: :keygroup)
|
30
30
|
assert_equal(%w(owner.emancu),
|
31
31
|
match.value.instance_variable_get('@nested_keys'))
|
32
32
|
|
33
|
-
match = Document.parse('[ owner . emancu ]', root: :keygroup)
|
33
|
+
match = TOML::Document.parse('[ owner . emancu ]', root: :keygroup)
|
34
34
|
assert_equal(%w(owner emancu),
|
35
35
|
match.value.instance_variable_get('@nested_keys'))
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_keyvalue
|
39
39
|
indentation_alternatives_for('key = "value"') do |str|
|
40
|
-
match = Document.parse(str, root: :keyvalue)
|
40
|
+
match = TOML::Document.parse(str, root: :keyvalue)
|
41
41
|
assert_equal(TOML::Keyvalue, match.value.class)
|
42
42
|
|
43
43
|
keyvalue = match.value
|
@@ -47,12 +47,12 @@ class GrammarTest < Test::Unit::TestCase
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_string
|
50
|
-
match = Document.parse('"TOML-Example, should work."', root: :string)
|
50
|
+
match = TOML::Document.parse('"TOML-Example, should work."', root: :string)
|
51
51
|
assert_equal('TOML-Example, should work.', match.value)
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_multiline_string
|
55
|
-
match = Document.parse('"""\tOne\nTwo"""', root: :multiline_string)
|
55
|
+
match = TOML::Document.parse('"""\tOne\nTwo"""', root: :multiline_string)
|
56
56
|
assert_equal "\tOne\nTwo", match.value
|
57
57
|
|
58
58
|
to_parse = '"""\
|
@@ -60,143 +60,144 @@ class GrammarTest < Test::Unit::TestCase
|
|
60
60
|
Two\
|
61
61
|
"""'
|
62
62
|
|
63
|
-
match = Document.parse(to_parse, root: :multiline_string)
|
63
|
+
match = TOML::Document.parse(to_parse, root: :multiline_string)
|
64
64
|
assert_equal "One Two", match.value
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_special_characters
|
68
|
-
match = Document.parse('"\0 \" \t \n \r"', root: :string)
|
68
|
+
match = TOML::Document.parse('"\0 \" \t \n \r"', root: :string)
|
69
69
|
assert_equal("\0 \" \t \n \r", match.value)
|
70
70
|
|
71
|
-
match = Document.parse('"C:\\Documents\\virus.exe"', root: :string)
|
71
|
+
match = TOML::Document.parse('"C:\\Documents\\virus.exe"', root: :string)
|
72
72
|
assert_equal('C:\\Documents\\virus.exe', match.value)
|
73
73
|
end
|
74
74
|
|
75
75
|
def test_bool
|
76
|
-
match = Document.parse('true', root: :bool)
|
76
|
+
match = TOML::Document.parse('true', root: :bool)
|
77
77
|
assert_equal(true, match.value)
|
78
78
|
|
79
|
-
match = Document.parse('false', root: :bool)
|
79
|
+
match = TOML::Document.parse('false', root: :bool)
|
80
80
|
assert_equal(false, match.value)
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_integer
|
84
|
-
match = Document.parse('26', root: :number)
|
84
|
+
match = TOML::Document.parse('26', root: :number)
|
85
85
|
assert_equal(26, match.value)
|
86
86
|
|
87
|
-
match = Document.parse('1_200_000_999', root: :number)
|
87
|
+
match = TOML::Document.parse('1_200_000_999', root: :number)
|
88
88
|
assert_equal(1_200_000_999, match.value)
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_float
|
92
|
-
match = Document.parse('1.69', root: :number)
|
92
|
+
match = TOML::Document.parse('1.69', root: :number)
|
93
93
|
assert_equal(1.69, match.value)
|
94
94
|
|
95
|
-
match = Document.parse('1_000.69', root: :number)
|
95
|
+
match = TOML::Document.parse('1_000.69', root: :number)
|
96
96
|
assert_equal(1000.69, match.value)
|
97
97
|
|
98
|
-
match = Document.parse('1e6', root: :number)
|
98
|
+
match = TOML::Document.parse('1e6', root: :number)
|
99
99
|
assert_equal(1e6, match.value)
|
100
100
|
|
101
|
-
match = Document.parse('1.02e-46', root: :number)
|
101
|
+
match = TOML::Document.parse('1.02e-46', root: :number)
|
102
102
|
assert_equal(1.02e-46, match.value)
|
103
103
|
|
104
|
-
match = Document.parse('+1e4_000_000', root: :number)
|
104
|
+
match = TOML::Document.parse('+1e4_000_000', root: :number)
|
105
105
|
assert_equal(1e4_000_000, match.value)
|
106
106
|
end
|
107
107
|
|
108
108
|
def test_signed_numbers
|
109
|
-
match = Document.parse('+26', root: :number)
|
109
|
+
match = TOML::Document.parse('+26', root: :number)
|
110
110
|
assert_equal(26, match.value)
|
111
111
|
|
112
|
-
match = Document.parse('-26', root: :number)
|
112
|
+
match = TOML::Document.parse('-26', root: :number)
|
113
113
|
assert_equal(-26, match.value)
|
114
114
|
|
115
|
-
match = Document.parse('1.69', root: :number)
|
115
|
+
match = TOML::Document.parse('1.69', root: :number)
|
116
116
|
assert_equal(1.69, match.value)
|
117
117
|
|
118
|
-
match = Document.parse('-1.69', root: :number)
|
118
|
+
match = TOML::Document.parse('-1.69', root: :number)
|
119
119
|
assert_equal(-1.69, match.value)
|
120
120
|
end
|
121
121
|
|
122
122
|
def test_expressions_with_comments
|
123
|
-
match = Document.parse('[shouldwork] # with comment', root: :keygroup)
|
123
|
+
match = TOML::Document.parse('[shouldwork] # with comment', root: :keygroup)
|
124
124
|
assert_equal(['shouldwork'],
|
125
125
|
match.value.instance_variable_get('@nested_keys'))
|
126
126
|
|
127
|
-
match = Document.parse('works = true # with comment', root: :keyvalue).value
|
127
|
+
match = TOML::Document.parse('works = true # with comment', root: :keyvalue).value
|
128
128
|
assert_equal('works', match.instance_variable_get('@key'))
|
129
129
|
assert_equal(true, match.instance_variable_get('@value'))
|
130
130
|
end
|
131
131
|
|
132
132
|
def test_array
|
133
|
-
match = Document.parse('[]', root: :array)
|
133
|
+
match = TOML::Document.parse('[]', root: :array)
|
134
134
|
assert_equal([], match.value)
|
135
135
|
|
136
|
-
match = Document.parse('[ 2, 4]', root: :array)
|
136
|
+
match = TOML::Document.parse('[ 2, 4]', root: :array)
|
137
137
|
assert_equal([2, 4], match.value)
|
138
138
|
|
139
|
-
match = Document.parse('[ 2.4, 4.72]', root: :array)
|
139
|
+
match = TOML::Document.parse('[ 2.4, 4.72]', root: :array)
|
140
140
|
assert_equal([2.4, 4.72], match.value)
|
141
141
|
|
142
|
-
match = Document.parse('[ "hey", "TOML"]', root: :array)
|
142
|
+
match = TOML::Document.parse('[ "hey", "TOML"]', root: :array)
|
143
143
|
assert_equal(%w(hey TOML), match.value)
|
144
144
|
|
145
|
-
match = Document.parse('[ ["hey", "TOML"], [2,4] ]', root: :array)
|
145
|
+
match = TOML::Document.parse('[ ["hey", "TOML"], [2,4] ]', root: :array)
|
146
146
|
assert_equal([%w(hey TOML), [2, 4]], match.value)
|
147
147
|
|
148
|
-
match = Document.parse('[ { one = 1 }, { two = 2, three = 3} ]',
|
148
|
+
match = TOML::Document.parse('[ { one = 1 }, { two = 2, three = 3} ]',
|
149
149
|
root: :inline_table_array)
|
150
150
|
assert_equal([{ 'one' => 1 }, { 'two' => 2, 'three' => 3 }], match.value)
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_empty_array
|
154
154
|
# test that [] is parsed as array and not as inline table array
|
155
|
-
match = Document.parse("a = []", root: :keyvalue).value
|
155
|
+
match = TOML::Document.parse("a = []", root: :keyvalue).value
|
156
156
|
assert_equal [], match.value
|
157
157
|
end
|
158
158
|
|
159
159
|
def test_multiline_array
|
160
160
|
multiline_array = "[ \"hey\",\n \"ho\",\n\t \"lets\", \"go\",\n ]"
|
161
|
-
match = Document.parse(multiline_array, root: :array)
|
161
|
+
match = TOML::Document.parse(multiline_array, root: :array)
|
162
162
|
assert_equal(%w(hey ho lets go), match.value)
|
163
163
|
|
164
164
|
multiline_array = "[\n#1,\n2,\n# 3\n]"
|
165
|
-
match = Document.parse(multiline_array, root: :array)
|
165
|
+
match = TOML::Document.parse(multiline_array, root: :array)
|
166
166
|
assert_equal([2], match.value)
|
167
167
|
|
168
168
|
multiline_array = "[\n# comment\n#, more comments\n4]"
|
169
|
-
match = Document.parse(multiline_array, root: :array)
|
169
|
+
match = TOML::Document.parse(multiline_array, root: :array)
|
170
170
|
assert_equal([4], match.value)
|
171
171
|
|
172
172
|
multiline_array = "[\n 1,\n # 2,\n 3 ,\n]"
|
173
|
-
match = Document.parse(multiline_array, root: :array)
|
173
|
+
match = TOML::Document.parse(multiline_array, root: :array)
|
174
174
|
assert_equal([1, 3], match.value)
|
175
175
|
|
176
176
|
multiline_array = "[\n 1 , # useless comment\n # 2,\n 3 #other comment\n]"
|
177
|
-
match = Document.parse(multiline_array, root: :array)
|
177
|
+
match = TOML::Document.parse(multiline_array, root: :array)
|
178
178
|
assert_equal([1, 3], match.value)
|
179
179
|
end
|
180
180
|
|
181
181
|
def test_datetime
|
182
|
-
match = Document.parse('1986-08-28T15:15:00Z', root: :datetime)
|
182
|
+
match = TOML::Document.parse('1986-08-28T15:15:00Z', root: :datetime)
|
183
183
|
assert_equal(Time.utc(1986, 8, 28, 15, 15), match.value)
|
184
184
|
|
185
|
-
match = Document.parse('1986-08-28T15:15:00-03:00', root: :datetime)
|
185
|
+
match = TOML::Document.parse('1986-08-28T15:15:00-03:00', root: :datetime)
|
186
186
|
assert_equal(Time.utc(1986, 8, 28, 18, 15), match.value)
|
187
187
|
|
188
|
-
match = Document.parse('1986-08-28T15:15:00.123-03:00', root: :datetime)
|
188
|
+
match = TOML::Document.parse('1986-08-28T15:15:00.123-03:00', root: :datetime)
|
189
189
|
assert_equal(Time.utc(1986, 8, 28, 18, 15, 0.123), match.value)
|
190
190
|
end
|
191
191
|
|
192
192
|
def test_inline_table
|
193
|
-
match = Document.parse('{ }', root: :inline_table)
|
193
|
+
match = TOML::Document.parse('{ }', root: :inline_table)
|
194
194
|
assert_equal({}, match.value.value)
|
195
195
|
|
196
|
-
match = Document.parse('{ simple = true, params = 2 }', root: :inline_table)
|
196
|
+
match = TOML::Document.parse('{ simple = true, params = 2 }', root: :inline_table)
|
197
197
|
assert_equal({ 'simple' => true, 'params' => 2 }, match.value.value)
|
198
198
|
|
199
|
-
match = Document.parse('{ nest = { really = { hard = true } } }',
|
199
|
+
match = TOML::Document.parse('{ nest = { really = { hard = true } } }',
|
200
|
+
root: :inline_table)
|
200
201
|
assert_equal({ 'nest' => { 'really' => { 'hard' => true } } }, match.value.value)
|
201
202
|
assert_equal({ nest: { really: { hard: true } } }, match.value.value(true))
|
202
203
|
end
|
data/test/toml_examples.rb
CHANGED
data/test/toml_test.rb
CHANGED
@@ -5,7 +5,7 @@ class TomlTest < Test::Unit::TestCase
|
|
5
5
|
def test_file_v_0_4_0
|
6
6
|
path = File.join(File.dirname(__FILE__), 'example-v0.4.0.toml')
|
7
7
|
parsed = TOML.load_file(path)
|
8
|
-
hash =
|
8
|
+
hash = TOML::Examples.example_v_0_4_0
|
9
9
|
|
10
10
|
assert_equal hash['Array'], parsed['Array']
|
11
11
|
assert_equal hash['Booleans'], parsed['Booleans']
|
@@ -22,14 +22,14 @@ class TomlTest < Test::Unit::TestCase
|
|
22
22
|
path = File.join(File.dirname(__FILE__), 'example.toml')
|
23
23
|
parsed = TOML.load_file(path)
|
24
24
|
|
25
|
-
assert_equal
|
25
|
+
assert_equal TOML::Examples.example, parsed
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_hard_example
|
29
29
|
path = File.join(File.dirname(__FILE__), 'hard_example.toml')
|
30
30
|
parsed = TOML.load_file(path)
|
31
31
|
|
32
|
-
assert_equal
|
32
|
+
assert_equal TOML::Examples.hard_example, parsed
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_symbolize_keys
|
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.6
|
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: 2015-05-
|
12
|
+
date: 2015-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: citrus
|