a9n 0.4.6 → 0.4.7
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 +1 -1
- data/a9n.gemspec +2 -0
- data/lib/a9n.rb +7 -5
- data/lib/a9n/ext/hash.rb +1 -1
- data/lib/a9n/loader.rb +2 -2
- data/lib/a9n/scope.rb +2 -2
- data/lib/a9n/struct.rb +1 -1
- data/lib/a9n/version.rb +1 -1
- data/spec/integration/a9n_spec.rb +3 -1
- data/spec/unit/a9n_spec.rb +2 -2
- data/spec/unit/loader_spec.rb +17 -8
- data/spec/unit/struct_spec.rb +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: 6c42b5f9aaf76bc887465a6fdd0a79ee562d9295
|
4
|
+
data.tar.gz: f0451023f9ef4e7868040ed028ca0c7c375a6672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b3d29df86f51828f13546861bb0839424a14606d6724798ae7893c43aa06200899693e6267d538f0167d9a062c88776e2721c1363d8879b2eea50e2860b673c
|
7
|
+
data.tar.gz: d972cf3270b4b97f87aae0f7806b4b6c2fbd5f917150c4a80ec8b6686f3eb5a7250f8bf68be1ef0f77189110cc908c2e290f9e77104f1ccca50a5522a3d827c8
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ directory. When none fo these files exists, `A9n::MissingConfigurationFile`
|
|
29
29
|
exception is thrown.
|
30
30
|
If both file exist, content of `configuration.yml` is validated. It means that
|
31
31
|
all keys existing in example file must exist in local file - in case of missing
|
32
|
-
keys `A9n::
|
32
|
+
keys `A9n::MissingConfigurationVariablesError` is thrown with the explanation what is missing.
|
33
33
|
|
34
34
|
Set application root and load configuration by adding to your `application.rb` or `environment.rb` right
|
35
35
|
after budler requires:
|
data/a9n.gemspec
CHANGED
data/lib/a9n.rb
CHANGED
@@ -9,10 +9,11 @@ require "erb"
|
|
9
9
|
module A9n
|
10
10
|
extend SingleForwardable
|
11
11
|
|
12
|
-
class
|
13
|
-
class
|
14
|
-
class
|
15
|
-
class
|
12
|
+
class ConfigurationNotLoadedError < StandardError; end
|
13
|
+
class MissingConfigurationDataError < StandardError; end
|
14
|
+
class MissingConfigurationVariablesError < StandardError; end
|
15
|
+
class NoSuchConfigurationVariableError < StandardError; end
|
16
|
+
class MissingEnvVariableError < StandardError; end
|
16
17
|
|
17
18
|
EXTENSION_LIST = "{yml,yml.erb,yml.example,yml.erb.example}"
|
18
19
|
|
@@ -49,7 +50,8 @@ module A9n
|
|
49
50
|
defined?(Rails) ? Rails : nil
|
50
51
|
end
|
51
52
|
|
52
|
-
def get_env_var(name)
|
53
|
+
def get_env_var(name, strict = false)
|
54
|
+
raise MissingEnvVariableError.new(name) if strict && !ENV.key?(name)
|
53
55
|
ENV[name]
|
54
56
|
end
|
55
57
|
|
data/lib/a9n/ext/hash.rb
CHANGED
data/lib/a9n/loader.rb
CHANGED
@@ -22,7 +22,7 @@ module A9n
|
|
22
22
|
example_config = self.class.load_yml(example_file, scope, env)
|
23
23
|
|
24
24
|
if local_config.nil? && example_config.nil?
|
25
|
-
raise A9n::
|
25
|
+
raise A9n::MissingConfigurationDataError.new("Configuration data for *#{env}* env was not found in neither *#{example_file}* nor *#{local_file}*")
|
26
26
|
end
|
27
27
|
|
28
28
|
if !local_config.nil? && !example_config.nil?
|
@@ -57,7 +57,7 @@ module A9n
|
|
57
57
|
def verify!(local, example)
|
58
58
|
missing_keys = example.keys - local.keys
|
59
59
|
if missing_keys.any?
|
60
|
-
raise A9n::
|
60
|
+
raise A9n::MissingConfigurationVariablesError.new("Following variables are missing in #{local_file} file: #{missing_keys.join(",")}")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/lib/a9n/scope.rb
CHANGED
data/lib/a9n/struct.rb
CHANGED
data/lib/a9n/version.rb
CHANGED
@@ -5,6 +5,8 @@ RSpec.describe A9n do
|
|
5
5
|
|
6
6
|
before do
|
7
7
|
clean_singleton(subject)
|
8
|
+
ENV["ERB_DWARF"] = "erbized dwarf"
|
9
|
+
ENV["DWARF_PASSWORD"] = "dwarf123"
|
8
10
|
ENV["MANDRILL_API_KEY"] = "ASDF1234"
|
9
11
|
ENV["API_KEY"] = "XYZ999"
|
10
12
|
subject.app = double(env: env)
|
@@ -34,7 +36,7 @@ RSpec.describe A9n do
|
|
34
36
|
end
|
35
37
|
|
36
38
|
it do
|
37
|
-
expect { subject.invalid }.to raise_error(A9n::
|
39
|
+
expect { subject.invalid }.to raise_error(A9n::NoSuchConfigurationVariableError)
|
38
40
|
end
|
39
41
|
|
40
42
|
it do
|
data/spec/unit/a9n_spec.rb
CHANGED
@@ -228,7 +228,7 @@ RSpec.describe A9n do
|
|
228
228
|
|
229
229
|
it do
|
230
230
|
expect(subject.storage).to be_empty
|
231
|
-
expect { subject.whatever }.to raise_error(A9n::
|
231
|
+
expect { subject.whatever }.to raise_error(A9n::NoSuchConfigurationVariableError)
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
@@ -239,7 +239,7 @@ RSpec.describe A9n do
|
|
239
239
|
end
|
240
240
|
|
241
241
|
it do
|
242
|
-
expect { subject.whatever }.to raise_error(A9n::
|
242
|
+
expect { subject.whatever }.to raise_error(A9n::NoSuchConfigurationVariableError)
|
243
243
|
end
|
244
244
|
end
|
245
245
|
end
|
data/spec/unit/loader_spec.rb
CHANGED
@@ -33,7 +33,7 @@ RSpec.describe A9n::Loader do
|
|
33
33
|
it "raises expection" do
|
34
34
|
expect {
|
35
35
|
subject.load
|
36
|
-
}.to raise_error(A9n::
|
36
|
+
}.to raise_error(A9n::MissingConfigurationDataError)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -48,7 +48,7 @@ RSpec.describe A9n::Loader do
|
|
48
48
|
it { expect(config.api_key).to eq("example1234") }
|
49
49
|
|
50
50
|
it do
|
51
|
-
expect { config.app_host }.to raise_error(A9n::
|
51
|
+
expect { config.app_host }.to raise_error(A9n::NoSuchConfigurationVariableError)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -63,7 +63,7 @@ RSpec.describe A9n::Loader do
|
|
63
63
|
it { expect(config.api_key).to eq("local1234") }
|
64
64
|
|
65
65
|
it do
|
66
|
-
expect { config.app_url }.to raise_error(A9n::
|
66
|
+
expect { config.app_url }.to raise_error(A9n::NoSuchConfigurationVariableError)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -79,7 +79,7 @@ RSpec.describe A9n::Loader do
|
|
79
79
|
it { expect(config.api_key).to eq("example1234") }
|
80
80
|
|
81
81
|
it do
|
82
|
-
expect { config.app_host }.to raise_error(A9n::
|
82
|
+
expect { config.app_host }.to raise_error(A9n::NoSuchConfigurationVariableError)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -94,7 +94,7 @@ RSpec.describe A9n::Loader do
|
|
94
94
|
it "raises expection with missing variables names" do
|
95
95
|
expect {
|
96
96
|
subject.load
|
97
|
-
}.to raise_error(A9n::
|
97
|
+
}.to raise_error(A9n::MissingConfigurationVariablesError, /#{missing_variables_names.join(", ")}/)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -124,8 +124,8 @@ RSpec.describe A9n::Loader do
|
|
124
124
|
end
|
125
125
|
|
126
126
|
after do
|
127
|
-
ENV
|
128
|
-
ENV
|
127
|
+
ENV.delete("ERB_DWARF")
|
128
|
+
ENV.delete("DWARF_PASSWORD")
|
129
129
|
end
|
130
130
|
|
131
131
|
context "when file has erb extension" do
|
@@ -155,9 +155,18 @@ RSpec.describe A9n::Loader do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it "gets valus from ENV" do
|
158
|
-
p subject
|
159
158
|
expect(subject[:dwarf_password]).to eq("dwarf123")
|
160
159
|
end
|
160
|
+
|
161
|
+
it "raises exception when ENV var is not set" do
|
162
|
+
ENV.delete("DWARF_PASSWORD")
|
163
|
+
expect{ subject[:dwarf_password] }.to raise_error(A9n::MissingEnvVariableError)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "raises exception when ENV var is set to nil" do
|
167
|
+
ENV["DWARF_PASSWORD"] = nil
|
168
|
+
expect{ subject[:dwarf_password] }.to raise_error(A9n::MissingEnvVariableError)
|
169
|
+
end
|
161
170
|
end
|
162
171
|
|
163
172
|
context "having no env and only defaults data" do
|
data/spec/unit/struct_spec.rb
CHANGED
@@ -33,7 +33,7 @@ RSpec.describe A9n::Struct do
|
|
33
33
|
it "raises error on accessin invalid attribute" do
|
34
34
|
expect {
|
35
35
|
subject.dwarf
|
36
|
-
}.to raise_error(A9n::
|
36
|
+
}.to raise_error(A9n::NoSuchConfigurationVariableError, "dwarf")
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -106,7 +106,7 @@ RSpec.describe A9n::Struct do
|
|
106
106
|
it "raises exception when value not exists" do
|
107
107
|
expect {
|
108
108
|
subject.non_existing_dwarf
|
109
|
-
}.to raise_error(A9n::
|
109
|
+
}.to raise_error(A9n::NoSuchConfigurationVariableError)
|
110
110
|
end
|
111
111
|
|
112
112
|
describe "#[]" do
|
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.7
|
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-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: a9n - ruby/rails apps configuration manager
|
14
14
|
email:
|
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
61
|
requirements:
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: '0'
|
64
|
+
version: '2.0'
|
65
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ">="
|