a9n 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/.ruby-version +1 -1
- data/.travis.yml +9 -3
- data/lib/a9n.rb +11 -5
- data/lib/a9n/ext/hash.rb +2 -2
- data/lib/a9n/loader.rb +2 -2
- data/lib/a9n/version.rb +1 -1
- data/spec/unit/a9n_spec.rb +11 -1
- data/spec/unit/loader_spec.rb +5 -0
- metadata +2 -3
- data/.hound.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1281f22d87f9f4d7859fc9502b63c1f0ce4b3ffc2613cffffac04439eb15ce4
|
4
|
+
data.tar.gz: a654029ddd734466360ff854f7a8f384ed04b4ad3d76a40b7532900ab1a1ddbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4729ff94e74c73b5473a2de24faae869f913a9d066f16e666c8d92c8aedbc748bf7c89821dd4197833b4a901a7111f68968b787f8eee4679b4bbed3b89e877
|
7
|
+
data.tar.gz: 70913ef31b6334875776970fc6b2922e9e97a8e0ccbd983672a8e120f6677ec440d8435436845efe20ac9d0f303c98249566c6a249050b43d62db93406b3cb0c
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.5
|
data/.travis.yml
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
1
3
|
language: ruby
|
4
|
+
cache: bundler
|
2
5
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
|
6
|
+
- 2.5.7
|
7
|
+
- 2.6.5
|
8
|
+
before_install: gem install bundler -v 2.0.2
|
9
|
+
script:
|
10
|
+
- bundle exec rspec
|
11
|
+
- bundle exec rubocop
|
6
12
|
addons:
|
7
13
|
code_climate:
|
8
14
|
repo_token: 9aa2aa2432639c57772b6917ad9da468709e5536b75617575b02b35201a2eaf8
|
data/lib/a9n.rb
CHANGED
@@ -19,7 +19,13 @@ module A9n
|
|
19
19
|
|
20
20
|
class << self
|
21
21
|
def env
|
22
|
-
@env ||= ::A9n::StringInquirer.new(
|
22
|
+
@env ||= ::A9n::StringInquirer.new(
|
23
|
+
app_env ||
|
24
|
+
env_var('RAILS_ENV') ||
|
25
|
+
env_var('RACK_ENV') ||
|
26
|
+
env_var('APP_ENV') ||
|
27
|
+
raise(UnknownEnvError)
|
28
|
+
)
|
23
29
|
end
|
24
30
|
|
25
31
|
def env=(value)
|
@@ -47,11 +53,11 @@ module A9n
|
|
47
53
|
end
|
48
54
|
|
49
55
|
def root=(path)
|
50
|
-
@root = path.to_s.empty? ? nil : Pathname.new(path.to_s)
|
56
|
+
@root = path.to_s.empty? ? nil : Pathname.new(path.to_s).freeze
|
51
57
|
end
|
52
58
|
|
53
59
|
def groups
|
54
|
-
['default', env].compact
|
60
|
+
['default', env].compact.freeze
|
55
61
|
end
|
56
62
|
|
57
63
|
def rails_app
|
@@ -62,9 +68,9 @@ module A9n
|
|
62
68
|
raise A9n::MissingEnvVariableError, name if strict && !ENV.key?(name)
|
63
69
|
|
64
70
|
if ENV[name].is_a?(::String)
|
65
|
-
ENV[name].dup.force_encoding(Encoding::UTF_8)
|
71
|
+
ENV[name].dup.force_encoding(Encoding::UTF_8).freeze
|
66
72
|
else
|
67
|
-
ENV[name]
|
73
|
+
ENV[name].dup.freeze
|
68
74
|
end
|
69
75
|
end
|
70
76
|
|
data/lib/a9n/ext/hash.rb
CHANGED
@@ -19,11 +19,11 @@ module A9n
|
|
19
19
|
|
20
20
|
def get_value(key, value, scope)
|
21
21
|
if value.is_a?(::Hash)
|
22
|
-
deep_prepare(value, scope)
|
22
|
+
deep_prepare(value, scope).freeze
|
23
23
|
elsif value.is_a?(Symbol) && value == :env
|
24
24
|
A9n.env_var(scope.env_key_name(key), strict: A9n.strict?)
|
25
25
|
else
|
26
|
-
value
|
26
|
+
value.freeze
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/a9n/loader.rb
CHANGED
@@ -34,13 +34,13 @@ module A9n
|
|
34
34
|
common_scope = prepare_yml_scope(yml, scope, COMMON_SCOPE)
|
35
35
|
env_scope = prepare_yml_scope(yml, scope, env)
|
36
36
|
|
37
|
-
A9n::Hash.merge(common_scope, env_scope)
|
37
|
+
A9n::Hash.merge(common_scope, env_scope).freeze
|
38
38
|
end
|
39
39
|
|
40
40
|
def prepare_yml_scope(yml, scope, env)
|
41
41
|
return nil unless yml[env].is_a?(::Hash)
|
42
42
|
|
43
|
-
A9n::Hash.deep_prepare(yml[env], scope)
|
43
|
+
A9n::Hash.deep_prepare(yml[env], scope).freeze
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
data/lib/a9n/version.rb
CHANGED
data/spec/unit/a9n_spec.rb
CHANGED
@@ -39,6 +39,13 @@ RSpec.describe A9n do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context 'unknown env' do
|
42
|
+
before do
|
43
|
+
expect(subject).to receive(:app_env).and_return(nil)
|
44
|
+
expect(subject).to receive(:env_var).with('RAILS_ENV').and_return(nil)
|
45
|
+
expect(subject).to receive(:env_var).with('RACK_ENV').and_return(nil)
|
46
|
+
expect(subject).to receive(:env_var).with('APP_ENV').and_return(nil)
|
47
|
+
end
|
48
|
+
|
42
49
|
it do
|
43
50
|
expect { subject.env }.to raise_error(A9n::UnknownEnvError)
|
44
51
|
end
|
@@ -51,7 +58,8 @@ RSpec.describe A9n do
|
|
51
58
|
end
|
52
59
|
|
53
60
|
it do
|
54
|
-
expect(subject.groups).to eq([
|
61
|
+
expect(subject.groups).to eq(%w[default development])
|
62
|
+
expect(subject.groups).to be_frozen
|
55
63
|
end
|
56
64
|
end
|
57
65
|
|
@@ -106,6 +114,7 @@ RSpec.describe A9n do
|
|
106
114
|
|
107
115
|
it do
|
108
116
|
expect(subject.root).to eq(Pathname.new('/home/knapo/workspace/a9n'))
|
117
|
+
expect(subject.root).to be_frozen
|
109
118
|
end
|
110
119
|
end
|
111
120
|
|
@@ -172,6 +181,7 @@ RSpec.describe A9n do
|
|
172
181
|
|
173
182
|
it do
|
174
183
|
expect(subject.env_var('FOO')).to eq('little foo')
|
184
|
+
expect(subject.env_var('FOO')).to be_frozen
|
175
185
|
end
|
176
186
|
|
177
187
|
it do
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -114,6 +114,7 @@ RSpec.describe A9n::Loader do
|
|
114
114
|
shared_examples 'non-empty config file' do
|
115
115
|
it 'returns non-empty hash' do
|
116
116
|
expect(subject).to be_kind_of(Hash)
|
117
|
+
expect(subject).to be_frozen
|
117
118
|
expect(subject.keys).to_not be_empty
|
118
119
|
end
|
119
120
|
end
|
@@ -141,6 +142,10 @@ RSpec.describe A9n::Loader do
|
|
141
142
|
|
142
143
|
it_behaves_like 'non-empty config file'
|
143
144
|
|
145
|
+
it 'contains only frozen values' do
|
146
|
+
expect(subject.values.reject(&:frozen?)).to eq([])
|
147
|
+
end
|
148
|
+
|
144
149
|
it 'contains keys from defaults scope' do
|
145
150
|
expect(subject[:default_foo]).to eq('default foo')
|
146
151
|
expect(subject[:overriden_foo]).to eq('already overriden foo')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: a9n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codeclimate-test-reporter
|
@@ -102,7 +102,6 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
|
-
- ".hound.yml"
|
106
105
|
- ".rspec"
|
107
106
|
- ".rspec.example"
|
108
107
|
- ".rubocop.yml"
|
data/.hound.yml
DELETED