a9n 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/lib/a9n/ext/hash.rb +16 -8
- data/lib/a9n/loader.rb +1 -1
- data/lib/a9n/version.rb +1 -1
- data/spec/unit/loader_spec.rb +19 -8
- data/test_app/config/configuration.yml +2 -2
- data/test_app/config/configuration.yml.example +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90f0d9378a0371006614053fd5f2ba3add41dd36
|
4
|
+
data.tar.gz: e2d2b46d4acc96d2fadf7e83ee13e396b9daa988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 898bc6b5f725ce86e9323a528979c0fbf082627717b30786a8e1625d1f6b0c838964b03bdba3052526265fe5ecf8aae10f2d77d93fefb64df5ae330aca316a57
|
7
|
+
data.tar.gz: e5e42e3571bfb95ac3a5d308a40639a0d99d8d6e721384ba250fe56297e915c16adee00877e3131c7469f24854129b97791e35f9f76386485992d8fab5e0a30d
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2@a9n
|
data/.travis.yml
CHANGED
data/lib/a9n/ext/hash.rb
CHANGED
@@ -1,21 +1,29 @@
|
|
1
1
|
module A9n
|
2
2
|
class HashExt
|
3
3
|
class << self
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def deep_symbolize_keys(hash)
|
8
|
-
hash.inject({}) { |result, (key, value)|
|
9
|
-
value = deep_symbolize_keys(value) if value.is_a?(::Hash)
|
10
|
-
result[(key.to_sym rescue key) || key] = value
|
4
|
+
def deep_prepare(hash)
|
5
|
+
hash.inject({}) do |result, (key, value)|
|
6
|
+
result[(key.to_sym rescue key)] = get_value(key, value)
|
11
7
|
result
|
12
|
-
|
8
|
+
end
|
13
9
|
end
|
14
10
|
|
15
11
|
def merge(*items)
|
16
12
|
return nil if items.compact.empty?
|
17
13
|
items.compact.inject({}){|sum, item| sum.merge!(item)}
|
18
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def get_value(key, value)
|
19
|
+
if value.is_a?(::Hash)
|
20
|
+
deep_prepare(value)
|
21
|
+
elsif value.is_a?(Symbol) && value == :env
|
22
|
+
ENV[key.to_s.upcase]
|
23
|
+
else
|
24
|
+
value
|
25
|
+
end
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
data/lib/a9n/loader.rb
CHANGED
data/lib/a9n/version.rb
CHANGED
data/spec/unit/loader_spec.rb
CHANGED
@@ -13,15 +13,15 @@ describe A9n::Loader do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#load" do
|
16
|
-
let(:example_config)
|
16
|
+
let(:example_config) do
|
17
17
|
{ app_url: "http://127.0.0.1:3000", api_key: "example1234" }
|
18
|
-
|
19
|
-
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:local_config) do
|
20
21
|
{ app_host: "127.0.0.1:3000", api_key: "local1234" }
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:env) { "tropical" }
|
25
25
|
let(:config) { subject.get }
|
26
26
|
|
27
27
|
context "when no configuration file exists" do
|
@@ -122,7 +122,13 @@ describe A9n::Loader do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
before do
|
125
|
-
ENV["
|
125
|
+
ENV["ERB_DWARF"] = "erbized dwarf"
|
126
|
+
ENV["DWARF_PASSWORD"] = "dwarf123"
|
127
|
+
end
|
128
|
+
|
129
|
+
after do
|
130
|
+
ENV["ERB_DWARF"] = nil
|
131
|
+
ENV["DWARF_PASSWORD"] = nil
|
126
132
|
end
|
127
133
|
|
128
134
|
context "when file has erb extension" do
|
@@ -150,6 +156,11 @@ describe A9n::Loader do
|
|
150
156
|
it "parses erb" do
|
151
157
|
expect(subject[:erb_dwarf]).to eq("erbized dwarf")
|
152
158
|
end
|
159
|
+
|
160
|
+
it "gets valus from ENV" do
|
161
|
+
p subject
|
162
|
+
expect(subject[:dwarf_password]).to eq("dwarf123")
|
163
|
+
end
|
153
164
|
end
|
154
165
|
|
155
166
|
context "having no env and only defaults data" do
|
@@ -1,12 +1,13 @@
|
|
1
1
|
defaults:
|
2
2
|
default_dwarf: "default dwarf"
|
3
3
|
overriden_dwarf: "not yet overriden dwarf"
|
4
|
+
erb_dwarf: "<%= ENV['ERB_DWARF'] %>"
|
5
|
+
dwarf_password: :env
|
4
6
|
development:
|
5
7
|
nil_dwarf: ~
|
6
8
|
false_dwarf: false
|
7
9
|
true_dwarf: true
|
8
10
|
string_dwarf: "dwarf"
|
9
|
-
erb_dwarf: "<%= ENV['DWARF'] %>"
|
10
11
|
overriden_dwarf: "already overriden dwarf"
|
11
12
|
hash_dwarf:
|
12
13
|
dwarf_1: "hello 1"
|
@@ -16,7 +17,6 @@ test:
|
|
16
17
|
false_dwarf: false
|
17
18
|
true_dwarf: true
|
18
19
|
string_dwarf: "dwarf"
|
19
|
-
erb_dwarf: "<%= ENV['DWARF'] %>"
|
20
20
|
overriden_dwarf: "already overriden dwarf"
|
21
21
|
hash_dwarf:
|
22
22
|
dwarf_1: "hello 1"
|
@@ -1,12 +1,13 @@
|
|
1
1
|
defaults:
|
2
2
|
default_dwarf: "example default dwarf"
|
3
3
|
overriden_dwarf: "example not yet overriden dwarf"
|
4
|
+
erb_dwarf: "<%= ENV['ERB_DWARF'] %>"
|
5
|
+
dwarf_password: :env
|
4
6
|
development:
|
5
7
|
nil_dwarf: ~
|
6
8
|
false_dwarf: false
|
7
9
|
true_dwarf: true
|
8
10
|
string_dwarf: "dwarf"
|
9
|
-
erb_dwarf: "<%= ENV['DWARF'] %>"
|
10
11
|
overriden_dwarf: "example already overriden dwarf"
|
11
12
|
hash_dwarf:
|
12
13
|
dwarf_1: "hello 1"
|
@@ -16,7 +17,6 @@ test:
|
|
16
17
|
false_dwarf: false
|
17
18
|
true_dwarf: true
|
18
19
|
string_dwarf: "dwarf"
|
19
|
-
erb_dwarf: "<%= ENV['DWARF'] %>"
|
20
20
|
overriden_dwarf: "example already overriden dwarf"
|
21
21
|
hash_dwarf:
|
22
22
|
dwarf_1: "hello 1"
|
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Knapik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: a9n - ruby/rails apps configuration manager
|
14
14
|
email:
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.4.
|
69
|
+
rubygems_version: 2.4.6
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: a9n is a tool to keep ruby/rails apps extra configuration easily maintainable
|