valise 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/valise/set/extensions-decorator.rb +8 -0
- data/lib/valise/stack.rb +3 -3
- data/lib/valise/stack/decorator.rb +7 -9
- data/lib/valise/stack/extensions-decorator.rb +29 -3
- data/lib/valise/stack/prefixes-decorator.rb +28 -2
- data/lib/valise/strategies/merge-diff.rb +2 -2
- data/lib/valise/utils.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 455879a100dafe54e0baa03a50d495b22bc34e78
|
4
|
+
data.tar.gz: 3fb179de644e34d38e4680bd50f730fc824c0cc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b35098b0c0587b040bb0bbeee1f7e1b2c2f41d9c28e4bf5f7753449a88909a969297f3d7fb887ed1690034f12a9cf557748d3c4af5b88a8ea9f09bde296ba19f
|
7
|
+
data.tar.gz: e1acc62569e4318f638ef414753380f88ca4a250db916ca4cdb67138ee2204b5090a4be3ab5195d7b02d0b0f01d08f745d5bcc2b98ab5ae0d2eab9f3d1138d45
|
@@ -21,6 +21,14 @@ module Valise
|
|
21
21
|
def serialization
|
22
22
|
set.serialization
|
23
23
|
end
|
24
|
+
|
25
|
+
def add_serialization_handler(pattern, serializer, options = nil)
|
26
|
+
set.add_serialization_handler(pattern, serializer, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_merge_handler(pattern, merger, options = nil)
|
30
|
+
set.add_merge_handler(pattern, merger, options)
|
31
|
+
end
|
24
32
|
end
|
25
33
|
|
26
34
|
class PrefixesDecorator < Decorator
|
data/lib/valise/stack.rb
CHANGED
@@ -25,11 +25,11 @@ module Valise
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def merge_diff
|
28
|
-
|
28
|
+
valise.merge_diff_for(self)
|
29
29
|
end
|
30
30
|
|
31
31
|
def dump_load
|
32
|
-
|
32
|
+
valise.serialization_for(self)
|
33
33
|
end
|
34
34
|
|
35
35
|
def merged(item)
|
@@ -81,7 +81,7 @@ module Valise
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def reget(root)
|
84
|
-
root.get(
|
84
|
+
root.get(segments)
|
85
85
|
end
|
86
86
|
|
87
87
|
def item_for(root)
|
@@ -5,21 +5,19 @@ module Valise
|
|
5
5
|
class Decorator < Stack
|
6
6
|
def initialize(stack)
|
7
7
|
@stack = stack
|
8
|
-
@stacks =
|
9
|
-
h[segments] = @stack.valise.get(segments)
|
10
|
-
end
|
8
|
+
@stacks = {}
|
11
9
|
end
|
12
10
|
|
13
|
-
def
|
14
|
-
@stack.valise
|
11
|
+
def sub_stack(segments)
|
12
|
+
@stacks[segments] ||= @stack.valise.get(segments)
|
15
13
|
end
|
16
14
|
|
17
|
-
def
|
18
|
-
|
15
|
+
def segments
|
16
|
+
@stack.segments
|
19
17
|
end
|
20
18
|
|
21
|
-
def
|
22
|
-
|
19
|
+
def valise
|
20
|
+
@stack.valise
|
23
21
|
end
|
24
22
|
|
25
23
|
def rel_path
|
@@ -14,18 +14,44 @@ module Valise
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def reget(root)
|
17
|
-
decorated = self.new(super)
|
17
|
+
decorated = self.class.new(super(root))
|
18
18
|
decorated.extensions = self.extensions
|
19
19
|
decorated
|
20
20
|
end
|
21
21
|
|
22
|
+
def sub_stack(stack, ext)
|
23
|
+
SingleExtensionDecorator.new(stack, self, ext)
|
24
|
+
end
|
25
|
+
|
22
26
|
def decorate_item(item)
|
23
|
-
dir, file = *item.segments.split
|
24
27
|
@extensions.each do |ext|
|
25
|
-
ext_stack =
|
28
|
+
ext_stack = sub_stack(item.stack, ext)
|
26
29
|
yield(ext_stack.item_for(item.root))
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
33
|
+
|
34
|
+
class SingleExtensionDecorator < Decorator
|
35
|
+
def initialize(stack, lead_decco, ext)
|
36
|
+
super(stack)
|
37
|
+
@leader = lead_decco
|
38
|
+
@ext = ext
|
39
|
+
|
40
|
+
dir, file = *(stack.segments.split.map(&:to_s))
|
41
|
+
@segments = make_pathname([dir, (file.to_s + ext)])
|
42
|
+
end
|
43
|
+
|
44
|
+
def inspect
|
45
|
+
@stack.inspect + @ext
|
46
|
+
end
|
47
|
+
|
48
|
+
def segments
|
49
|
+
@segments
|
50
|
+
end
|
51
|
+
|
52
|
+
def reget(root)
|
53
|
+
@leader.reget(root)
|
54
|
+
end
|
55
|
+
end
|
30
56
|
end
|
31
57
|
end
|
@@ -19,13 +19,39 @@ module Valise
|
|
19
19
|
decorated
|
20
20
|
end
|
21
21
|
|
22
|
+
def sub_stack(stack, pfx)
|
23
|
+
SinglePrefixDecorator.new(stack, self, pfx)
|
24
|
+
end
|
25
|
+
|
22
26
|
def decorate_item(item)
|
23
|
-
dir, file = *item.segments.split
|
24
27
|
@prefixes.each do |pfx|
|
25
|
-
dec_stack =
|
28
|
+
dec_stack = sub_stack(item.stack, pfx)
|
26
29
|
yield(dec_stack.item_for(item.root))
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
33
|
+
|
34
|
+
class SinglePrefixDecorator < Decorator
|
35
|
+
def initialize(stack, lead_decco, pfx)
|
36
|
+
super(stack)
|
37
|
+
@leader = lead_decco
|
38
|
+
@pfx = pfx
|
39
|
+
|
40
|
+
dir, file = *(stack.segments.split.map(&:to_s))
|
41
|
+
@segments = make_pathname([dir, (pfx + file.to_s)])
|
42
|
+
end
|
43
|
+
|
44
|
+
def inspect
|
45
|
+
@stack.inspect + "^#@pfx"
|
46
|
+
end
|
47
|
+
|
48
|
+
def segments
|
49
|
+
@segments
|
50
|
+
end
|
51
|
+
|
52
|
+
def reget(root)
|
53
|
+
@leader.reget(root)
|
54
|
+
end
|
55
|
+
end
|
30
56
|
end
|
31
57
|
end
|
@@ -24,11 +24,11 @@ module Valise
|
|
24
24
|
register :hash_merge
|
25
25
|
|
26
26
|
def merge(item)
|
27
|
-
merge_stack(@stack.not_above(item)
|
27
|
+
merge_stack(@stack.not_above(item))
|
28
28
|
end
|
29
29
|
|
30
30
|
def merge_stack(stack)
|
31
|
-
stack.present.inject({}) do |hash, item|
|
31
|
+
stack.present.reverse_each.inject({}) do |hash, item|
|
32
32
|
deep_merge(hash, item.load_contents)
|
33
33
|
end
|
34
34
|
end
|
data/lib/valise/utils.rb
CHANGED
@@ -129,7 +129,7 @@ module Valise
|
|
129
129
|
when ::File
|
130
130
|
parts = parts.path
|
131
131
|
else
|
132
|
-
raise ArgumentError, "path must be String, Array of Strings or File"
|
132
|
+
raise ArgumentError, "path must be String, Array of Strings or File, was: #{parts.inspect} (#{parts.class})"
|
133
133
|
end
|
134
134
|
pathname = clean_pathname(Pathname.new(parts))
|
135
135
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Judson Lester
|
@@ -210,7 +210,7 @@ rdoc_options:
|
|
210
210
|
- --main
|
211
211
|
- doc/README
|
212
212
|
- --title
|
213
|
-
- valise-1.1.
|
213
|
+
- valise-1.1.4 RDoc
|
214
214
|
require_paths:
|
215
215
|
- lib/
|
216
216
|
required_ruby_version: !ruby/object:Gem::Requirement
|