cfa 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed36ef61432f274fddde803ec94e699e1cdaa96c
4
- data.tar.gz: 5ab4d242ebbbec5a794ed6b2309d76396f7a69ee
3
+ metadata.gz: 20d0d56ba26b5b824817fedbd1dd5111952bfc15
4
+ data.tar.gz: a3d8b0c17b1727c18ee25aea940db711a7d5714c
5
5
  SHA512:
6
- metadata.gz: b7f9e87b62d41a80f332c123317a3ab01368ea2c32c544b7338b3dd0977f9fe3d1ed28e5c8807c58a9ec50bdf3b77a3c9eb029a3ce2c56bb01fe634b646bfdda
7
- data.tar.gz: c60aa0011596224752a97a0b8ecc6df8b883603e9c559df15920d3609ff9f763eec59c988bd8eca884938e83ffb6c0359145a3646863fd7c57ee88707c5363b8
6
+ metadata.gz: aa97b3fed3d901bc8901d58d57b4612d4455b0a4552d4e90c190865c0a1bd62627ff8e36accf05cbb8efa9855b8b36a2551de482ce31451f85dfd3eb70f47138
7
+ data.tar.gz: f6a930470d3151060eb00e0f24d5f7cbb0db0f103e13ab84997a7dc04fef1098cd99d0cdf5b949061174cbf386fbefa42328270beb1ba9e2b655c40bdf68a1df
@@ -147,7 +147,7 @@ module CFA
147
147
  # @return [Array<Hash{Symbol => Object}>] a frozen array as it is
148
148
  # just a copy of the real data
149
149
  def data
150
- @data.select { |e| e[:operation] != :remove }.freeze
150
+ @data.reject { |e| e[:operation] == :remove }.freeze
151
151
  end
152
152
 
153
153
  # low level access to all AugeasElement including ones marked for removal
@@ -238,8 +238,10 @@ module CFA
238
238
  return false if self.class != other.class
239
239
  other_data = other.data # do not compute again
240
240
  data.each_with_index do |entry, index|
241
- return false if entry[:key] != other_data[index][:key]
242
- return false if entry[:value] != other_data[index][:value]
241
+ other_entry = other_data[index]
242
+ return false unless other_entry
243
+ return false if entry[:key] != other_entry[:key]
244
+ return false if entry[:value] != other_entry[:value]
243
245
  end
244
246
 
245
247
  true
@@ -236,11 +236,13 @@ module CFA
236
236
  # @see https://github.com/hercules-team/augeas/wiki/Path-expressions
237
237
  def set_new_value(path, located_entry)
238
238
  aug.set(path, located_entry.entry_value)
239
- prefix = path[/(^.*)\[[^\]]*\]/, 1] || path
240
- # we need to get new path as set can look like [last() + 1]
241
- # which creates new entry and we do not want to add subtree to new
242
- # entries
243
- new_path = aug.match(prefix + "[last()]").first
239
+ # we need to get new path as path used in aug.set can contains
240
+ # "[last() + 1]", so adding subtree to it, adds additional entry.
241
+ # So here, we replace "[last() + 1]" with "[last()]" so it will match
242
+ # path created by previous aug.set
243
+ match_str = path.gsub(/\[\s*last\(\)\s*\+\s*1\]/, "[last()]")
244
+
245
+ new_path = aug.match(match_str).first
244
246
  add_subtree(located_entry.entry_tree, new_path)
245
247
  end
246
248
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Reidinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-augeas