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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37c61d91df158a98905540788736c8cb991ac74ad07b7e731d3cc4c90a7db51a
4
- data.tar.gz: 91b249ed588ec98a51d630cc3ead8fd3940e1aac5b2a37c052fb6d90419cd9bc
3
+ metadata.gz: b1281f22d87f9f4d7859fc9502b63c1f0ce4b3ffc2613cffffac04439eb15ce4
4
+ data.tar.gz: a654029ddd734466360ff854f7a8f384ed04b4ad3d76a40b7532900ab1a1ddbf
5
5
  SHA512:
6
- metadata.gz: a4c51ba32a2bd745ac6902f6ae53f0cfdb7f9f19d44fa0c35b615ba61e3d87ace7009bf5aad7cb06b16abd0a5e1c58e383210910cc186c9616dcba491a884848
7
- data.tar.gz: b1ebbf900ae993a785ed432d514033c0b86d108fa3b9b94ca1ac1096cddfaf4952843bd4a21e291f934e54898efead2fd9b9f4bc88bfad8b496cd58247bbff43
6
+ metadata.gz: ff4729ff94e74c73b5473a2de24faae869f913a9d066f16e666c8d92c8aedbc748bf7c89821dd4197833b4a901a7111f68968b787f8eee4679b4bbed3b89e877
7
+ data.tar.gz: 70913ef31b6334875776970fc6b2922e9e97a8e0ccbd983672a8e120f6677ec440d8435436845efe20ac9d0f303c98249566c6a249050b43d62db93406b3cb0c
@@ -1,6 +1,5 @@
1
1
  Gemspec/RequiredRubyVersion:
2
2
  Include:
3
- - 2.4
4
3
  - 2.5
5
4
  - 2.6
6
5
 
@@ -12,6 +11,9 @@ Metrics/BlockLength:
12
11
  Metrics/LineLength:
13
12
  Max: 140
14
13
 
14
+ Metrics/ModuleLength:
15
+ Max: 120
16
+
15
17
  Security/YAMLLoad:
16
18
  Enabled: false
17
19
 
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.6.5
@@ -1,8 +1,14 @@
1
+ ---
2
+ sudo: false
1
3
  language: ruby
4
+ cache: bundler
2
5
  rvm:
3
- - 2.4.6
4
- - 2.5.5
5
- - 2.6.3
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(app_env || env_var('RAILS_ENV') || env_var('RACK_ENV') || env_var('APP_ENV') || fail(UnknownEnvError))
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
 
@@ -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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module A9n
2
- VERSION = '0.8.3'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
@@ -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(['default', 'development'])
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
@@ -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.8.3
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-21 00:00:00.000000000 Z
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
@@ -1,4 +0,0 @@
1
- fail_on_violations: true
2
-
3
- rubocop:
4
- config_file: .rubocop.yml