toml-rb 3.0.1 → 4.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17bca528380dd019502a124e00667782d479b10f3b969d4953eb53738c8f94b4
4
- data.tar.gz: db97b38da58ce0a0ff99f5f1c62b0c14aadf40529188336843964f8fe7bc808a
3
+ metadata.gz: 7deb039c3dea36679fb813cc6414671f8691f97d8a4d3d180a5a8cab2a5636e8
4
+ data.tar.gz: 6d495d33fe92641632e962d560a508c35f1d0f03c5d445e13151b5b4e046a9ce
5
5
  SHA512:
6
- metadata.gz: 7f27ceb8979c1775126f652c39766e84072007ba59d58bab852be8a38033f091c31239b7931515de1c9d504e11f253d27cf2086e47efc9339de62aaa17dee6cc
7
- data.tar.gz: f659f25a3335391dbb3982e09f76266ac365349e87b8d58b3eb1d6f3b2b403da4bf976b735a2cb55bcddbdd061894989329b243f19818ab50f339d86c40b8b07
6
+ metadata.gz: 853879c8fbd703519d800f6e48b8b81cbc92791adb63584a5be9a75b9f17ea635df63aa86df7c05465684c4d15d2b72528740c307a06abda5f786913391ff16a
7
+ data.tar.gz: 766d75b5c583d47a17d17c0fca05d6f520ae198c7953ad78cf2eda937397bb67c77e5c820ca1ea0924825020da3af2d7d26249d89f1a9d6062a03ff647a811dc
@@ -1,6 +1,5 @@
1
1
  grammar TomlRB::Document
2
2
  include TomlRB::Primitive
3
- include TomlRB::Arrays
4
3
 
5
4
  rule document
6
5
  (comment | table_array | table | keyvalue | line_break)*
@@ -18,35 +17,41 @@ grammar TomlRB::Document
18
17
  (stripped_key '=' space? v:(toml_values) comment? space) <TomlRB::KeyvalueParser>
19
18
  end
20
19
 
20
+ ### Values
21
+
21
22
  rule inline_table
22
23
  (space? '{' (keyvalue? (',' keyvalue)*)? space? '}' ) <TomlRB::InlineTableParser>
23
24
  end
24
25
 
25
- rule inline_table_array
26
- (inline_table (space "," array_comments inline_table)*) {
27
- captures[:inline_table].map(&:value).map(&:value)
28
- }
29
- end
30
-
31
26
  rule array
32
27
  ("[" array_comments (array_elements)? space ","? array_comments "]" indent?) <TomlRB::ArrayParser>
33
28
  end
34
29
 
35
- rule array_elements
36
- inline_table_array | float_array | string_array | array_array | integer_array | datetime_array | bool_array
37
- end
38
-
39
30
  rule array_array
40
31
  (array (space "," array_comments array)*) {
41
32
  captures[:array].map(&:value)
42
33
  }
43
34
  end
44
35
 
45
- rule toml_values
46
- primitive | inline_table | array | inline_table_array
36
+ rule array_elements
37
+ (toml_values (indent? "," array_comments toml_values)*) {
38
+ captures[:toml_values].map(&:value).map do |v|
39
+ v.respond_to?(:value) ? v.value : v
40
+ end
41
+ }
47
42
  end
48
43
 
44
+ ### Helpers
45
+
49
46
  rule stripped_key
50
47
  (space? key space?) { captures[:key].first.value }
51
48
  end
49
+
50
+ rule array_comments
51
+ (indent? (comment indent?)*)
52
+ end
53
+
54
+ rule toml_values
55
+ primitive | inline_table | array
56
+ end
52
57
  end
@@ -99,33 +99,33 @@ grammar TomlRB::Primitive
99
99
  end
100
100
 
101
101
  rule exponential_float
102
- ((fractional_float | demical_integer) [eE] demical_integer) { to_str.to_f }
102
+ ((fractional_float | decimal_integer) [eE] decimal_integer) { to_str.to_f }
103
103
  end
104
104
 
105
105
  rule fractional_float
