param_store 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 333fc97381cc05055d9111ff26983d53d34fe14964c3498c21b0c4d182dc64e3
4
+ data.tar.gz: 3d08af6a980db816dda1149254674332f3fd7a0cf050924542377872b31688ea
5
+ SHA512:
6
+ metadata.gz: d548fbcd4dbe959756ed0721e3d9c7b64159fea2dcf30b4fe1c779770fe11d2f36bd0a1071353aeaeba547e29428ae33c7f86a7b25c91b42e85c00b1793207c4
7
+ data.tar.gz: '080a2b1a10b421e327474adb36ea24f49ed60e17209eb3883c3894e9f0082677f84320ac978e55826a73a329b5314a61960b1dd184c826cfb2de18ae93d4c95b'
@@ -0,0 +1,57 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.4.1-node-browsers
11
+
12
+ # Specify service dependencies here if necessary
13
+ # CircleCI maintains a library of pre-built images
14
+ # documented at https://circleci.com/docs/2.0/circleci-images/
15
+ # - image: circleci/postgres:9.4
16
+
17
+ working_directory: ~/repo
18
+
19
+ steps:
20
+ - checkout
21
+
22
+ # Download and cache dependencies
23
+ - restore_cache:
24
+ keys:
25
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
26
+ # fallback to using the latest cache if no exact match is found
27
+ - v1-dependencies-
28
+
29
+ - run:
30
+ name: install dependencies
31
+ command: |
32
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
33
+
34
+ - save_cache:
35
+ paths:
36
+ - ./vendor/bundle
37
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
38
+
39
+ # run tests!
40
+ - run:
41
+ name: run tests
42
+ command: |
43
+ mkdir /tmp/test-results
44
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
45
+
46
+ bundle exec rspec --format progress \
47
+ --format RspecJunitFormatter \
48
+ --out /tmp/test-results/rspec.xml \
49
+ --format progress \
50
+ $TEST_FILES
51
+
52
+ # collect reports
53
+ - store_test_results:
54
+ path: /tmp/test-results
55
+ - store_artifacts:
56
+ path: /tmp/test-results
57
+ destination: test-results
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,122 @@
1
+ AllCops:
2
+ Exclude:
3
+ - '**/Gemfile'
4
+ TargetRubyVersion: 2.2
5
+
6
+ Metrics/PerceivedComplexity:
7
+ Enabled: false
8
+
9
+ Metrics/CyclomaticComplexity:
10
+ Enabled: false
11
+
12
+ Metrics/ClassLength:
13
+ Enabled: false
14
+
15
+ Metrics/ParameterLists:
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: false
20
+
21
+ Metrics/AbcSize:
22
+ # Disable "Assignment Branch Condition size for update_attributes is too high" from houndci
23
+ # because codeclimate already give that for us with more details
24
+ Enabled: false
25
+
26
+ Metrics/LineLength:
27
+ Max: 125
28
+
29
+ Style/Alias:
30
+ Enabled: false
31
+
32
+ Style/PerlBackrefs:
33
+ Enabled: false
34
+
35
+ Layout/TrailingBlankLines:
36
+ Enabled: false
37
+
38
+ # Override the HoundCI custom rules (they do not use Rubocop defaults)
39
+ Style/StringLiterals:
40
+ EnforcedStyle: single_quotes
41
+
42
+ Style/StringLiteralsInInterpolation:
43
+ EnforcedStyle: single_quotes
44
+
45
+ Layout/ExtraSpacing:
46
+ # disabling that in favour of using:
47
+ # long_field_test_1 = 1
48
+ # field_test_2 = 2
49
+ # etc = 3
50
+ Enabled: false
51
+
52
+ Style/BlockDelimiters:
53
+ Enabled: false
54
+
55
+ Style/CollectionMethods:
56
+ Enabled: false
57
+
58
+ Style/SignalException:
59
+ Enabled: false
60
+
61
+ Style/Documentation:
62
+ Enabled: false
63
+
64
+ Style/ClassAndModuleChildren:
65
+ Enabled: false
66
+
67
+ Style/CommentAnnotation:
68
+ Enabled: false
69
+
70
+ Layout/DotPosition:
71
+ EnforcedStyle: leading
72
+
73
+ Style/GuardClause:
74
+ Enabled: false
75
+
76
+ Style/RegexpLiteral:
77
+ Enabled: false
78
+
79
+ Lint/HandleExceptions:
80
+ Enabled: false
81
+
82
+ Lint/AssignmentInCondition:
83
+ Enabled: false
84
+
85
+ Style/DoubleNegation:
86
+ Enabled: false
87
+
88
+ Style/AndOr:
89
+ Enabled: false
90
+
91
+ Style/ClassVars:
92
+ Enabled: false
93
+
94
+ Style/GlobalVars:
95
+ Enabled: false
96
+
97
+ Style/SingleLineBlockParams:
98
+ Enabled: false
99
+
100
+ Style/RescueModifier:
101
+ Enabled: false
102
+
103
+ Style/ColonMethodCall:
104
+ Enabled: false
105
+
106
+ Naming/FileName:
107
+ Enabled: false
108
+
109
+ Style/FrozenStringLiteralComment:
110
+ Enabled: false
111
+
112
+ Style/RescueStandardError:
113
+ Enabled: false
114
+
115
+ Security/YAMLLoad:
116
+ Enabled: false
117
+
118
+ Naming/MemoizedInstanceVariableName:
119
+ Enabled: false
120
+
121
+ Performance/RedundantBlockCall:
122
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.4
7
+ before_install: gem install bundler -v 1.16.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at pablohstc@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in param_store.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem 'pry-byebug'
10
+ end
11
+
12
+ group :test do
13
+ gem 'rspec', '~> 3.0'
14
+ gem 'rspec_junit_formatter'
15
+ gem 'stub_env'
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ param_store (0.0.1)
5
+ aws-sdk-ssm (~> 1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aws-eventstream (1.0.1)
11
+ aws-partitions (1.127.0)
12
+ aws-sdk-core (3.44.1)
13
+ aws-eventstream (~> 1.0)
14
+ aws-partitions (~> 1.0)
15
+ aws-sigv4 (~> 1.0)
16
+ jmespath (~> 1.0)
17
+ aws-sdk-ssm (1.34.0)
18
+ aws-sdk-core (~> 3, >= 3.39.0)
19
+ aws-sigv4 (~> 1.0)
20
+ aws-sigv4 (1.0.3)
21
+ byebug (10.0.2)
22
+ coderay (1.1.2)
23
+ diff-lcs (1.3)
24
+ jmespath (1.4.0)
25
+ method_source (0.9.2)
26
+ pry (0.12.2)
27
+ coderay (~> 1.1.0)
28
+ method_source (~> 0.9.0)
29
+ pry-byebug (3.6.0)
30
+ byebug (~> 10.0)
31
+ pry (~> 0.10)
32
+ rake (10.4.2)
33
+ rspec (3.8.0)
34
+ rspec-core (~> 3.8.0)
35
+ rspec-expectations (~> 3.8.0)
36
+ rspec-mocks (~> 3.8.0)
37
+ rspec-core (3.8.0)
38
+ rspec-support (~> 3.8.0)
39
+ rspec-expectations (3.8.2)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-mocks (3.8.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.8.0)
45
+ rspec-support (3.8.0)
46
+ rspec_junit_formatter (0.4.1)
47
+ rspec-core (>= 2, < 4, != 2.12.0)
48
+ stub_env (1.0.4)
49
+ rspec (>= 2.0, < 4.0)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ bundler (~> 1.16)
56
+ param_store!
57
+ pry-byebug
58
+ rake (~> 10.0)
59
+ rspec (~> 3.0)
60
+ rspec_junit_formatter
61
+ stub_env
62
+
63
+ BUNDLED WITH
64
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Pablo Cantero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,106 @@
1
+ [![CircleCI](https://circleci.com/gh/phstc/param_store.svg?style=svg)](https://circleci.com/gh/phstc/param_store)
2
+
3
+ # ParamStore
4
+
5
+ This gem goal is to <strike>DRY some code I have been copying around for a while</strike> make easy switching in between ENV and [AWS Parameter Store (SSM)](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html) for retrieving parameters.
6
+
7
+ This gem is not a replacement for [dotenv](https://github.com/bkeepers/dotenv). I still use and recommend it in development, in case it is "safe" to save your keys in `.env` files. Otherwise, you could also use AWS Parameter Store for development.
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'param_store'
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ For switching in between ENV and SSM, you need you set which adapter you want to use.
21
+
22
+ ```ruby
23
+ # read from SSM
24
+ # i.e. config/environments/production.rb
25
+ ParamStore.adapter = :aws_ssm
26
+ # default path for SSM Hierarchies
27
+ # see https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-su-organize.html
28
+ ParamStore.path = '/Environment/Type of computer/Application/'
29
+
30
+ # read from ENV
31
+ # i.e. config/environments/[development, test].rb
32
+ ParamStore.adapter = :env
33
+ ```
34
+
35
+ For retrieving parameters:
36
+
37
+ ```ruby
38
+ # fetch is similar to Hash#fetch,
39
+ # if the key is not found and there's no default defined, it raises an error
40
+ ParamStore.fetch('my_secret_key')
41
+ ```
42
+
43
+ ### SSM to ENV
44
+
45
+ You can also make SSM compatible with `ENV` by copying parameters to `ENV`.
46
+
47
+ ```ruby
48
+ # i.e. config/application.rb
49
+ # Bundler.require(*Rails.groups)
50
+ ParamStore.copy_to_env('key1', 'key2', 'key3')
51
+
52
+ ENV['key1'] # => value for key1
53
+ ENV['key2'] # => value for key2
54
+ ENV['key3'] # => value for key3
55
+ ```
56
+
57
+ ### SSM client
58
+
59
+ By default `ParamStore` will initiate `Aws::SSM::Client.new` without supplying any parameter. If you want to control the initiation of the SSM client, you can define it by setting `ssm_client`.
60
+
61
+
62
+ ```ruby
63
+ ParamStore.ssm_client = Aws::SSM::Client.new(
64
+ region: region_name,
65
+ credentials: credentials,
66
+ # ...
67
+ )
68
+ ```
69
+
70
+ ### Fail-fast
71
+
72
+ You can configure the required parameters for an app and fail at startup.
73
+
74
+ ```ruby
75
+ # i.e. config/application.rb
76
+ # Bundler.require(*Rails.groups)
77
+ ParamStore.require_keys!('key1', 'key2', 'key3')
78
+ ```
79
+
80
+ #### aws ssm
81
+
82
+ A few useful [aws ssm](https://docs.aws.amazon.com/cli/latest/reference/ssm/index.html) commands:
83
+
84
+ ```sh
85
+ aws ssm get-parameters-by-path --path /Prod/ERP/SAP --with-decryption
86
+ aws ssm put-parameter --name /Prod/ERP/SAP --value ... --type SecureString
87
+ ```
88
+
89
+
90
+ ## Development
91
+
92
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
93
+
94
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
+
96
+ ## Contributing
97
+
98
+ Bug reports and pull requests are welcome on GitHub at https://github.com/phstc/param_store. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
99
+
100
+ ## License
101
+
102
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
103
+
104
+ ## Code of Conduct
105
+
106
+ Everyone interacting in the ParamStore project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/phstc/param_store/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "param_store"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,43 @@
1
+ require 'aws-sdk-ssm'
2
+ require 'forwardable'
3
+
4
+ require 'param_store/version'
5
+ require 'param_store/wrapper'
6
+ require 'param_store/adapters/env'
7
+ require 'param_store/adapters/ssm'
8
+
9
+ module ParamStore
10
+ extend SingleForwardable
11
+
12
+ def_delegators(
13
+ :'@wrapper',
14
+ :fetch,
15
+ :copy_to_env,
16
+ :require_keys!
17
+ )
18
+
19
+ class << self
20
+ attr_accessor :path
21
+ attr_reader :adapter, :wrapper
22
+
23
+ def ssm_client
24
+ @_ssm_client ||= Aws::SSM::Client.new
25
+ end
26
+
27
+ def adapter=(adapter)
28
+ @adapter = adapter
29
+ @wrapper = Wrapper.new(adapter_class(adapter))
30
+ end
31
+
32
+ def adapter_class(adapter)
33
+ case adapter
34
+ when :env
35
+ Adapters::Env
36
+ when :aws_ssm
37
+ Adapters::SSM
38
+ else
39
+ raise "Invalid adapter: #{adapter}"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ module ParamStore
2
+ module Adapters
3
+ class Env
4
+ def fetch(key, *args, &block)
5
+ ENV.fetch(key, *args, &block)
6
+ end
7
+
8
+ def fetch_all(*keys)
9
+ keys = keys.flatten
10
+ keys.each_with_object({}) do |key, result|
11
+ result[key] = ENV[key]
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,24 @@
1
+ module ParamStore
2
+ module Adapters
3
+ class SSM
4
+ def fetch(key, *args, &block)
5
+ tmp = {}
6
+ key = "#{ParamStore.path}#{key}" unless ParamStore.path.nil?
7
+ begin
8
+ tmp[key] = ParamStore.ssm_client.get_parameter(name: key, with_decryption: true).parameter.value
9
+ rescue Aws::SSM::Errors::ParameterNotFound
10
+ # let the tmp.fetch below deal with not found key and defaults
11
+ end
12
+ tmp.fetch(key, *args, &block)
13
+ end
14
+
15
+ def fetch_all(*keys)
16
+ keys = keys.flatten
17
+ keys = keys.map { |key| "#{ParamStore.path}#{key}" } if ParamStore.path
18
+ ParamStore.ssm_client.get_parameters(names: keys, with_decryption: true).parameters.each_with_object({}) do |param, result|
19
+ result[param.name.gsub(ParamStore.path.to_s, '')] = param.value
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module ParamStore
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,53 @@
1
+ module ParamStore
2
+ class Wrapper
3
+ def initialize(adapter_class)
4
+ @adapter_class = adapter_class
5
+ end
6
+
7
+ def fetch(key, *args, &block)
8
+ key = key.to_s
9
+ unless cache.key?(key)
10
+ # cache params to minimize number of requests
11
+ cache[key] = adapter_instance.fetch(key, *args, &block)
12
+ end
13
+ cache[key]
14
+ end
15
+
16
+ def copy_to_env(*keys, require_keys: false)
17
+ cache_all(*keys)
18
+
19
+ require_keys!(*keys) if require_keys
20
+
21
+ keys.each { |key| ENV[key] = cache[key] }
22
+ end
23
+
24
+ def require_keys!(*keys)
25
+ cache_all(*keys)
26
+
27
+ missing = keys.flatten.map!(&:to_s) - cache.keys
28
+
29
+ return if missing.none?
30
+
31
+ raise "Missing keys: #{missing.join(', ')}"
32
+ end
33
+
34
+ private
35
+
36
+ attr_accessor :adapter, :cache
37
+
38
+ def cache_all(*keys)
39
+ keys.flatten.map!(&:to_s)
40
+ adapter_instance.fetch_all(*keys).each do |key, value|
41
+ cache[key] = value
42
+ end
43
+ end
44
+
45
+ def cache
46
+ @_cache ||= {}
47
+ end
48
+
49
+ def adapter_instance
50
+ @_adapter_instance ||= @adapter_class.new
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,28 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'param_store/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'param_store'
7
+ spec.version = ParamStore::VERSION
8
+ spec.authors = ['Pablo Cantero']
9
+ spec.email = ['pablohstc@gmail.com']
10
+
11
+ spec.summary = 'Easy switch in between ENV and AWS Parameter Store (SSM)'
12
+ spec.homepage = 'https://github.com/phstc/param_store'
13
+ spec.license = 'MIT'
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'aws-sdk-ssm', '~> 1'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: param_store
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pablo Cantero
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk-ssm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description:
56
+ email:
57
+ - pablohstc@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".circleci/config.yml"
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - bin/console
74
+ - bin/setup
75
+ - lib/param_store.rb
76
+ - lib/param_store/adapters/env.rb
77
+ - lib/param_store/adapters/ssm.rb
78
+ - lib/param_store/version.rb
79
+ - lib/param_store/wrapper.rb
80
+ - param_store.gemspec
81
+ homepage: https://github.com/phstc/param_store
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.0.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Easy switch in between ENV and AWS Parameter Store (SSM)
104
+ test_files: []