simple_parameter_store 0.1.1 → 0.2.0

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: 0071e4ef3cd71ae0a57df53926b5a7f2fbd5a7f20e1c6d68eefa895d508cb39b
4
- data.tar.gz: f128adff7f525f097cd0e5f04c8cfa6c89779aed514efc3b7515a5ff1804b4c4
3
+ metadata.gz: 4f8bc88322fc430919cc4eb79628ce142cd0e2194a0ac7c77cc7ce02acc3ce44
4
+ data.tar.gz: 1bbf1b7f83ef3fc9e2b8d8b717be07f195b142f64a6bd6960c10576bddf46cfc
5
5
  SHA512:
6
- metadata.gz: 656371046a106f78f958de51bbdbd83d43507947273068c12bfbd11530aafff57415a51594312a8c829736d3d9ff118d2aefb4bcd4b819ecfffe983ce6846b66
7
- data.tar.gz: cfd9696da27b114efabdfaea1d88e436d0c3826b0b9b9c6c97c8cfb7f1dafc0df1f4a2a90a87e9bc62d08a437e6dd3dc4e4594e841aae55c4b46ec7ee1221c42
6
+ metadata.gz: 3bb50891a011946d2d48ab795e48419b1a6f117f3f428bd1801058fb7cf6e3efda63189d47b11bc17a97736bde53533b59895a22602d816a187f9d1d96f644e4
7
+ data.tar.gz: 6c12a7522f797fb8b5d869e9dacfbb8964336638a2844d7cff2063a72238fd4770be3ef65189ff083c89b0a1ba783ea93931b36a7049a9b83b6962e911fde371
@@ -2,7 +2,8 @@ workflow "CI" {
2
2
  on = "push"
3
3
  resolves = [
4
4
  "CI - Ruby 2.5",
5
- "CI - Ruby 2.6"
5
+ "CI - Ruby 2.6",
6
+ "CI - Mutant"
6
7
  ]
7
8
  }
8
9
 
@@ -17,3 +18,9 @@ action "CI - Ruby 2.6" {
17
18
  runs = "bash"
18
19
  args = ["-c", "gem install bundler:2.0.1 && bundle && bundle exec rake test"]
19
20
  }
21
+
22
+ action "CI - Mutant" {
23
+ uses = "docker://ruby:2.6"
24
+ runs = "bash"
25
+ args = ["-c", "gem install bundler:2.0.1 && bundle && bundle exec mutant --use minitest --include test --include lib --require 'simple_parameter_store' -- 'SimpleParameterStore*'"]
26
+ }
data/Gemfile CHANGED
@@ -4,3 +4,9 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in simple_parameter_store.gemspec
6
6
  gemspec
7
+
8
+ gem 'mutant', github: 'mbj/mutant'
9
+
10
+ source 'https://6MzqeHoxySwKpgklFubwKEE80auW03cr@gem.mutant.dev' do
11
+ gem 'mutant-license'
12
+ end
data/Gemfile.lock CHANGED
@@ -1,12 +1,43 @@
1
+ GIT
2
+ remote: git://github.com/mbj/mutant.git
3
+ revision: c00534863309da874ee355d544bc44a30975a118
4
+ specs:
5
+ mutant (0.8.25)
6
+ abstract_type (~> 0.0.7)
7
+ adamantium (~> 0.2.0)
8
+ anima (~> 0.3.1)
9
+ ast (~> 2.2)
10
+ concord (~> 0.1.5)
11
+ diff-lcs (~> 1.3)
12
+ equalizer (~> 0.0.9)
13
+ ice_nine (~> 0.11.1)
14
+ memoizable (~> 0.4.2)
15
+ mutant-license (~> 0.0.1)
16
+ parser (~> 2.6.0)
17
+ procto (~> 0.0.2)
18
+ unparser (~> 0.4.3)
19
+ mutant-minitest (0.8.25)
20
+ minitest (~> 5.11)
21
+ mutant (~> 0.8.25)
22
+
1
23
  PATH
2
24
  remote: .
3
25
  specs:
4
- simple_parameter_store (0.1.1)
26
+ simple_parameter_store (0.2.0)
5
27
  aws-sdk-ssm
6
28
 
7
29
  GEM
8
30
  remote: https://rubygems.org/
31
+ remote: https://6MzqeHoxySwKpgklFubwKEE80auW03cr@gem.mutant.dev/
9
32
  specs:
33
+ abstract_type (0.0.7)
34
+ adamantium (0.2.0)
35
+ ice_nine (~> 0.11.0)
36
+ memoizable (~> 0.4.0)
37
+ anima (0.3.1)
38
+ abstract_type (~> 0.0.7)
39
+ adamantium (~> 0.2)
40
+ equalizer (~> 0.0.11)
10
41
  ast (2.4.0)
11
42
  aws-eventstream (1.0.3)
12
43
  aws-partitions (1.157.0)
@@ -20,12 +51,22 @@ GEM
20
51
  aws-sigv4 (~> 1.1)
21
52
  aws-sigv4 (1.1.0)
22
53
  aws-eventstream (~> 1.0, >= 1.0.2)
54
+ concord (0.1.5)
55
+ adamantium (~> 0.2.0)
56
+ equalizer (~> 0.0.9)
57
+ diff-lcs (1.3)
58
+ equalizer (0.0.11)
59
+ ice_nine (0.11.2)
23
60
  jaro_winkler (1.5.2)
24
61
  jmespath (1.4.0)
62
+ memoizable (0.4.2)
63
+ thread_safe (~> 0.3, >= 0.3.1)
25
64
  minitest (5.11.3)
