blinkist-config 1.2.2 → 1.4.0
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 +5 -5
- data/.github/workflows/ci.yml +27 -0
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/Dockerfile +9 -5
- data/Gemfile +8 -1
- data/README.md +27 -12
- data/Rakefile +5 -6
- data/blinkist-config.gemspec +16 -17
- data/docker-compose.yml +2 -3
- data/lib/blinkist/config/adapters/adapter.rb +1 -1
- data/lib/blinkist/config/adapters/aws_ssm_adapter.rb +13 -10
- data/lib/blinkist/config/adapters/diplomat_adapter.rb +3 -9
- data/lib/blinkist/config/error_handlers/error_handler.rb +1 -1
- data/lib/blinkist/config/error_handlers/production_only_error_handler.rb +1 -1
- data/lib/blinkist/config/error_handlers.rb +0 -1
- data/lib/blinkist/config/factory.rb +2 -2
- data/lib/blinkist/config/version.rb +1 -1
- data/lib/blinkist/config.rb +7 -8
- metadata +15 -56
- data/.rubocop.yml +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2bb5e2fe4f325f1f3a8d4a9c5c90869bdaa4dbfda924ea1924262343f67516b2
|
4
|
+
data.tar.gz: aff6fc8557d9a1d198441ef9516e7278e347a55d41e192d62b5b1e7dd01d8a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdab1d7adc48147f58e2aa9d38798cfd660eb07496b755ff26b100ae650915e365266c964d2a6491fe3e0aaabe5da03f57af6b0a518ef3465f56bcdc44947ff6
|
7
|
+
data.tar.gz: d9e7e893de135f92651afa148ddef9302d60100e8d54a7216ef3443f21e8428a33fd00747f5e6255963d7f4378aa94134d8b855980013ba18f1b4b8fabf90c93
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: Run tests
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v4
|
12
|
+
|
13
|
+
- name: Set up Ruby
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 3.2.8
|
17
|
+
bundler-cache: true
|
18
|
+
bundler: "2.6.9"
|
19
|
+
|
20
|
+
- name: Bundle Install
|
21
|
+
run: bundle install --jobs=4 --retry=3 --path=vendor/bundle
|
22
|
+
|
23
|
+
- name: Run RSpec
|
24
|
+
env:
|
25
|
+
RAILS_ENV: test
|
26
|
+
RACK_ENV: test
|
27
|
+
run: bundle exec rspec --format progress spec
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ main ]
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: [ main ]
|
20
|
+
schedule:
|
21
|
+
- cron: '35 19 * * 6'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
actions: read
|
29
|
+
contents: read
|
30
|
+
security-events: write
|
31
|
+
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
language: [ 'ruby' ]
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout repository
|
41
|
+
uses: actions/checkout@v2
|
42
|
+
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
44
|
+
- name: Initialize CodeQL
|
45
|
+
uses: github/codeql-action/init@v1
|
46
|
+
with:
|
47
|
+
languages: ${{ matrix.language }}
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
+
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
+
- name: Autobuild
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
57
|
+
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
+
# 📚 https://git.io/JvXDl
|
60
|
+
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
+
# and modify them (or add more) to build your code if your project
|
63
|
+
# uses a compiled language
|
64
|
+
|
65
|
+
#- run: |
|
66
|
+
# make bootstrap
|
67
|
+
# make release
|
68
|
+
|
69
|
+
- name: Perform CodeQL Analysis
|
70
|
+
uses: github/codeql-action/analyze@v1
|
data/Dockerfile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
FROM ruby:
|
1
|
+
FROM ruby:3.3.0-slim
|
2
2
|
|
3
3
|
ENV RAILS_ENV=test
|
4
4
|
ENV LANG en_US.UTF-8
|
5
5
|
ENV LANGUAGE en_US.UTF-8
|
6
6
|
ENV LC_ALL en_US.UTF-8
|
7
7
|
ENV LC_CTYPE en_US.UTF-8
|
8
|
+
ENV XDG_CACHE_HOME /nonexistent/.cache
|
8
9
|
|
9
10
|
ENV RUNTIME_PACKAGES pkg-config git
|
10
11
|
|
@@ -13,8 +14,9 @@ WORKDIR /tmp/tmpapp
|
|
13
14
|
ADD . /tmp/tmpapp
|
14
15
|
|
15
16
|
RUN echo 'gem: --no-document' >> ~/.gemrc && \
|
16
|
-
apt-get clean && apt-get update -qq &&
|
17
|
-
|
17
|
+
apt-get clean && apt-get update -qq && \
|
18
|
+
apt-get install -y build-essential $RUNTIME_PACKAGES && \
|
19
|
+
gem install bundler --version 2.2.10 && \
|
18
20
|
gem install gem-release && \
|
19
21
|
bundle update && bundle install --jobs 20 --retry 5 && \
|
20
22
|
rm -Rf /tmp/tmpapp/ && \
|
@@ -26,7 +28,9 @@ WORKDIR /app
|
|
26
28
|
|
27
29
|
RUN bundle install -j1
|
28
30
|
|
29
|
-
RUN
|
31
|
+
RUN mkdir -p /nonexistent && \
|
32
|
+
mkdir -p /nonexistent/.cache && \
|
33
|
+
chown -R nobody:nogroup /app /nonexistent
|
30
34
|
RUN whoami
|
31
35
|
USER nobody
|
32
|
-
RUN whoami
|
36
|
+
RUN whoami
|
data/Gemfile
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in blinkist-config.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
+
group :development do
|
7
|
+
gem "bundler", "~> 2.6.9"
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem "standard", ">= 1.50.0"
|
10
|
+
end
|
11
|
+
|
6
12
|
group :test do
|
7
13
|
gem "codeclimate-test-reporter", "~> 1.0.0"
|
14
|
+
gem "rspec"
|
8
15
|
gem "simplecov"
|
9
16
|
end
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Blinkist::Config
|
2
2
|
|
3
3
|
[](https://circleci.com/gh/blinkist/blinkist-config)
|
4
|
-
[](https://www.versioneye.com/user/projects/58abf0e4b4d2a20036950ef0)
|
5
4
|
[](https://codeclimate.com/github/blinkist/blinkist-config)
|
6
5
|
|
7
6
|
This GEM allows you to access configuration stores with different adapters. Here're some examples of usage:
|
@@ -10,6 +9,11 @@ This GEM allows you to access configuration stores with different adapters. Here
|
|
10
9
|
|
11
10
|
```ruby
|
12
11
|
# First setup the Config to use the ENV as config store
|
12
|
+
|
13
|
+
Diplomat.configure do |config|
|
14
|
+
config.url = "http://172.17.0.1:8500"
|
15
|
+
end
|
16
|
+
|
13
17
|
Blinkist::Config.env = ENV["RAILS_ENV"]
|
14
18
|
Blinkist::Config.app_name = "my_nice_app"
|
15
19
|
Blinkist::Config.adapter_type = :env
|
@@ -23,7 +27,7 @@ my_config_value = Blinkist::Config.get! "some/folder/config"
|
|
23
27
|
### Error handling
|
24
28
|
|
25
29
|
When configured with `Blinkist::Config.error_handler = :strict` (as recommended)
|
26
|
-
reading a configuration entry for which the value is missing
|
30
|
+
reading a configuration entry for which the value is missing
|
27
31
|
(for example missing enviroment variables) will cause
|
28
32
|
`Blinkist::Config::ValueMissingError` to be raised.
|
29
33
|
|
@@ -44,12 +48,24 @@ my_config_value = Blinkist::Config.get! "some/folder/config", "default value"
|
|
44
48
|
# If ENV["SOME_FOLDER_CONFIG"] is nil, "default value" will be returned
|
45
49
|
```
|
46
50
|
|
51
|
+
### Refetching a value
|
52
|
+
|
53
|
+
If you want to refetch a value from the config store, you can set the `refetch` parameter to `true`.
|
54
|
+
**WARNING**: This will cut into our SSM quota on AWS - please use this with caution and behind another way of caching.
|
55
|
+
See [AWS SSM Quota](https://docs.aws.amazon.com/general/latest/gr/ssm.html#parameter-store) for more information.
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
my_config_value = Blinkist::Config.get! "some/folder/config", refetch: true
|
59
|
+
|
60
|
+
# This will reload the value from the config store, even if it's cached. The re-fetched value will then be cached.
|
61
|
+
```
|
62
|
+
|
47
63
|
### Using Diplomat & Consul
|
48
64
|
|
49
65
|
If you want to use Consul's key value store, simply use our diplomat adapter.
|
50
66
|
|
51
|
-
|
52
|
-
|
67
|
+
- [https://www.consul.io/](https://www.consul.io/)
|
68
|
+
- [https://github.com/WeAreFarmGeek/diplomat](https://github.com/WeAreFarmGeek/diplomat)
|
53
69
|
|
54
70
|
The GEM expects consul to listen to `http://172.17.0.1:8500`
|
55
71
|
|
@@ -65,6 +81,7 @@ my_config_value = Blinkist::Config.get! "some/folder/config"
|
|
65
81
|
```
|
66
82
|
|
67
83
|
### Using Diplomat with a folder scope
|
84
|
+
|
68
85
|
```ruby
|
69
86
|
# Here we setting a scope outside of the app
|
70
87
|
|
@@ -95,6 +112,7 @@ Blinkist::Config.preload scope: "global" # in case you need also another scope b
|
|
95
112
|
```
|
96
113
|
|
97
114
|
### Using SSM with a folder scope
|
115
|
+
|
98
116
|
```ruby
|
99
117
|
# Here we setting a scope outside of the app
|
100
118
|
|
@@ -103,7 +121,6 @@ my_config_value = Blinkist::Config.get! "another/config", scope: "global"
|
|
103
121
|
# This will replace `my_nice_app` with `global` and try to resolve "/application/global/another/config"
|
104
122
|
```
|
105
123
|
|
106
|
-
|
107
124
|
## Installation
|
108
125
|
|
109
126
|
Add this line to your application's Gemfile:
|
@@ -137,31 +154,29 @@ require "rails"
|
|
137
154
|
You can build this project easily with [docker compose](https://docs.docker.com/compose/).
|
138
155
|
|
139
156
|
```
|
140
|
-
docker
|
157
|
+
docker compose run rake
|
141
158
|
```
|
142
159
|
|
143
|
-
This will execute rake and run all specs by auto correcting the code with
|
160
|
+
This will execute rake and run all specs by auto correcting the code with StandardRB.
|
144
161
|
|
145
162
|
If you're ready to tag a new version, do this
|
146
163
|
|
147
164
|
```
|
148
|
-
docker
|
165
|
+
docker compose run gem bump -t -v major|minor|patch
|
149
166
|
```
|
150
167
|
|
151
168
|
To deploy to rubygems.org do this then
|
152
169
|
|
153
170
|
```
|
154
|
-
docker
|
171
|
+
docker compose run gem release
|
155
172
|
```
|
156
173
|
|
157
174
|
You'll have to have proper rights to access rubygems.org
|
158
175
|
|
159
176
|
## Contributing
|
160
177
|
|
161
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
162
|
-
|
178
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/blinkist/blinkist-config.
|
163
179
|
|
164
180
|
## License
|
165
181
|
|
166
182
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
167
|
-
|
data/Rakefile
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
-
require "rubocop/rake_task"
|
4
|
-
|
5
|
-
RuboCop::RakeTask.new do |task|
|
6
|
-
task.options = %w(-a)
|
7
|
-
end
|
8
3
|
|
9
4
|
RSpec::Core::RakeTask.new(:spec)
|
10
5
|
|
6
|
+
task :standardrb do
|
7
|
+
sh "bundle exec standardrb --fix"
|
8
|
+
end
|
9
|
+
|
11
10
|
task(:default).clear
|
12
|
-
task default: %i
|
11
|
+
task default: %i[standardrb spec]
|
data/blinkist-config.gemspec
CHANGED
@@ -1,26 +1,25 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require_relative "lib/blinkist/config/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
6
|
+
spec.name = "blinkist-config"
|
7
|
+
spec.version = Blinkist::Config::VERSION
|
8
|
+
spec.authors = ["Sebastian Schleicher, Blinks Labs GmbH"]
|
9
|
+
spec.email = ["sj@blinkist.com"]
|
10
|
+
|
11
|
+
spec.required_ruby_version = ">= 3.2.8"
|
11
12
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
13
|
+
spec.summary = "Simple adapter based configuration handler (supports ENV and Consul/Diplomat)."
|
14
|
+
spec.description = "This GEM allows you to keep your configuration class-based by calling Blinkist::Config.get!(...) instead of accessing the ENV directly. You can set up different types of adapters to connect to various configuration systems like your ENV or Consul's key-value-store."
|
15
|
+
spec.homepage = "https://github.com/blinkist/blinkist-config"
|
16
|
+
spec.license = "MIT"
|
16
17
|
|
17
|
-
spec.files
|
18
|
-
spec.require_paths = %w
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.require_paths = %w[lib]
|
19
20
|
|
20
|
-
spec.
|
21
|
-
spec.
|
22
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
21
|
+
spec.add_dependency "aws-sdk-ssm", "~> 1"
|
22
|
+
spec.add_dependency "diplomat", "~> 2"
|
23
23
|
|
24
|
-
spec.
|
25
|
-
spec.add_runtime_dependency "aws-sdk-ssm", "~> 1"
|
24
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
26
25
|
end
|
data/docker-compose.yml
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
version: "2"
|
2
1
|
services:
|
3
2
|
rake:
|
4
3
|
entrypoint: bundle exec rake
|
@@ -9,7 +8,7 @@ services:
|
|
9
8
|
- RACK_ENV=test
|
10
9
|
volumes:
|
11
10
|
- .:/app
|
12
|
-
|
11
|
+
|
13
12
|
gem:
|
14
13
|
build:
|
15
14
|
context: .
|
@@ -18,4 +17,4 @@ services:
|
|
18
17
|
- .:/app
|
19
18
|
- ~/.gitconfig:/nonexistent/.gitconfig
|
20
19
|
- ~/.ssh:/nonexistent/.ssh
|
21
|
-
- ~/.gem:/nonexistent/.gem
|
20
|
+
- ~/.gem:/nonexistent/.gem
|
@@ -7,16 +7,16 @@ module Blinkist
|
|
7
7
|
DEFAULT_PREFIX = "/application/".freeze
|
8
8
|
|
9
9
|
def initialize(env, app_name)
|
10
|
-
super
|
10
|
+
super
|
11
11
|
|
12
12
|
@items_cache = {}
|
13
13
|
@client = Aws::SSM::Client.new
|
14
14
|
end
|
15
15
|
|
16
|
-
def get(key, default=nil, scope: nil)
|
16
|
+
def get(key, default = nil, scope: nil, refetch: false)
|
17
17
|
prefix = prefix_for(scope)
|
18
18
|
|
19
|
-
query_ssm_parameter
|
19
|
+
query_ssm_parameter(prefix + key, refetch)
|
20
20
|
rescue Aws::SSM::Errors::ParameterNotFound
|
21
21
|
default
|
22
22
|
end
|
@@ -29,17 +29,20 @@ module Blinkist
|
|
29
29
|
|
30
30
|
def prefix_for(scope)
|
31
31
|
if scope.nil?
|
32
|
-
DEFAULT_PREFIX
|
32
|
+
"#{DEFAULT_PREFIX}#{@app_name}/"
|
33
33
|
else
|
34
|
-
DEFAULT_PREFIX
|
34
|
+
"#{DEFAULT_PREFIX}#{scope}/"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def query_ssm_parameter(name)
|
39
|
-
|
40
|
-
name
|
41
|
-
|
42
|
-
|
38
|
+
def query_ssm_parameter(name, refetch)
|
39
|
+
if refetch || !@items_cache.key?(name)
|
40
|
+
@items_cache[name] = @client.get_parameter(
|
41
|
+
name: name,
|
42
|
+
with_decryption: true
|
43
|
+
).parameter.value
|
44
|
+
end
|
45
|
+
@items_cache[name]
|
43
46
|
end
|
44
47
|
|
45
48
|
def query_all_ssm_parameters(prefix)
|
@@ -5,23 +5,17 @@ module Blinkist
|
|
5
5
|
class Config
|
6
6
|
class DiplomatAdapter < Adapter
|
7
7
|
def initialize(env, app_name)
|
8
|
-
super
|
8
|
+
super
|
9
9
|
|
10
10
|
@items_cache = {}
|
11
|
-
|
12
|
-
Diplomat.configure do |config|
|
13
|
-
config.url = "http://172.17.0.1:8500"
|
14
|
-
end
|
15
11
|
end
|
16
12
|
|
17
|
-
def get(key, default=nil, scope: nil)
|
13
|
+
def get(key, default = nil, scope: nil, refetch: false)
|
18
14
|
scope ||= @app_name
|
19
15
|
|
20
16
|
diplomat_key = "#{scope}/#{key}"
|
21
17
|
|
22
|
-
|
23
|
-
@items_cache[diplomat_key] = Diplomat::Kv.get(diplomat_key)
|
24
|
-
end
|
18
|
+
@items_cache[diplomat_key] = Diplomat::Kv.get(diplomat_key) if refetch || !@items_cache.key?(diplomat_key)
|
25
19
|
|
26
20
|
@items_cache[diplomat_key]
|
27
21
|
rescue Diplomat::KeyNotFound
|
@@ -7,7 +7,7 @@ module Blinkist
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(key, scope)
|
10
|
-
raise ValueMissingError, "Missing value for #{key} in the scope: #{scope ||
|
10
|
+
raise ValueMissingError, "Missing value for #{key} in the scope: #{scope || "<default>"} (Please check the configuration for missing keys)"
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Blinkist
|
2
2
|
class Config
|
3
3
|
class Factory
|
4
|
-
def initialize(aspect, implementations, env=Blinkist::Config.env, app_name=Blinkist::Config.app_name)
|
4
|
+
def initialize(aspect, implementations, env = Blinkist::Config.env, app_name = Blinkist::Config.app_name)
|
5
5
|
@aspect = aspect
|
6
6
|
@implementations = implementations
|
7
7
|
@env = env
|
@@ -12,7 +12,7 @@ module Blinkist
|
|
12
12
|
case strategy
|
13
13
|
when Symbol
|
14
14
|
klass = @implementations[strategy] ||
|
15
|
-
|
15
|
+
raise(NotImplementedError, "Unknown strategy #{strategy} for #{@aspect}")
|
16
16
|
when Class
|
17
17
|
klass = strategy
|
18
18
|
else
|
data/lib/blinkist/config.rb
CHANGED
@@ -17,8 +17,8 @@ module Blinkist
|
|
17
17
|
class << self
|
18
18
|
attr_accessor :adapter_type, :logger, :env, :app_name, :error_handler
|
19
19
|
|
20
|
-
def get(key, default = nil, scope: nil)
|
21
|
-
get!(key, default, scope: scope)
|
20
|
+
def get(key, default = nil, scope: nil, refetch: false)
|
21
|
+
get!(key, default, scope: scope, refetch: refetch)
|
22
22
|
end
|
23
23
|
|
24
24
|
def preload(scope: nil)
|
@@ -28,26 +28,26 @@ module Blinkist
|
|
28
28
|
extend Gem::Deprecate
|
29
29
|
deprecate :get, "get!", 2017, 12
|
30
30
|
|
31
|
-
def get!(key, *args, scope: nil)
|
31
|
+
def get!(key, *args, scope: nil, refetch: false)
|
32
32
|
# NOTE: we need to do this this way
|
33
33
|
# to handle 'nil' default correctly
|
34
34
|
case args.length
|
35
35
|
when 0
|
36
36
|
default = nil
|
37
|
-
bang
|
37
|
+
bang = true
|
38
38
|
when 1
|
39
39
|
default = args.first
|
40
|
-
bang
|
40
|
+
bang = false
|
41
41
|
else
|
42
42
|
raise ArgumentError, "wrong number of arguments (given #{args.length + 1}, expected 1..2)"
|
43
43
|
end
|
44
44
|
|
45
|
-
from_adapter = adapter.get(key, scope: scope)
|
45
|
+
from_adapter = adapter.get(key, scope: scope, refetch: refetch)
|
46
46
|
|
47
47
|
if from_adapter.nil? && bang
|
48
48
|
handle_error(key, scope)
|
49
49
|
else
|
50
|
-
|
50
|
+
from_adapter || default
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -59,7 +59,6 @@ module Blinkist
|
|
59
59
|
handler = Factory.new("Blinkist::Config.error_handler", ErrorHandlers::BUILT_IN).call(error_handler)
|
60
60
|
handler.call(key, scope)
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
64
63
|
|
65
64
|
# NOTE: default configuration goes here
|
metadata
CHANGED
@@ -1,59 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blinkist-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Schleicher, Blinks Labs GmbH
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.12'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.12'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '12.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '12.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '3.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: diplomat
|
14
|
+
name: aws-sdk-ssm
|
57
15
|
requirement: !ruby/object:Gem::Requirement
|
58
16
|
requirements:
|
59
17
|
- - "~>"
|
@@ -67,19 +25,19 @@ dependencies:
|
|
67
25
|
- !ruby/object:Gem::Version
|
68
26
|
version: '1'
|
69
27
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
28
|
+
name: diplomat
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
72
30
|
requirements:
|
73
31
|
- - "~>"
|
74
32
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
33
|
+
version: '2'
|
76
34
|
type: :runtime
|
77
35
|
prerelease: false
|
78
36
|
version_requirements: !ruby/object:Gem::Requirement
|
79
37
|
requirements:
|
80
38
|
- - "~>"
|
81
39
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
40
|
+
version: '2'
|
83
41
|
description: This GEM allows you to keep your configuration class-based by calling
|
84
42
|
Blinkist::Config.get!(...) instead of accessing the ENV directly. You can set up
|
85
43
|
different types of adapters to connect to various configuration systems like your
|
@@ -90,8 +48,9 @@ executables: []
|
|
90
48
|
extensions: []
|
91
49
|
extra_rdoc_files: []
|
92
50
|
files:
|
51
|
+
- ".github/workflows/ci.yml"
|
52
|
+
- ".github/workflows/codeql-analysis.yml"
|
93
53
|
- ".gitignore"
|
94
|
-
- ".rubocop.yml"
|
95
54
|
- Dockerfile
|
96
55
|
- Gemfile
|
97
56
|
- LICENSE
|
@@ -120,8 +79,9 @@ files:
|
|
120
79
|
homepage: https://github.com/blinkist/blinkist-config
|
121
80
|
licenses:
|
122
81
|
- MIT
|
123
|
-
metadata:
|
124
|
-
|
82
|
+
metadata:
|
83
|
+
rubygems_mfa_required: 'true'
|
84
|
+
post_install_message:
|
125
85
|
rdoc_options: []
|
126
86
|
require_paths:
|
127
87
|
- lib
|
@@ -129,16 +89,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
89
|
requirements:
|
130
90
|
- - ">="
|
131
91
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
92
|
+
version: 3.2.8
|
133
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
94
|
requirements:
|
135
95
|
- - ">="
|
136
96
|
- !ruby/object:Gem::Version
|
137
97
|
version: '0'
|
138
98
|
requirements: []
|
139
|
-
|
140
|
-
|
141
|
-
signing_key:
|
99
|
+
rubygems_version: 3.5.3
|
100
|
+
signing_key:
|
142
101
|
specification_version: 4
|
143
102
|
summary: Simple adapter based configuration handler (supports ENV and Consul/Diplomat).
|
144
103
|
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
Lint/ParenthesesAsGroupedExpression:
|
2
|
-
Enabled: true
|
3
|
-
Exclude:
|
4
|
-
- 'spec/**/*'
|
5
|
-
|
6
|
-
Metrics/ModuleLength:
|
7
|
-
Exclude:
|
8
|
-
- "**/*_spec.rb"
|
9
|
-
|
10
|
-
Metrics/BlockLength:
|
11
|
-
Exclude:
|
12
|
-
- "**/*_spec.rb"
|
13
|
-
|
14
|
-
Style/BlockDelimiters:
|
15
|
-
Enabled: true
|
16
|
-
Exclude:
|
17
|
-
- 'spec/**/*'
|
18
|
-
|
19
|
-
Style/Documentation:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
Style/EmptyLinesAroundClassBody:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
Style/EmptyLinesAroundModuleBody:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Style/GuardClause:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
Style/PredicateName:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
Style/SignalException:
|
35
|
-
Enabled: false
|
36
|
-
|
37
|
-
Style/SpaceAroundEqualsInParameterDefault:
|
38
|
-
Enabled: false
|
39
|
-
|
40
|
-
Style/StringLiterals:
|
41
|
-
Enabled: false
|
42
|
-
|
43
|
-
Style/ZeroLengthPredicate:
|
44
|
-
Enabled: false
|
45
|
-
|
46
|
-
# Offense count: 9
|
47
|
-
Metrics/AbcSize:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
# Offense count: 1
|
51
|
-
# Configuration parameters: CountComments.
|
52
|
-
Metrics/ClassLength:
|
53
|
-
Enabled: false
|
54
|
-
|
55
|
-
# Offense count: 2
|
56
|
-
Metrics/CyclomaticComplexity:
|
57
|
-
Enabled: false
|
58
|
-
|
59
|
-
# Offense count: 79
|
60
|
-
# Configuration parameters: AllowURI, URISchemes.
|
61
|
-
Metrics/LineLength:
|
62
|
-
Enabled: false
|
63
|
-
|
64
|
-
# Offense count: 10
|
65
|
-
# Configuration parameters: CountComments.
|
66
|
-
Metrics/MethodLength:
|
67
|
-
Enabled: false
|
68
|
-
|
69
|
-
# Offense count: 2
|
70
|
-
Metrics/PerceivedComplexity:
|
71
|
-
Enabled: false
|