cfa 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cfa/augeas_parser/writer.rb +29 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd707324d0e3ad8265613743072f4557a1907be8c4db9074e323134eaa7acfe6
|
4
|
+
data.tar.gz: 0a7fc0fb5020ce4edbad0f47f6124b28904fdd039f8ccf0382e7781688f35a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5b04935b9112cad8cbe806d6a23d3933d27c1ee2a6c0d198e92a30a72e493d9034883424e1e46301b740eea7e49f6324ec3d7c760ca0cc58c1f13e487d9e53b
|
7
|
+
data.tar.gz: 42c7343d2933ad4ef95d363ccbaf55d9d366d35ef98eb7cc0dfc4d506b52f2cc0044f085afd0bb9754c9653f47fde430eeb332e23e8f66b84410a09819f02bad
|
@@ -301,12 +301,35 @@ module CFA
|
|
301
301
|
# @param preceding [LocatedEntry]
|
302
302
|
def path_after(preceding)
|
303
303
|
paths = aug.match(preceding.prefix + "/*")
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
304
|
+
paths[find_preceding_index(paths, preceding) + 1]
|
305
|
+
end
|
306
|
+
|
307
|
+
def find_preceding_index(paths, preceding)
|
308
|
+
path = preceding.path
|
309
|
+
# common case, just included
|
310
|
+
return paths.index(path) if paths.include?(path)
|
311
|
+
|
312
|
+
# not found, so it means that some collection or single entry switch
|
313
|
+
new_path = +"/"
|
314
|
+
path.split("/").each do |element|
|
315
|
+
new_path << "/" unless new_path.end_with?("/")
|
316
|
+
new_path << pick_candidate(paths, new_path, element)
|
317
|
+
end
|
318
|
+
|
319
|
+
paths.index(new_path) ||
|
320
|
+
raise("Cannot find path #{preceding.path} in #{paths.inspect}")
|
321
|
+
end
|
322
|
+
|
323
|
+
# it returns variant of element that exists in path
|
324
|
+
def pick_candidate(paths, new_path, element)
|
325
|
+
# NOTE: order here is important due to early matching
|
326
|
+
candidates = [element + "/", element + "[1]",
|
327
|
+
element.sub(/\[\d+\]/, ""), element]
|
328
|
+
paths.each do |p|
|
329
|
+
candidates.each do |c|
|
330
|
+
return c if p.start_with?(new_path + c)
|
331
|
+
end
|
332
|
+
end
|
310
333
|
end
|
311
334
|
end
|
312
335
|
|
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: 1.0.
|
4
|
+
version: 1.0.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: 2019-
|
11
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-augeas
|