loadable_config 1.0.3 → 1.0.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/.github/workflows/gem-push.yml +31 -0
- data/.github/workflows/test.yml +42 -0
- data/lib/loadable_config/options.rb +10 -1
- data/lib/loadable_config/version.rb +1 -1
- data/lib/loadable_config.rb +15 -0
- metadata +5 -4
- data/.circleci/config.yml +0 -102
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c974e84d16ca1f1e101cdec3f960c9ddda833f662aed89801c62bf5a1242a42
|
4
|
+
data.tar.gz: 947f347ea37ed0a39d95d2efce098e885ecbd1617a5bc21ada7fddc1582bf30c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40f35dee22f84221bcf392d4cc8c0333ea8367418402bbd8fdf31be47c2729ab8d2a5434e348b47ce3084bfbeb232974763108a1bfbb7fc8030a45d7dd3de70
|
7
|
+
data.tar.gz: 49c65edd385e9c30aaaa3ab7d4b5e40b62fa48f13959a535905ce5acc245060b1aba65425aad517b12f4d46aec3fb5332a66b7377d1e0e12881cbb9ea5ff3a0e
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Publish Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "master" ]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: read
|
13
|
+
packages: write
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v3
|
17
|
+
- name: Set up Ruby 2.7
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: 2.7
|
21
|
+
|
22
|
+
- name: Publish to RubyGems
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build *.gemspec
|
29
|
+
gem push *.gem
|
30
|
+
env:
|
31
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Run Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches: "**"
|
6
|
+
|
7
|
+
permissions:
|
8
|
+
contents: read
|
9
|
+
checks: write
|
10
|
+
pull-requests: write
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2']
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v3
|
23
|
+
- name: Set up Ruby
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby-version }}
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rspec --profile 10 --format RspecJunitFormatter --out test_results/rspec.xml --format progress
|
30
|
+
- name: Upload result
|
31
|
+
uses: actions/upload-artifact@v3
|
32
|
+
if: always()
|
33
|
+
with:
|
34
|
+
name: rspec_${{ matrix.ruby-version }}.xml
|
35
|
+
path: test_results/rspec.xml
|
36
|
+
- name: Test Report
|
37
|
+
uses: dorny/test-reporter@v1
|
38
|
+
if: always()
|
39
|
+
with:
|
40
|
+
name: Rspec Tests - ${{ matrix.ruby-version }}
|
41
|
+
path: test_results/rspec.xml
|
42
|
+
reporter: java-junit
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class LoadableConfig::Options
|
4
|
-
attr_reader :config_path_prefix, :environment_key, :preprocessor
|
4
|
+
attr_reader :config_path_prefix, :environment_key, :preprocessor, :overlay_function
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
# Prefix for configuration file paths. Must be a valid directory, for
|
@@ -18,6 +18,11 @@ class LoadableConfig::Options
|
|
18
18
|
# If set, uses the provided block to preprocess the configuration file
|
19
19
|
# before YAML parsing.
|
20
20
|
@preprocessor = nil
|
21
|
+
|
22
|
+
# If set, calls the provided block with the configuration class after
|
23
|
+
# parsing to obtain a configuration overlay. If a value is returned, it is
|
24
|
+
# deep_merged into the application.
|
25
|
+
@overlay_function = nil
|
21
26
|
end
|
22
27
|
|
23
28
|
def config_path_prefix=(val)
|
@@ -35,4 +40,8 @@ class LoadableConfig::Options
|
|
35
40
|
def preprocess(&block)
|
36
41
|
@preprocessor = block
|
37
42
|
end
|
43
|
+
|
44
|
+
def overlay(&block)
|
45
|
+
@overlay_function = block
|
46
|
+
end
|
38
47
|
end
|
data/lib/loadable_config.rb
CHANGED
@@ -103,6 +103,11 @@ class LoadableConfig
|
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
|
+
if (overlay_function = LoadableConfig._configuration.overlay_function)
|
107
|
+
overlay_data = overlay_function.call(self.class)
|
108
|
+
config = _deep_merge(config, overlay_data) if overlay_data
|
109
|
+
end
|
110
|
+
|
106
111
|
unless config
|
107
112
|
raise RuntimeError.new("Configuration file missing config for #{self.class.name}.")
|
108
113
|
end
|
@@ -142,4 +147,14 @@ class LoadableConfig
|
|
142
147
|
'additionalProperties' => false,
|
143
148
|
)
|
144
149
|
end
|
150
|
+
|
151
|
+
def _deep_merge(a_hash, b_hash)
|
152
|
+
a_hash.merge(b_hash) do |_key, a_val, b_val|
|
153
|
+
if a_val.is_a?(Hash) && b_val.is_a?(Hash)
|
154
|
+
_deep_merge(a_val, b_val)
|
155
|
+
else
|
156
|
+
b_val
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
145
160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadable_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_schema
|
@@ -73,7 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- ".
|
76
|
+
- ".github/workflows/gem-push.yml"
|
77
|
+
- ".github/workflows/test.yml"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".travis.yml"
|
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
- !ruby/object:Gem::Version
|
107
108
|
version: '0'
|
108
109
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
110
|
+
rubygems_version: 3.1.6
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: Simple declarative configuration files
|
data/.circleci/config.yml
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
|
3
|
-
executors:
|
4
|
-
ruby:
|
5
|
-
parameters:
|
6
|
-
ruby-version:
|
7
|
-
type: string
|
8
|
-
default: "2.6"
|
9
|
-
gemfile:
|
10
|
-
type: string
|
11
|
-
default: "Gemfile"
|
12
|
-
docker:
|
13
|
-
- image: cimg/ruby:<< parameters.ruby-version >>
|
14
|
-
environment:
|
15
|
-
BUNDLE_JOBS: 3
|
16
|
-
BUNDLE_RETRY: 3
|
17
|
-
BUNDLE_PATH: vendor/bundle
|
18
|
-
RAILS_ENV: test
|
19
|
-
BUNDLE_GEMFILE: << parameters.gemfile >>
|
20
|
-
|
21
|
-
jobs:
|
22
|
-
test:
|
23
|
-
parameters:
|
24
|
-
ruby-version:
|
25
|
-
type: string
|
26
|
-
executor:
|
27
|
-
name: ruby
|
28
|
-
ruby-version: << parameters.ruby-version >>
|
29
|
-
parallelism: 1
|
30
|
-
steps:
|
31
|
-
- checkout
|
32
|
-
|
33
|
-
- run:
|
34
|
-
# Remove the non-appraisal gemfile for safety: we never want to use it.
|
35
|
-
name: Prepare bundler
|
36
|
-
command: bundle -v
|
37
|
-
|
38
|
-
- run:
|
39
|
-
name: Compute a gemfile lock
|
40
|
-
command: bundle lock && cp "${BUNDLE_GEMFILE}.lock" /tmp/gem-lock
|
41
|
-
|
42
|
-
- restore_cache:
|
43
|
-
keys:
|
44
|
-
- loadable_config-<< parameters.ruby-version >>-{{ checksum "/tmp/gem-lock" }}
|
45
|
-
- loadable_config-
|
46
|
-
|
47
|
-
- run:
|
48
|
-
name: Bundle Install
|
49
|
-
command: bundle check || bundle install
|
50
|
-
|
51
|
-
- save_cache:
|
52
|
-
key: loadable_config-<< parameters.ruby-version >>-{{ checksum "/tmp/gem-lock" }}
|
53
|
-
paths:
|
54
|
-
- vendor/bundle
|
55
|
-
|
56
|
-
- run:
|
57
|
-
name: Run rspec
|
58
|
-
command: bundle exec rspec --profile 10 --format RspecJunitFormatter --out test_results/rspec.xml --format progress
|
59
|
-
|
60
|
-
- store_test_results:
|
61
|
-
path: test_results
|
62
|
-
|
63
|
-
publish:
|
64
|
-
executor: ruby
|
65
|
-
steps:
|
66
|
-
- checkout
|
67
|
-
- run:
|
68
|
-
name: Setup Rubygems
|
69
|
-
command: |
|
70
|
-
mkdir ~/.gem &&
|
71
|
-
echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials &&
|
72
|
-
chmod 0600 ~/.gem/credentials
|
73
|
-
- run:
|
74
|
-
name: Publish to Rubygems
|
75
|
-
command: |
|
76
|
-
gem build loadable_config.gemspec
|
77
|
-
gem push loadable_config-*.gem
|
78
|
-
|
79
|
-
|
80
|
-
workflows:
|
81
|
-
version: 2.1
|
82
|
-
build:
|
83
|
-
jobs:
|
84
|
-
- test:
|
85
|
-
name: 'ruby 2.7'
|
86
|
-
ruby-version: "2.7"
|
87
|
-
- test:
|
88
|
-
name: 'ruby 3.0'
|
89
|
-
ruby-version: "3.0"
|
90
|
-
- test:
|
91
|
-
name: 'ruby 3.1'
|
92
|
-
ruby-version: "3.1"
|
93
|
-
- publish:
|
94
|
-
requires:
|
95
|
-
- 'ruby 2.7'
|
96
|
-
- 'ruby 3.0'
|
97
|
-
- 'ruby 3.1'
|
98
|
-
filters:
|
99
|
-
branches:
|
100
|
-
only: master
|
101
|
-
tags:
|
102
|
-
ignore: /.*/
|