knowledge-ssm 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: ff1d12d1fcdad26b496cdc51abdb22dc98528f518338a9ee1959b8792da4ee10
4
- data.tar.gz: '00866e3590c120a8c2d7d6500186012d2850f6eb06a9cafc254741cecdcab2de'
3
+ metadata.gz: a247ac1c241b6a540326bc19cbd52b4a1c792813aa3c437eb0d573309f94bac1
4
+ data.tar.gz: 5d0df0fdd47591028b44bf6b3a144f06215a493ca35022a82f120a02cb9ef3da
5
5
  SHA512:
6
- metadata.gz: 789883aa2ef2ea21e993e1e8dfac6de5016196ba3ba6636b69f411b94e41e8d1d4746e1753788f5fa337ea1947d7f443d700b9dee91ddf11f42191b9348753a3
7
- data.tar.gz: 79065e2c1d9b2510e4a70520805732a9f5675b85f1613da6252c3ec5effa6e9ac44aa104a74584d64d60640d495649d046fa070ddb95735ddba2906899a5a616
6
+ metadata.gz: 65e98af286c1cf76e622becddedddb07e893f45abebbade4b80831cf8b1e3fac9432defd3cd9cc08fb5217bd537655bfa253038424b9eccc0a2b0e984e0d5f9f
7
+ data.tar.gz: c6a7e1e0ef9d441f41827df2da61bbf295b8338c8b23b70b560fd8a7aef47179b09010ebaf10885eb7c334345581175794ef5a09480e3359a19f6f3b470acc3a
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
37
  spec.require_paths = ['lib']
38
38
 
39
- spec.add_dependency 'knowledge', '~> 0.1'
39
+ spec.add_dependency 'knowledge', '>= 0.1.3'
40
40
 
41
41
  spec.add_development_dependency 'aws-sdk-ssm', '~> 1'
42
42
  spec.add_development_dependency 'bundler', '~> 1.16'
@@ -30,7 +30,7 @@ module Knowledge
30
30
  #
31
31
  class Ssm < Base
32
32
  # == Attributes ==================================================================================================
33
-
33
+
34
34
  # Defines whether we should raise an error on param not found or not
35
35
  attr_reader :raise_not_found
36
36
 
@@ -41,7 +41,7 @@ module Knowledge
41
41
  attr_reader :ssm_parameters
42
42
 
43
43
  # == Constructor =================================================================================================
44
-
44
+
45
45
  #
46
46
  # @param [Hash] :params
47
47
  # @option params [Aws::SSM::Client] :client
@@ -66,7 +66,6 @@ module Knowledge
66
66
  #
67
67
  def run
68
68
  variables.each do |name, (path, default_value)|
69
- base_path = root_path[0..-2] if root_path&.end_with?('/')
70
69
  path = "/#{path.sub('/', '')}"
71
70
  value = Array(@ssm_parameters).detect { |p| p.name == "#{base_path}#{path}" }&.value
72
71
 
@@ -76,6 +75,43 @@ module Knowledge
76
75
 
77
76
  protected
78
77
 
78
+ #
79
+ # Memoized, well formatted base path
80
+ #
81
+ # === Parameters
82
+ #
83
+ # @return [String]
84
+ #
85
+ def base_path
86
+ @base_path ||= root_path[0..-2] if root_path&.end_with?('/')
87
+ end
88
+
89
+ #
90
+ # Checks if a value is nil or empty
91
+ #
92
+ # === Parameters
93
+ #
94
+ # @param [Any] value
95
+ #
96
+ # @return [Boolean]
97
+ #
98
+ def blank?(value)
99
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
100
+ end
101
+
102
+ #
103
+ # Checks if a value is a boolean value
104
+ #
105
+ # === Parameters
106
+ #
107
+ # @param [Any] value
108
+ #
109
+ # @return [Boolean]
110
+ #
111
+ def boolean?(value)
112
+ value == !!value # rubocop:disable Style/DoubleNegation
113
+ end
114
+
79
115
  #
80
116
  # Credentials for AWS should be loaded from the ENV vars by the client itself.
81
117
  # Authorization is done automatically according to the current AWS policies.
@@ -108,13 +144,13 @@ module Knowledge
108
144
  return initial_value if default_value.nil?
109
145
 
110
146
  # If boolean value
111
- return initial_value if initial_value == !!initial_value
147
+ return initial_value if boolean?(initial_value)
112
148
 
113
149
  # If number
114
- return initial_value if initial_value.respond_to?(:to_f) && initial_value.to_f == initial_value
115
-
150
+ return initial_value if initial_value.is_a?(Numeric)
151
+
116
152
  # If initial value nil or empty
117
- return default_value if initial_value.nil? || (initial_value.respond_to?(:empty?) && initial_value.empty?)
153
+ return default_value if blank?(initial_value)
118
154
 
119
155
  initial_value
120
156
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Knowledge
4
4
  module Ssm
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knowledge-ssm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johann Wilfrid-Calixte
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: knowledge
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: 0.1.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: 0.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aws-sdk-ssm
29
29
  requirement: !ruby/object:Gem::Requirement