bbc-cosmos-config 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bbc/cosmos/config/cosmos.rb +10 -6
- data/lib/bbc/cosmos/config/version.rb +1 -1
- data/spec/config_spec.rb +24 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a3406d1d342dfdcb5da6f16df47eae1e69ea76
|
4
|
+
data.tar.gz: 0a432c532e36143fd247538b7a99ff10d859b4f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e61dc6ea4583c0fa548a3afdeb751506da91a62a7aaaf5fcfa5976a1c56103e6337c7bca45d39ea7d190443b575f9c731ab46bb04e11df42914c7c842953b1
|
7
|
+
data.tar.gz: 68d4193def2ddaf8ec12774b28811c8ba595d5320cb989e1708af2868db9121cafb6dbdfe22ea49d85c6654da9709237a064530e12a1dfd60235b410043232a9
|
@@ -23,17 +23,21 @@ module BBC
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def component_config
|
26
|
-
load_config_from_s3? ? @aws_config.s3_config(
|
26
|
+
load_config_from_s3? ? @aws_config.s3_config(config) : config[:configuration]
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
def config
|
30
|
+
@config ||= JSON.parse(app_config_string, :symbolize_names => true)
|
31
|
+
end
|
30
32
|
|
31
|
-
def
|
32
|
-
|
33
|
+
def environment
|
34
|
+
BBC::Cosmos.production? ? config[:environment] : ENV.fetch('APP_ENV', 'development')
|
33
35
|
end
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
+
private
|
38
|
+
|
39
|
+
def load_config_from_s3?
|
40
|
+
config[:configuration].include?(:config_path) && BBC::Cosmos.production?
|
37
41
|
end
|
38
42
|
|
39
43
|
def app_config_string
|
data/spec/config_spec.rb
CHANGED
@@ -3,12 +3,22 @@ require "spec_helper"
|
|
3
3
|
describe BBC::Cosmos::Config do
|
4
4
|
|
5
5
|
subject { BBC::Cosmos::Config }
|
6
|
-
|
6
|
+
|
7
|
+
let (:expected_cosmos_config) do
|
7
8
|
{
|
8
|
-
:
|
9
|
+
:external_dependencies => {},
|
10
|
+
:secure_configuration => {},
|
11
|
+
:name => "app_name",
|
12
|
+
:environment => "test",
|
13
|
+
:configuration => {
|
14
|
+
:config_key => "config_value"
|
15
|
+
},
|
16
|
+
:resources => {}
|
9
17
|
}
|
10
18
|
end
|
11
19
|
|
20
|
+
let (:expected_config) { expected_cosmos_config[:configuration] }
|
21
|
+
|
12
22
|
describe ".app" do
|
13
23
|
describe "application config attribute" do
|
14
24
|
it "should be accessible using method notation" do
|
@@ -24,6 +34,18 @@ describe BBC::Cosmos::Config do
|
|
24
34
|
end
|
25
35
|
end
|
26
36
|
|
37
|
+
describe "#config" do
|
38
|
+
it "returns the complete cosmos config" do
|
39
|
+
expect(subject.cosmos.config).to eq(expected_cosmos_config)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#environment" do
|
44
|
+
it "returns the environment from the cosmos config" do
|
45
|
+
expect(subject.cosmos.environment).to eq('test')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
describe "#stack_name" do
|
28
50
|
it "returns the cosmos stack name" do
|
29
51
|
expect(subject.cosmos.stack_name).to eq("stack_name")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbc-cosmos-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|