toml-rb 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/toml-rb/array.rb +1 -1
- data/lib/toml-rb/datetime.rb +4 -4
- data/lib/toml-rb/dumper.rb +6 -6
- data/lib/toml-rb/grammars/document.citrus +1 -1
- data/lib/toml-rb/grammars/helper.citrus +1 -1
- data/lib/toml-rb/inline_table.rb +1 -1
- data/lib/toml-rb/keyvalue.rb +3 -2
- data/lib/toml-rb/string.rb +14 -14
- data/lib/toml-rb/table.rb +1 -1
- data/lib/toml-rb/table_array.rb +3 -3
- data/lib/toml-rb/version.rb +5 -0
- data/lib/toml-rb.rb +1 -1
- metadata +52 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa50386bfa3e4b6410b0339e2e24ea0e7ebef6e9c5ad5d6616bb1866c6603fb5
|
4
|
+
data.tar.gz: 636e0c4c7a3587958eebbcec87a0284c0aa85607e5e16a894ff4d9b3d884120f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d14285ee0ad9f55a8473354936f7398d62ee2a3ffca01609c420ebd809e5672506224158f41025f8defe7ab962de51830c30897483b9a2559d6438633b5197
|
7
|
+
data.tar.gz: 2ffba44e31838a5e46a579415240f14e9c7cdab6862658abff83e87913c10a1145711112ffd8e990599a83b6161a2ccacadd303ba1b8e3b9a01ca62679df2b06
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
![TOML Logo](https://github.com/toml-lang/toml/blob/master/logos/toml-100.png)
|
2
|
+
|
3
|
+
|
1
4
|
toml-rb
|
2
5
|
=======
|
3
6
|
|
4
7
|
[![Gem Version](https://badge.fury.io/rb/toml-rb.svg)](http://badge.fury.io/rb/toml-rb)
|
5
|
-
[![Build Status](https://
|
8
|
+
[![Build Status](https://github.com/emancu/toml-rb/actions/workflows/ruby.yml/badge.svg)](https://github.com/emancu/toml-rb/actions/workflows/ruby.yml)
|
6
9
|
[![Code Climate](https://codeclimate.com/github/emancu/toml-rb/badges/gpa.svg)](https://codeclimate.com/github/emancu/toml-rb)
|
7
10
|
[![RubyGem](https://img.shields.io/gem/dt/toml-rb.svg)](https://rubygems.org/gems/toml-rb)
|
8
11
|
|
data/lib/toml-rb/array.rb
CHANGED
data/lib/toml-rb/datetime.rb
CHANGED
@@ -14,7 +14,7 @@ module TomlRB
|
|
14
14
|
def value
|
15
15
|
year, mon, day = captures[:date_skeleton].first.value
|
16
16
|
hour, min, sec, sec_frac = captures[:time_skeleton].first.value
|
17
|
-
usec = sec_frac.to_s.ljust(6,
|
17
|
+
usec = sec_frac.to_s.ljust(6, "0")
|
18
18
|
|
19
19
|
Time.local(year, mon, day, hour, min, sec, usec)
|
20
20
|
end
|
@@ -23,16 +23,16 @@ module TomlRB
|
|
23
23
|
module LocalDateParser
|
24
24
|
def value
|
25
25
|
year, mon, day = captures[:date_skeleton].first.value
|
26
|
-
Time.local(year,mon,day)
|
26
|
+
Time.local(year, mon, day)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
module LocalTimeParser
|
31
31
|
def value
|
32
32
|
hour, min, sec, sec_frac = captures[:time_skeleton].first.value
|
33
|
-
usec = sec_frac.to_s.ljust(6,
|
33
|
+
usec = sec_frac.to_s.ljust(6, "0")
|
34
34
|
|
35
35
|
Time.at(3600 * hour.to_i + 60 * min.to_i + sec.to_i, usec.to_i)
|
36
36
|
end
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
data/lib/toml-rb/dumper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "date"
|
2
2
|
|
3
3
|
module TomlRB
|
4
4
|
class Dumper
|
5
5
|
attr_reader :toml_str
|
6
6
|
|
7
7
|
def initialize(hash)
|
8
|
-
@toml_str =
|
8
|
+
@toml_str = ""
|
9
9
|
|
10
10
|
visit(hash, [])
|
11
11
|
end
|
@@ -80,17 +80,17 @@ module TomlRB
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def print_prefix(prefix, extra_brackets = false)
|
83
|
-
new_prefix = prefix.join(
|
84
|
-
new_prefix =
|
83
|
+
new_prefix = prefix.join(".")
|
84
|
+
new_prefix = "[" + new_prefix + "]" if extra_brackets
|
85
85
|
|
86
86
|
@toml_str += "[" + new_prefix + "]\n"
|
87
87
|
end
|
88
88
|
|
89
89
|
def to_toml(obj)
|
90
90
|
if obj.is_a?(Time) || obj.is_a?(DateTime)
|
91
|
-
obj.strftime(
|
91
|
+
obj.strftime("%Y-%m-%dT%H:%M:%SZ")
|
92
92
|
elsif obj.is_a?(Date)
|
93
|
-
obj.strftime(
|
93
|
+
obj.strftime("%Y-%m-%d")
|
94
94
|
elsif obj.is_a? Regexp
|
95
95
|
obj.inspect.inspect
|
96
96
|
elsif obj.is_a? String
|
data/lib/toml-rb/inline_table.rb
CHANGED
data/lib/toml-rb/keyvalue.rb
CHANGED
@@ -14,12 +14,12 @@ module TomlRB
|
|
14
14
|
@symbolize_keys = symbolize_keys
|
15
15
|
dotted_keys_str = @dotted_keys.join(".")
|
16
16
|
keys = symbolize_keys ? @dotted_keys.map(&:to_sym) : @dotted_keys
|
17
|
-
update = keys.reverse.inject(visit_value
|
17
|
+
update = keys.reverse.inject(visit_value(@value)) { |k1, k2| {k2 => k1} }
|
18
18
|
|
19
19
|
if @value.is_a?(InlineTable)
|
20
20
|
fully_defined_keys << dotted_keys_str
|
21
21
|
hash.merge!(update) { |key, _, _| fail ValueOverwriteError.new(key) }
|
22
|
-
elsif fully_defined_keys.find{|k| update.dig(*k)}
|
22
|
+
elsif fully_defined_keys.find { |k| update.dig(*k) }
|
23
23
|
hash.merge!(update) { |key, _, _| fail ValueOverwriteError.new(key) }
|
24
24
|
else
|
25
25
|
dotted_key_merge(hash, update)
|
@@ -48,6 +48,7 @@ module TomlRB
|
|
48
48
|
a_value.accept_visitor self
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
51
52
|
# Used in document.citrus
|
52
53
|
module KeyvalueParser
|
53
54
|
def value
|
data/lib/toml-rb/string.rb
CHANGED
@@ -2,14 +2,14 @@ module TomlRB
|
|
2
2
|
# Used in primitive.citrus
|
3
3
|
module BasicString
|
4
4
|
SPECIAL_CHARS = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
'\\"'
|
12
|
-
|
5
|
+
"\\0" => "\0",
|
6
|
+
"\\t" => "\t",
|
7
|
+
"\\b" => "\b",
|
8
|
+
"\\f" => "\f",
|
9
|
+
"\\n" => "\n",
|
10
|
+
"\\r" => "\r",
|
11
|
+
'\\"' => '"',
|
12
|
+
"\\\\" => "\\"
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
def value
|
@@ -21,7 +21,7 @@ module TomlRB
|
|
21
21
|
# Replace the unicode escaped characters with the corresponding character
|
22
22
|
# e.g. \u03B4 => ?
|
23
23
|
def self.decode_unicode(str)
|
24
|
-
[str[2..-1].to_i(16)].pack(
|
24
|
+
[str[2..-1].to_i(16)].pack("U")
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.transform_escaped_chars(str)
|
@@ -29,7 +29,7 @@ module TomlRB
|
|
29
29
|
if m.size == 2
|
30
30
|
SPECIAL_CHARS[m] || parse_error(m)
|
31
31
|
else
|
32
|
-
decode_unicode(m).force_encoding(
|
32
|
+
decode_unicode(m).force_encoding("UTF-8")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -47,11 +47,11 @@ module TomlRB
|
|
47
47
|
|
48
48
|
module MultilineString
|
49
49
|
def value
|
50
|
-
return
|
50
|
+
return "" if captures[:text].empty?
|
51
51
|
aux = captures[:text].first.value
|
52
52
|
|
53
53
|
# Remove spaces on multilined Singleline strings
|
54
|
-
aux.gsub!(/\\\r?\n[\n\t\r ]*/,
|
54
|
+
aux.gsub!(/\\\r?\n[\n\t\r ]*/, "")
|
55
55
|
|
56
56
|
TomlRB::BasicString.transform_escaped_chars aux
|
57
57
|
end
|
@@ -59,10 +59,10 @@ module TomlRB
|
|
59
59
|
|
60
60
|
module MultilineLiteral
|
61
61
|
def value
|
62
|
-
return
|
62
|
+
return "" if captures[:text].empty?
|
63
63
|
aux = captures[:text].first.value
|
64
64
|
|
65
|
-
aux.gsub(/\\\r?\n[\n\t\r ]*/,
|
65
|
+
aux.gsub(/\\\r?\n[\n\t\r ]*/, "")
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/lib/toml-rb/table.rb
CHANGED
data/lib/toml-rb/table_array.rb
CHANGED
@@ -5,7 +5,7 @@ module TomlRB
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def navigate_keys(hash, symbolize_keys = false)
|
8
|
-
current = hash
|
8
|
+
current = hash
|
9
9
|
keys = symbolize_keys ? @dotted_keys.map(&:to_sym) : @dotted_keys
|
10
10
|
last_key = keys.pop
|
11
11
|
|
@@ -24,7 +24,7 @@ module TomlRB
|
|
24
24
|
# Define Table Array
|
25
25
|
if current[last_key].is_a? Hash
|
26
26
|
fail TomlRB::ParseError,
|
27
|
-
|
27
|
+
"#{last_key} was defined as hash but is now redefined as a table!"
|
28
28
|
end
|
29
29
|
current[last_key] = [] unless current[last_key]
|
30
30
|
current[last_key] << {}
|
@@ -37,7 +37,7 @@ module TomlRB
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def full_key
|
40
|
-
@dotted_keys.join(
|
40
|
+
@dotted_keys.join(".")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/lib/toml-rb.rb
CHANGED
metadata
CHANGED
@@ -1,36 +1,78 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toml-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emiliano Mancuso
|
8
8
|
- Lucas Tolchinsky
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: citrus
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.0'
|
21
|
-
- - "
|
21
|
+
- - ">"
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: '3.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
+
- - "~>"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '3.0'
|
28
31
|
- - ">"
|
29
32
|
- !ruby/object:Gem::Version
|
30
33
|
version: '3.0'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: minitest
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
31
38
|
- - "~>"
|
32
39
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
40
|
+
version: '5.7'
|
41
|
+
type: :development
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.7'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: standard
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.4'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
34
76
|
description: 'A Toml parser using Citrus parsing library. '
|
35
77
|
email:
|
36
78
|
- emiliano.mancuso@gmail.com
|
@@ -56,11 +98,12 @@ files:
|
|
56
98
|
- lib/toml-rb/string.rb
|
57
99
|
- lib/toml-rb/table.rb
|
58
100
|
- lib/toml-rb/table_array.rb
|
101
|
+
- lib/toml-rb/version.rb
|
59
102
|
homepage: https://github.com/emancu/toml-rb
|
60
103
|
licenses:
|
61
104
|
- MIT
|
62
105
|
metadata: {}
|
63
|
-
post_install_message:
|
106
|
+
post_install_message:
|
64
107
|
rdoc_options: []
|
65
108
|
require_paths:
|
66
109
|
- lib
|
@@ -75,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
118
|
- !ruby/object:Gem::Version
|
76
119
|
version: '0'
|
77
120
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
-
signing_key:
|
121
|
+
rubygems_version: 3.2.22
|
122
|
+
signing_key:
|
80
123
|
specification_version: 4
|
81
124
|
summary: Toml parser in ruby, for ruby.
|
82
125
|
test_files: []
|