patchyaml 0.1.0 → 0.1.2

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: cfc5b7ca990f2b4e504bcc910faad8efd99467aef4d53b58115c04c626e3a0c3
4
- data.tar.gz: 1d63195ee9f96395da68c3583d30249217db45c9add3c19a0435fd424b41f49f
3
+ metadata.gz: '09030d2cd8460fc135a5b74cc74277933efb7b9ba90c2cfa59fe14ea5de7496e'
4
+ data.tar.gz: 2ba8dddffcd1aa85adcaf10ae2aa92583a7ab10b61eb6c09be6771b9947adb33
5
5
  SHA512:
6
- metadata.gz: 408cbf60cfbcb5a5003744d506dfbc6ff7aa090f09e2c57968e8469f665eae07091c922c7c65d6d94cd975cacb5a953b585090143f02ddecb53e3f5237c2cbdd
7
- data.tar.gz: d9c9dad17bc67cad43748a63ca5f6e2125c50b17147974fbc5db65e21ccf7ed455b2e98be4736fa72677ec59a245efd2551e24ea454ff1fec4654a81da6d3f26
6
+ metadata.gz: 7e4d2de2e5ea6b51a40788003ca8284a5c73a025ddcc12c5f4cecb59359809ed055423e119fa2f7e16651ecdd93936feeca3cc1552b1db9a800f9965d7e31508
7
+ data.tar.gz: 0603fc03c1bbc826ddd80ec3f04d9cbf1d9a75ab065ce62e0485ad307add6146cf8ac9ef82430933aad3f02d02516343f6fb1cba33884fced9e447f98bf99b6a
@@ -9,6 +9,16 @@ module PatchYAML
9
9
  reload(data)
10
10
  end
11
11
 
12
+ # Determines whether a given path exists in the loaded YAML
13
+ #
14
+ # path - Path to be checked
15
+ #
16
+ # Returns true if the path exists, false otherwise.
17
+ def exist?(path)
18
+ value, parent = find(@stream, path)
19
+ !value.nil?
20
+ end
21
+
12
22
  # Deletes a given path from the yaml
13
23
  #
14
24
  # path - The path to the key to be deleted
@@ -8,7 +8,7 @@ module PatchYAML
8
8
  node = [from, nil]
9
9
  path.each do |part|
10
10
  node = find_node(node, part)
11
- return [] if node.empty?
11
+ return [] if node.nil? || node.empty?
12
12
  end
13
13
  node
14
14
  end
@@ -28,6 +28,8 @@ module PatchYAML
28
28
  raise "patchyaml: Unknown anchor #{from.anchor} defined by #{from.first}" unless node
29
29
 
30
30
  [find_node(node, part), node]
31
+ when NilClass
32
+ return []
31
33
  else
32
34
  raise "patchyaml: Unexpected node #{from.first.class} in #find_node"
33
35
  end
@@ -46,7 +48,7 @@ module PatchYAML
46
48
  v = from
47
49
  .first
48
50
  .children
49
- .find { it.is_a?(Psych::Nodes::Mapping) && find_mapping_key(it, part[:key]).value == part[:value] }
51
+ .find { it.is_a?(Psych::Nodes::Mapping) && find_mapping_key(it, part[:key]).first.value == part[:value] }
50
52
  [v, from]
51
53
  end
52
54
  end
@@ -78,7 +78,7 @@ module PatchYAML
78
78
  end.sum
79
79
  end
80
80
 
81
- @data = @data[...start_at].concat(@data[end_at...])
81
+ @data = @data[...start_at].concat(@data[end_at...] || "")
82
82
  else
83
83
  raise Error, "patchyaml: BUG: cannot delete object from #{parent.class}"
84
84
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Patchyaml
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patchyaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vito Sartori
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-08-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: YAML Editor Utility Library
13
13
  email:
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
- rubygems_version: 3.6.2
54
+ rubygems_version: 3.6.7
55
55
  specification_version: 4
56
56
  summary: YAML Editor Utility Library
57
57
  test_files: []