106
- (demical_integer '.' [0-9_]+) {
106
+ (decimal_integer '.' [0-9] ([0-9] | '_' [0-9])*) {
107
107
  to_str.to_f
108
108
  }
109
109
  end
110
110
 
111
111
  rule integer
112
- hexadecimal_integer | octal_integer | binary_integer | demical_integer
112
+ hexadecimal_integer | octal_integer | binary_integer | decimal_integer
113
113
  end
114
114
 
115
115
  rule hexadecimal_integer
116
- ('0x' [a-fA-F0-9_]+) { to_str.to_i(16) }
116
+ ('0x' [a-fA-F0-9] ([a-fA-F0-9] | '_' [a-fA-F0-9])*) { to_str.to_i(16) }
117
117
  end
118
118
 
119
119
  rule octal_integer
120
- ('0o' [0-7_]+) { to_str.to_i(8) }
120
+ ('0o' [0-7] ([0-7] | '_' [0-7])*) { to_str.to_i(8) }
121
121
  end
122
122
 
123
123
  rule binary_integer
124
- ('0b' [01_]+) { to_str.to_i(2) }
124
+ ('0b' [01] ([01] | '_' [01])*) { to_str.to_i(2) }
125
125
  end
126
126
 
127
- rule demical_integer
128
- (sign? [0-9_]+) { to_str.to_i }
127
+ rule decimal_integer
128
+ (sign? [0-9] ([0-9] | '_' [0-9])*) { to_str.to_i }
129
129
  end
130
130
 
131
131
  rule sign
@@ -161,7 +161,7 @@ grammar TomlRB::Primitive
161
161
  end
162
162
 
163
163
  rule quoted_key
164
- basic_string | literal_string
164
+ basic_string | literal_string
165
165
  end
166
166
 
167
167
  rule single_key
@@ -20,7 +20,7 @@ module TomlRB
20
20
 
21
21
  module InlineTableParser
22
22
  def value
23
- TomlRB::InlineTable.new captures[:keyvalue].map(&:value)
23
+ TomlRB::InlineTable.new(captures[:keyvalue].map(&:value))
24
24
  end
25
25
  end
26
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TomlRB
4
- VERSION = "3.0.1"
4
+ VERSION = "4.0.0"
5
5
  end
data/lib/toml-rb.rb CHANGED
@@ -14,7 +14,6 @@ require_relative "toml-rb/dumper"
14
14
  File.dirname(File.expand_path(__FILE__)).tap do |root|
15
15
  Citrus.load "#{root}/toml-rb/grammars/helper.citrus"
16
16
  Citrus.load "#{root}/toml-rb/grammars/primitive.citrus"
17
- Citrus.load "#{root}/toml-rb/grammars/array.citrus"
18
17
  Citrus.load "#{root}/toml-rb/grammars/document.citrus"
19
18
  end
20
19
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toml-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0
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: 2024-01-31 00:00:00.000000000 Z
12
+ date: 2025-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: citrus
@@ -102,7 +102,6 @@ files:
102
102
  - lib/toml-rb/datetime.rb
103
103
  - lib/toml-rb/dumper.rb
104
104
  - lib/toml-rb/errors.rb
105
- - lib/toml-rb/grammars/array.citrus
106
105
  - lib/toml-rb/grammars/document.citrus
107
106
  - lib/toml-rb/grammars/helper.citrus
108
107
  - lib/toml-rb/grammars/primitive.citrus
@@ -117,7 +116,7 @@ homepage: https://github.com/emancu/toml-rb
117
116
  licenses:
118
117
  - MIT
119
118
  metadata: {}
120
- post_install_message:
119
+ post_install_message:
121
120
  rdoc_options: []
122
121
  require_paths:
123
122
  - lib
@@ -132,8 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  - !ruby/object:Gem::Version
133
132
  version: '0'
134
133
  requirements: []
135
- rubygems_version: 3.4.10
136
- signing_key:
134
+ rubygems_version: 3.1.6
135
+ signing_key:
137
136
  specification_version: 4
138
137
  summary: Toml parser in ruby, for ruby.
139
138
  test_files: []
@@ -1,37 +0,0 @@
1
- grammar TomlRB::Arrays
2
- include TomlRB::Primitive
3
-
4
- rule array_comments
5
- (indent? (comment indent?)*)
6
- end
7
-
8
- rule float_array
9
- (float (indent? "," array_comments float)*) {
10
- captures[:float].map(&:value)
11
- }
12
- end
13
-
14
- rule string_array
15
- (string (indent? "," array_comments string)*) {
16
- captures[:string].map(&:value)
17
- }
18
- end
19
-
20
- rule integer_array
21
- (integer (indent? "," array_comments integer)*) {
22
- captures[:integer].map(&:value)
23
- }
24
- end
25
-
26
- rule datetime_array
27
- (datetime (indent? "," array_comments datetime)*) {
28
- captures[:datetime].map(&:value)
29
- }
30
- end
31
-
32
- rule bool_array
33
- (bool (indent? "," array_comments bool)*) {
34
- captures[:bool].map(&:value)
35
- }
36
- end
37
- end