65
+ mutant-license (0.0.1)
26
66
  parallel (1.17.0)
27
67
  parser (2.6.3.0)
28
68
  ast (~> 2.4.0)
69
+ procto (0.0.3)
29
70
  rainbow (3.0.0)
30
71
  rake (10.5.0)
31
72
  rubocop (0.68.1)
@@ -38,7 +79,16 @@ GEM
38
79
  rubocop-performance (1.1.0)
39
80
  rubocop (>= 0.67.0)
40
81
  ruby-progressbar (1.10.0)
82
+ thread_safe (0.3.6)
41
83
  unicode-display_width (1.5.0)
84
+ unparser (0.4.4)
85
+ abstract_type (~> 0.0.7)
86
+ adamantium (~> 0.2.0)
87
+ concord (~> 0.1.5)
88
+ diff-lcs (~> 1.3)
89
+ equalizer (~> 0.0.9)
90
+ parser (~> 2.6.2)
91
+ procto (~> 0.0.2)
42
92
 
43
93
  PLATFORMS
44
94
  ruby
@@ -46,6 +96,9 @@ PLATFORMS
46
96
  DEPENDENCIES
47
97
  bundler (~> 2.0)
48
98
  minitest (~> 5.0)
99
+ mutant!
100
+ mutant-license!
101
+ mutant-minitest
49
102
  rake (~> 10.0)
50
103
  rubocop
51
104
  rubocop-performance
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SimpleParameterStore
4
+ module Mock
5
+ class MockError < StandardError; end
6
+
7
+ class Parameter
8
+ attr_reader :name, :value
9
+ def initialize(name, value)
10
+ @name = name
11
+ @value = value
12
+ end
13
+ end
14
+
15
+ def self.prepended(base)
16
+ base.extend ClassMethods
17
+ end
18
+
19
+ private
20
+
21
+ def verify
22
+ %i[prefix decrypt expires_after client].each do |key|
23
+ current_value = instance_variable_get("@#{key}")
24
+ expected_value = self.class.mock.fetch(key)
25
+ raise MockError, <<~ERROR unless current_value.equal?(expected_value)
26
+ Invalid `:#{key}`:
27
+ expected: `#{expected_value}`
28
+ current: `#{current_value}`
29
+ ERROR
30
+ end
31
+ end
32
+
33
+ def fetch
34
+ verify
35
+
36
+ self.class.mock.fetch(:cache)
37
+ end
38
+
39
+ def build_client
40
+ :mocked_client
41
+ end
42
+
43
+ module ClassMethods
44
+ attr_reader :mock
45
+
46
+ def mock=(names:, client: nil, prefix: nil, decrypt: true, expires_after: nil)
47
+ @mock = {
48
+ cache: names.map { |(key, value)| Parameter.new("#{prefix}#{key}", value) },
49
+ prefix: prefix,
50
+ decrypt: decrypt,
51
+ expires_after: expires_after,
52
+ client: (client || :mocked_client)
53
+ }
54
+ end
55
+
56
+ def reset_mock
57
+ @mock = nil
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class SimpleParameterStore
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'simple_parameter_store/mock'
3
4
  require 'simple_parameter_store/version'
4
5
  require 'aws-sdk-ssm'
5
6
 
@@ -7,7 +8,7 @@ class SimpleParameterStore
7
8
  class SSMKeyError < KeyError; end
8
9
 
9
10
  def initialize(names:, client: nil, prefix: nil, decrypt: true, expires_after: nil)
10
- @client = client || Aws::SSM::Client.new
11
+ @client = client || build_client
11
12
  @prefix = prefix
12
13
  @decrypt = decrypt
13
14
  @expires_after = expires_after
@@ -23,7 +24,7 @@ class SimpleParameterStore
23
24
  attr_reader :client, :prefix, :decrypt, :expires_after, :expires_at
24
25
 
25
26
  def refresh
26
- fetch.parameters.each do |parameter|
27
+ fetch.each do |parameter|
27
28
  key, = @mappings.rassoc(parameter.name)
28
29
  caster = @casters.fetch(key)
29
30
  value = caster.call(parameter.value)
@@ -52,7 +53,7 @@ class SimpleParameterStore
52
53
  result = client.get_parameters(names: @mappings.values, with_decryption: decrypt)
53
54
  raise SSMKeyError, "Missing keys: `#{result.invalid_parameters}`" if result.invalid_parameters.any?
54
55
 
55
- result
56
+ result.parameters
56
57
  end
57
58
 
58
59
  def prepare(names)
@@ -61,4 +62,8 @@ class SimpleParameterStore
61
62
  @casters[key] = caster || :itself.to_proc
62
63
  end
63
64
  end
65
+
66
+ def build_client
67
+ Aws::SSM::Client.new
68
+ end
64
69
  end
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency 'bundler', '~> 2.0'
30
30
  spec.add_development_dependency 'minitest', '~> 5.0'
31
+ spec.add_development_dependency 'mutant'
32
+ spec.add_development_dependency 'mutant-minitest'
31
33
  spec.add_development_dependency 'rake', '~> 10.0'
32
34
  spec.add_development_dependency 'rubocop'
33
35
  spec.add_development_dependency 'rubocop-performance'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_parameter_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Schilling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ssm
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mutant
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mutant-minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: rake
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +140,7 @@ files:
112
140
  - bin/console
113
141
  - bin/setup
114
142
  - lib/simple_parameter_store.rb
143
+ - lib/simple_parameter_store/mock.rb
115
144
  - lib/simple_parameter_store/version.rb
116
145
  - simple_parameter_store.gemspec
117
146
  homepage: https://github.com/COMPEON/simple_parameter_store