kuber_kit 0.6.3 → 0.6.4
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/kuber_kit/core/context_helper/context_vars.rb +39 -18
- data/lib/kuber_kit/version.rb +1 -1
- 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: 47a6af30e186e24f434c1d5a777a169eb089e0491177127f4824cfa8af89b0d3
|
4
|
+
data.tar.gz: 8ef8e5deeee25dc255e4b1700b9d2c6afe7be5ae34ce0a5a6565e1b6a8092759
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2307096ca0a11b96a8fa64b31b2611e7fc15c6de8838076ded727f3d1e6ac9541d3f6c3152c84472500b376c0cae5d322b2a6021657a4a0d28aed7c5da5e5579
|
7
|
+
data.tar.gz: b8e527ab441c2b2c420728ca670bfeefb094b4fbc0233cb15dea237d0cb7e4fae9a2345f2026c46cb1d528f6e21044d3da0d883cfdb200c16ac6f56777a014de
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,35 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::ContextVars
|
2
2
|
attr_reader :parent, :parent_name
|
3
3
|
|
4
|
+
BuildArgUndefined = Class.new(KuberKit::Error)
|
5
|
+
|
4
6
|
def initialize(context_vars, parent_name = nil, parent = nil)
|
5
7
|
@context_vars = context_vars
|
6
8
|
@parent_name = parent_name
|
7
9
|
@parent = parent
|
8
10
|
end
|
9
11
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
12
|
+
def read(*variable_names)
|
13
|
+
result = self
|
14
|
+
variable_names.each do |var|
|
15
|
+
result = result.get_variable_value(var)
|
13
16
|
end
|
17
|
+
result
|
18
|
+
end
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
def variable_defined?(*variable_names)
|
21
|
+
read(*variable_names)
|
22
|
+
return true
|
23
|
+
rescue BuildArgUndefined
|
24
|
+
return false
|
25
|
+
end
|
18
26
|
|
19
|
-
|
20
|
-
|
27
|
+
def method_missing(name, *args)
|
28
|
+
if args.size > 0
|
29
|
+
raise ArgumentError.new("context args does not accept any arguments")
|
21
30
|
end
|
22
31
|
|
23
|
-
|
32
|
+
read(name)
|
24
33
|
end
|
25
34
|
|
26
35
|
def to_h
|
@@ -31,17 +40,29 @@ class KuberKit::Core::ContextHelper::ContextVars
|
|
31
40
|
end
|
32
41
|
end
|
33
42
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
parent = @parent
|
43
|
+
def get_variable_value(variable_name)
|
44
|
+
value = @context_vars.fetch(variable_name) do
|
45
|
+
raise(BuildArgUndefined, "build arg '#{format_arg(variable_name)}' is not defined, available args: #{@context_vars.inspect}")
|
46
|
+
end
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
parent = parent.parent
|
48
|
+
if value.is_a?(Hash)
|
49
|
+
return self.class.new(value, variable_name, self)
|
43
50
|
end
|
44
51
|
|
45
|
-
|
52
|
+
value
|
46
53
|
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def format_arg(name)
|
58
|
+
string = [@parent_name, name].compact.join(".")
|
59
|
+
parent = @parent
|
60
|
+
|
61
|
+
while parent do
|
62
|
+
string = [parent.parent_name, string].compact.join(".")
|
63
|
+
parent = parent.parent
|
64
|
+
end
|
65
|
+
|
66
|
+
string
|
67
|
+
end
|
47
68
|
end
|
data/lib/kuber_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuber_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|