a9n 0.7.0 → 0.8.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 +4 -4
- data/README.md +11 -0
- data/lib/a9n/struct.rb +7 -8
- data/lib/a9n/version.rb +1 -1
- data/spec/integration/a9n_spec.rb +15 -8
- data/spec/unit/a9n_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +4 -4
- data/spec/unit/scope_spec.rb +3 -3
- data/test_app/config/{configuration.yml → a9n.yml} +0 -0
- data/test_app/config/{configuration.yml.example → a9n.yml.example} +0 -0
- data/test_app/config/a9n/{mandrill.yml → aws.yml} +0 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c01e44cda9bcf5236abb9f3e48b210770559debc113dd329eb9be58be5e6ffb
|
4
|
+
data.tar.gz: 19cc16d440842053dd4deaf3534fa4367d4be03d72f672249d42bfd133e24fd5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5258bfce395c5b2af491824036833601979f1f0b7fbb7bd22d999549698e0240de74911c92bf83acc7e5db61a1ad34015799783ae1dffc4877b03d02ce0bf09
|
7
|
+
data.tar.gz: 185d114b3f8db2aefefe5e4a8a4b434b19be429d6c28b1d840c45e7d91e1537fb47c11410097192ac3d6c8141ea73a2afeda083c6985c96051ca3e47837d8d52
|
data/README.md
CHANGED
@@ -75,6 +75,17 @@ You can access it by:
|
|
75
75
|
A9n.mail.email_from # => `knapo@knapo.net`
|
76
76
|
A9n.mail.delivery_method # => `smtp`
|
77
77
|
|
78
|
+
## Setting variables manually
|
79
|
+
|
80
|
+
You can set variables manually using `A9n.set` method
|
81
|
+
|
82
|
+
A9n.set(:app_host, "localhost:3000")
|
83
|
+
A9n.app_host # => `localhost:3000`
|
84
|
+
|
85
|
+
To reload/restore configuration:
|
86
|
+
|
87
|
+
A9n.load
|
88
|
+
|
78
89
|
## Mapping ENV variables
|
79
90
|
|
80
91
|
Sometimes, you don't want to store a single secret value in the repo and you prefer having it in ENV variable. You can easily map it using `:env` symbol as a value:
|
data/lib/a9n/struct.rb
CHANGED
@@ -2,17 +2,16 @@ module A9n
|
|
2
2
|
class Struct
|
3
3
|
extend Forwardable
|
4
4
|
|
5
|
+
attr_reader :data
|
6
|
+
|
5
7
|
def_delegators :data, :empty?, :keys, :key?, :fetch, :[], :[]=
|
6
8
|
|
7
9
|
def initialize(data = {})
|
8
10
|
@data = data
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
alias to_h to_hash
|
13
|
+
alias to_hash data
|
14
|
+
alias to_h data
|
16
15
|
|
17
16
|
def merge(another_data)
|
18
17
|
data.merge!(another_data)
|
@@ -26,8 +25,8 @@ module A9n
|
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def set(key, value)
|
29
|
+
data[key.to_sym] = value
|
30
|
+
end
|
32
31
|
end
|
33
32
|
end
|
data/lib/a9n/version.rb
CHANGED
@@ -7,7 +7,7 @@ RSpec.describe A9n do
|
|
7
7
|
clean_singleton(subject)
|
8
8
|
ENV['ERB_DWARF'] = 'erbized dwarf'
|
9
9
|
ENV['DWARF_PASSWORD'] = 'dwarf123'
|
10
|
-
ENV['
|
10
|
+
ENV['AWS_API_KEY'] = 'ASDF1234'
|
11
11
|
ENV['API_KEY'] = 'XYZ999'
|
12
12
|
subject.app = double(env: env)
|
13
13
|
subject.root = File.expand_path('../../test_app', __dir__)
|
@@ -16,7 +16,7 @@ RSpec.describe A9n do
|
|
16
16
|
|
17
17
|
after do
|
18
18
|
clean_singleton(subject)
|
19
|
-
ENV.delete('
|
19
|
+
ENV.delete('GOOGLE_API_KEY')
|
20
20
|
ENV.delete('API_KEY')
|
21
21
|
end
|
22
22
|
|
@@ -28,6 +28,13 @@ RSpec.describe A9n do
|
|
28
28
|
it do
|
29
29
|
expect(subject.default_dwarf).to eq('default dwarf')
|
30
30
|
expect(subject.overriden_dwarf).to eq('already overriden dwarf')
|
31
|
+
subject.set(:default_dwarf, 'lazy dwarf')
|
32
|
+
subject.set(:overriden_dwarf, 'hard working dwarf')
|
33
|
+
expect(subject.default_dwarf).to eq('lazy dwarf')
|
34
|
+
expect(subject.overriden_dwarf).to eq('hard working dwarf')
|
35
|
+
subject.load
|
36
|
+
expect(subject.default_dwarf).to eq('default dwarf')
|
37
|
+
expect(subject.overriden_dwarf).to eq('already overriden dwarf')
|
31
38
|
end
|
32
39
|
|
33
40
|
it do
|
@@ -64,21 +71,21 @@ RSpec.describe A9n do
|
|
64
71
|
|
65
72
|
context 'extra config file' do
|
66
73
|
before do
|
67
|
-
expect(subject.
|
74
|
+
expect(subject.aws).to be_kind_of(A9n::Struct)
|
68
75
|
end
|
69
76
|
|
70
77
|
it do
|
71
|
-
expect(subject.
|
72
|
-
expect(subject.
|
78
|
+
expect(subject.aws.username).to eq('joe')
|
79
|
+
expect(subject.aws.api_key).to eq('ASDF1234')
|
73
80
|
end
|
74
81
|
|
75
82
|
it do
|
76
|
-
expect(subject.
|
77
|
-
expect(subject.
|
83
|
+
expect(subject.aws.fetch(:username)).to eq('joe')
|
84
|
+
expect(subject.aws.fetch(:api_key)).to eq('ASDF1234')
|
78
85
|
end
|
79
86
|
|
80
87
|
it do
|
81
|
-
expect(subject.fetch(:
|
88
|
+
expect(subject.fetch(:aws)).to eq(subject.aws)
|
82
89
|
end
|
83
90
|
end
|
84
91
|
|
data/spec/unit/a9n_spec.rb
CHANGED
@@ -167,9 +167,9 @@ RSpec.describe A9n do
|
|
167
167
|
end
|
168
168
|
|
169
169
|
it do
|
170
|
-
expect(subject.default_files[0]).to include('
|
170
|
+
expect(subject.default_files[0]).to include('a9n.yml')
|
171
171
|
expect(Pathname.new(subject.default_files[0])).to be_absolute
|
172
|
-
expect(subject.default_files[1]).to include('a9n/
|
172
|
+
expect(subject.default_files[1]).to include('a9n/aws.yml')
|
173
173
|
expect(Pathname.new(subject.default_files[1])).to be_absolute
|
174
174
|
end
|
175
175
|
end
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
RSpec.describe A9n::Loader do
|
2
|
-
let(:scope) { A9n::Scope.new('
|
2
|
+
let(:scope) { A9n::Scope.new('a9n') }
|
3
3
|
let(:env) { 'test' }
|
4
4
|
let(:root) { File.expand_path('../../test_app', __dir__) }
|
5
|
-
let(:file_path) { File.join(root, 'config/
|
5
|
+
let(:file_path) { File.join(root, 'config/a9n.yml') }
|
6
6
|
subject { described_class.new(file_path, scope, env) }
|
7
7
|
|
8
8
|
describe '#intialize' do
|
@@ -135,7 +135,7 @@ RSpec.describe A9n::Loader do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
context 'having env and defaults data' do
|
138
|
-
let(:file_path) { File.join(root, 'config/
|
138
|
+
let(:file_path) { File.join(root, 'config/a9n.yml') }
|
139
139
|
|
140
140
|
it_behaves_like 'non-empty config file'
|
141
141
|
|
@@ -170,7 +170,7 @@ RSpec.describe A9n::Loader do
|
|
170
170
|
end
|
171
171
|
|
172
172
|
context 'having no env and only defaults data' do
|
173
|
-
let(:file_path) { File.join(root, 'config/
|
173
|
+
let(:file_path) { File.join(root, 'config/a9n.yml') }
|
174
174
|
let(:env) { 'production' }
|
175
175
|
|
176
176
|
it_behaves_like 'non-empty config file'
|
data/spec/unit/scope_spec.rb
CHANGED
@@ -13,15 +13,15 @@ RSpec.describe A9n::Scope do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when name is other than configuration' do
|
16
|
-
let(:name) { '
|
16
|
+
let(:name) { 'google' }
|
17
17
|
it { expect(subject).not_to be_root }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '.form_file_path' do
|
22
|
-
let(:path) { 'config/a9n/
|
22
|
+
let(:path) { 'config/a9n/google.yml.example' }
|
23
23
|
subject { described_class.form_file_path(path) }
|
24
24
|
|
25
|
-
it { expect(subject.name).to eq(:
|
25
|
+
it { expect(subject.name).to eq(:google) }
|
26
26
|
end
|
27
27
|
end
|
File without changes
|
File without changes
|
File without changes
|
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.8.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-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codeclimate-test-reporter
|
@@ -132,11 +132,11 @@ files:
|
|
132
132
|
- spec/unit/scope_spec.rb
|
133
133
|
- spec/unit/struct_spec.rb
|
134
134
|
- test_app/benchmark.rb
|
135
|
+
- test_app/config/a9n.yml
|
136
|
+
- test_app/config/a9n.yml.example
|
137
|
+
- test_app/config/a9n/aws.yml
|
135
138
|
- test_app/config/a9n/cloud.yml.erb
|
136
139
|
- test_app/config/a9n/mailer.yml.example
|
137
|
-
- test_app/config/a9n/mandrill.yml
|
138
|
-
- test_app/config/configuration.yml
|
139
|
-
- test_app/config/configuration.yml.example
|
140
140
|
- test_app/config/no_defaults.yml
|
141
141
|
homepage: https://github.com/knapo/a9n
|
142
142
|
licenses:
|