toml-rb 4.1.0 → 4.2.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: 80597ee120e2f6517bfca775d9215d4ac3c9c9880bac87c1ec432edb78f32566
4
- data.tar.gz: fd278770b1c245508fc7ceb15336fba968e98b258bc06badcca0875107406292
3
+ metadata.gz: d11cbf4f3f759b946f7f1eec65450c67798690a7488146243e9e524c7f41b0f0
4
+ data.tar.gz: a034e9b52165a77cf56cb33e6fbaae8dc02c64bb9891d0d27b5071490dde7ea2
5
5
  SHA512:
6
- metadata.gz: d31002d86304f9c675da476e41f9c196077c7ded480f9f2224fb9d43416de1964238410828d55ce894f0ed68a0559097f2d96324be0f527771507f2589da4777
7
- data.tar.gz: 91a114c7a2c397be72edfb826025ae1cde65d0732359c38a3719ca6e61f2cd6eb237842d7ddf60e3034db9791c800c916e8bf1885aaa48e56ff147aaccc68d20
6
+ metadata.gz: 0ccb42dd5b8499964d2d0d4b33c2a99b6e5ea1620ca7e8b2c132ccc3e420564c3a897b3075768069c8a82245899cc36eb8e99c2c5f1f2c1723e92f7054f2fc5f
7
+ data.tar.gz: 7cecedebad2b68ee1be63707bce6a7ce8a551356b8a536a6d522d04c38474b0d90c389d2deacfe09a67d206997bc77f472d586f928e9372f7d0ba9b2c899d365
@@ -20,7 +20,7 @@ grammar TomlRB::Document
20
20
  ### Values
21
21
 
22
22
  rule inline_table
23
- (space? '{' (keyvalue? (',' keyvalue)*)? space? '}' ) <TomlRB::InlineTableParser>
23
+ (space? '{' array_comments (keyvalue (array_comments ',' array_comments keyvalue)* (array_comments ',')?)? array_comments '}' ) <TomlRB::InlineTableParser>
24
24
  end
25
25
 
26
26
  rule array
@@ -10,23 +10,23 @@ module TomlRB
10
10
  @symbolize_keys = false
11
11
  end
12
12
 
13
- def assign(hash, fully_defined_keys, symbolize_keys = false)
13
+ def assign(hash, fully_defined_paths, symbolize_keys = false)
14
14
  @symbolize_keys = symbolize_keys
15
- dotted_keys_str = @dotted_keys.join(".")
16
15
  keys = symbolize_keys ? @dotted_keys.map(&:to_sym) : @dotted_keys
16
+ depth = @dotted_keys.size
17
17
  update = keys.reverse.inject(visit_value(@value)) { |k1, k2| {k2 => k1} }
18
18
 
19
- parent_inline_table = fully_defined_keys.find { |k| dotted_keys_str.start_with?("#{k}.") }
19
+ parent_inline_table = fully_defined_paths.find { |k| k.size < depth && @dotted_keys.first(k.size) == k }
20
20
  fail ValueOverwriteError.new(@dotted_keys.first) if parent_inline_table
21
21
 
22
22
  if @value.is_a?(InlineTable)
23
- child_keys_exist = fully_defined_keys.find { |k| k.start_with?("#{dotted_keys_str}.") }
23
+ child_keys_exist = fully_defined_paths.find { |k| k.size > depth && k.first(depth) == @dotted_keys }
24
24
  fail ValueOverwriteError.new(@dotted_keys.first) if child_keys_exist
25
25
 
26
26
  existing_hash = hash.dig(*keys)
27
27
  fail ValueOverwriteError.new(@dotted_keys.first) if existing_hash.is_a?(Hash) && !existing_hash.empty?
28
28
 
29
- fully_defined_keys << dotted_keys_str
29
+ fully_defined_paths << @dotted_keys
30
30
  end
31
31
 
32
32
  dotted_key_merge(hash, update)
@@ -5,7 +5,7 @@ module TomlRB
5
5
  def initialize(content, symbolize_keys: false)
6
6
  @hash = {}
7
7
  @visited_keys = []
8
- @fully_defined_keys = []
8
+ @fully_defined_paths = []
9
9
  @current = @hash
10
10
  @symbolize_keys = symbolize_keys
11
11
 
@@ -28,7 +28,7 @@ module TomlRB
28
28
  # Read about the Visitor pattern
29
29
  # http://en.wikipedia.org/wiki/Visitor_pattern
30
30
  def visit_table_array(table_array)
31
- @fully_defined_keys = []
31
+ @fully_defined_paths = []
32
32
  table_array_key = table_array.full_key
33
33
  @visited_keys.reject! { |k| k.start_with? table_array_key }
34
34
 
@@ -36,12 +36,12 @@ module TomlRB
36
36
  end
37
37
 
38
38
  def visit_table(table)
39
- @fully_defined_keys = []
39
+ @fully_defined_paths = []
40
40
  @current = table.navigate_keys @hash, @visited_keys, @symbolize_keys
41
41
  end
42
42
 
43
43
  def visit_keyvalue(keyvalue)
44
- keyvalue.assign @current, @fully_defined_keys, @symbolize_keys
44
+ keyvalue.assign @current, @fully_defined_paths, @symbolize_keys
45
45
  end
46
46
  end
47
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TomlRB
4
- VERSION = "4.1.0"
4
+ VERSION = "4.2.0"
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toml-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Mancuso
8
8
  - Lucas Tolchinsky
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-10-29 00:00:00.000000000 Z
11
+ date: 2026-04-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: citrus
@@ -116,7 +115,6 @@ homepage: https://github.com/emancu/toml-rb
116
115
  licenses:
117
116
  - MIT
118
117
  metadata: {}
119
- post_install_message:
120
118
  rdoc_options: []
121
119
  require_paths:
122
120
  - lib
@@ -124,15 +122,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
122
  requirements:
125
123
  - - ">="
126
124
  - !ruby/object:Gem::Version
127
- version: '2.3'
125
+ version: '2.5'
128
126
  required_rubygems_version: !ruby/object:Gem::Requirement
129
127
  requirements:
130
128
  - - ">="
131
129
  - !ruby/object:Gem::Version
132
130
  version: '0'
133
131
  requirements: []
134
- rubygems_version: 3.1.6
135
- signing_key:
132
+ rubygems_version: 3.6.2
136
133
  specification_version: 4
137
134
  summary: Toml parser in ruby, for ruby.
138
135
  test_files: []