settings_reader 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +91 -0
- data/.github/workflows/linters.yml +0 -13
- data/README.md +9 -0
- data/lib/settings_reader/backends/yaml_file.rb +4 -1
- data/lib/settings_reader/reader.rb +8 -0
- data/lib/settings_reader/resolvers/env.rb +1 -1
- data/lib/settings_reader/resolvers/erb.rb +1 -1
- data/lib/settings_reader/version.rb +1 -1
- metadata +4 -4
- data/.github/workflows/main.yml +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ab3a27357661ed1306d2333a8a7dedf2b48648752f1dbf1e912d6cbc95a0449
|
4
|
+
data.tar.gz: e4360e30403969a899afa297fb700e8b348d53eb31c62170d5245ea61568bb12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9258ae69739f257b64e7dfe5f2f71c6ee5a669907c8c03fde955f34f25fed5e423d9cce07b0f2b905c70b73aabbf688d7c21f21cdd8c78a5b5d428273b51e39
|
7
|
+
data.tar.gz: a09f7957d5e0ed8922c9c30dfbad6ade1c94a4deafeb423cdfe695d8a2b35cbf076934288cdf74341df9cfd1c2d66fb1a3e1ea297062d26cea24f7db2363ccb6
|
@@ -0,0 +1,91 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
orbs:
|
4
|
+
ruby: circleci/ruby@1.4.0
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
|
8
|
+
rspec-test:
|
9
|
+
parameters:
|
10
|
+
ruby-version:
|
11
|
+
type: string
|
12
|
+
docker:
|
13
|
+
- image: cimg/ruby:<< parameters.ruby-version >>
|
14
|
+
resource_class: small
|
15
|
+
environment:
|
16
|
+
COVERAGE: true
|
17
|
+
steps:
|
18
|
+
- checkout
|
19
|
+
- ruby/install-deps
|
20
|
+
- run:
|
21
|
+
name: Run rspec
|
22
|
+
command: bundle exec rspec
|
23
|
+
- run:
|
24
|
+
name: Upload coverage
|
25
|
+
command: bash <(curl -s https://codecov.io/bash)
|
26
|
+
|
27
|
+
rubocop:
|
28
|
+
docker:
|
29
|
+
- image: cimg/ruby:2.5
|
30
|
+
resource_class: small
|
31
|
+
steps:
|
32
|
+
- checkout
|
33
|
+
- ruby/install-deps
|
34
|
+
- run:
|
35
|
+
name: Run rubocop
|
36
|
+
command: bundle exec rubocop --parallel
|
37
|
+
|
38
|
+
release:
|
39
|
+
parameters:
|
40
|
+
tag:
|
41
|
+
type: string
|
42
|
+
default: "default-tag"
|
43
|
+
docker:
|
44
|
+
- image: cimg/ruby:2.6.6
|
45
|
+
resource_class: small
|
46
|
+
environment:
|
47
|
+
RELEASE_TAG: << parameters.tag >>
|
48
|
+
steps:
|
49
|
+
- checkout
|
50
|
+
- ruby/install-deps
|
51
|
+
- run:
|
52
|
+
name: Set up credentials
|
53
|
+
command: |
|
54
|
+
mkdir -p $HOME/.gem
|
55
|
+
touch $HOME/.gem/credentials
|
56
|
+
chmod 0600 $HOME/.gem/credentials
|
57
|
+
printf -- "---\n:rubygems_api_key: $RUBYGEMS_API_KEY\n" > $HOME/.gem/credentials
|
58
|
+
- run:
|
59
|
+
name: Set version
|
60
|
+
command: sed -i "s/[[:digit:]].[[:digit:]].[[:digit:]]/${RELEASE_TAG}/g" $(find . -name "version.rb")
|
61
|
+
- run:
|
62
|
+
name: Build gem
|
63
|
+
command: gem build *.gemspec
|
64
|
+
- run:
|
65
|
+
name: Push gem
|
66
|
+
command: gem push *.gem
|
67
|
+
|
68
|
+
workflows:
|
69
|
+
|
70
|
+
settings_reader.build:
|
71
|
+
jobs:
|
72
|
+
|
73
|
+
- rspec-test:
|
74
|
+
matrix:
|
75
|
+
parameters:
|
76
|
+
ruby-version: [ '2.5', '2.6', '2.7', '3.0' ]
|
77
|
+
|
78
|
+
- rubocop:
|
79
|
+
name: Rubocop
|
80
|
+
|
81
|
+
settings_reader.release:
|
82
|
+
jobs:
|
83
|
+
|
84
|
+
- release:
|
85
|
+
tag: << pipeline.git.tag >>
|
86
|
+
context: gem-publishing
|
87
|
+
filters:
|
88
|
+
branches:
|
89
|
+
ignore: /.*/
|
90
|
+
tags:
|
91
|
+
only: /\d\.\d\.\d/
|
@@ -9,19 +9,6 @@ on:
|
|
9
9
|
- cron: '30 0 * * 1'
|
10
10
|
|
11
11
|
jobs:
|
12
|
-
rubocop:
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
|
15
|
-
steps:
|
16
|
-
- name: Checkout
|
17
|
-
uses: actions/checkout@v2
|
18
|
-
- name: Set up Ruby
|
19
|
-
uses: ruby/setup-ruby@v1
|
20
|
-
with:
|
21
|
-
ruby-version: 2.5
|
22
|
-
bundler-cache: true
|
23
|
-
- name: Run rubocop
|
24
|
-
run: bundle exec rubocop --parallel
|
25
12
|
|
26
13
|
code-ql:
|
27
14
|
name: Analyze
|
data/README.md
CHANGED
@@ -110,6 +110,15 @@ db_settings['user'] # "app"
|
|
110
110
|
db_params = db_settings.load('parameters') # SettingsReader::Reader
|
111
111
|
```
|
112
112
|
|
113
|
+
You can also check if sub-setting tree exists:
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
APP_SETTINGS.load('integrations/database').blank? # false
|
117
|
+
APP_SETTINGS.load('integrations/database').present? # true
|
118
|
+
APP_SETTINGS.load('integrations/unexisiting').blank? # true
|
119
|
+
APP_SETTINGS.load('integrations/unexisiting').present? # false
|
120
|
+
```
|
121
|
+
|
113
122
|
## Advanced Configurations & Customization
|
114
123
|
|
115
124
|
### Backends
|
@@ -22,7 +22,10 @@ module SettingsReader
|
|
22
22
|
def read_yml(path)
|
23
23
|
return {} unless File.exist?(path)
|
24
24
|
|
25
|
-
YAML.safe_load(IO.read(path))
|
25
|
+
data = YAML.safe_load(IO.read(path))
|
26
|
+
raise SettingsReader::Error, "YML Settings at #{path} file has incorrect structure" unless data.is_a?(Hash)
|
27
|
+
|
28
|
+
data
|
26
29
|
rescue Psych::SyntaxError, Errno::ENOENT => e
|
27
30
|
raise SettingsReader::Error, "Cannot read settings file at #{path}: #{e.message}"
|
28
31
|
end
|
@@ -23,6 +23,14 @@ module SettingsReader
|
|
23
23
|
SettingsReader::Reader.new(new_path, @config)
|
24
24
|
end
|
25
25
|
|
26
|
+
def blank?
|
27
|
+
@backends.all? { |backend| backend.get(@base_path).nil? }
|
28
|
+
end
|
29
|
+
|
30
|
+
def present?
|
31
|
+
!blank?
|
32
|
+
end
|
33
|
+
|
26
34
|
protected
|
27
35
|
|
28
36
|
def check_deep_structure(value, path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: settings_reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodymyr Mykhailyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -103,8 +103,8 @@ executables: []
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
+
- ".circleci/config.yml"
|
106
107
|
- ".github/workflows/linters.yml"
|
107
|
-
- ".github/workflows/main.yml"
|
108
108
|
- ".gitignore"
|
109
109
|
- ".rspec"
|
110
110
|
- ".rubocop.yml"
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.1.
|
156
|
+
rubygems_version: 3.1.3
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Flexible Settings reader with support of custom backends and value resolutions
|
data/.github/workflows/main.yml
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
name: ci
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches:
|
5
|
-
- main
|
6
|
-
pull_request:
|
7
|
-
branches:
|
8
|
-
- main
|
9
|
-
release:
|
10
|
-
types: [published]
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
build:
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
strategy:
|
16
|
-
matrix:
|
17
|
-
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
18
|
-
steps:
|
19
|
-
- name: Checkout
|
20
|
-
uses: actions/checkout@v1
|
21
|
-
|
22
|
-
- name: Set up Ruby
|
23
|
-
uses: ruby/setup-ruby@v1
|
24
|
-
with:
|
25
|
-
ruby-version: ${{ matrix.ruby }}
|
26
|
-
bundler-cache: true
|
27
|
-
|
28
|
-
- name: Run specs
|
29
|
-
env:
|
30
|
-
COVERAGE: true
|
31
|
-
run: bundle exec rspec
|
32
|
-
|
33
|
-
- name: Upload coverage
|
34
|
-
env:
|
35
|
-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
36
|
-
run: bash <(curl -s https://codecov.io/bash)
|
37
|
-
|
38
|
-
release:
|
39
|
-
runs-on: ubuntu-latest
|
40
|
-
needs: build
|
41
|
-
if: github.event_name == 'release' && github.event.action == 'published'
|
42
|
-
steps:
|
43
|
-
- name: Checkout
|
44
|
-
uses: actions/checkout@v1
|
45
|
-
|
46
|
-
- name: Set up Ruby
|
47
|
-
uses: ruby/setup-ruby@v1
|
48
|
-
with:
|
49
|
-
ruby-version: 2.7
|
50
|
-
bundler-cache: true
|
51
|
-
- name: Set up credentials
|
52
|
-
run: |
|
53
|
-
mkdir -p $HOME/.gem
|
54
|
-
touch $HOME/.gem/credentials
|
55
|
-
chmod 0600 $HOME/.gem/credentials
|
56
|
-
printf -- "---\n:rubygems_api_key: ${{secrets.RUBYGEMS_AUTH_TOKEN}}\n" > $HOME/.gem/credentials
|
57
|
-
|
58
|
-
- name: Get version
|
59
|
-
run: echo "${GITHUB_REF/refs\/tags\//}" > release.tag
|
60
|
-
- name: Set version
|
61
|
-
run: sed -i "s/0.0.0/$(<release.tag)/g" */**/version.rb
|
62
|
-
|
63
|
-
- name: Build gem
|
64
|
-
run: gem build *.gemspec
|
65
|
-
- name: Push gem
|
66
|
-
run: gem push *.gem
|