bbc-cosmos-config 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65576a9095db870fd1b74e0b7aa89a41c888d5e4
4
- data.tar.gz: 2dda163f88bb77a9ddebccbe264bca8f620ada17
3
+ metadata.gz: e7a3406d1d342dfdcb5da6f16df47eae1e69ea76
4
+ data.tar.gz: 0a432c532e36143fd247538b7a99ff10d859b4f3
5
5
  SHA512:
6
- metadata.gz: 2428006bfe08f0dd2b85c3aac40cc5bb761925d7857aa8440930901d61f7d4d6c90e69aef270b7fc241d9f303e2b9f5b2ce6b0cd6da875d202fb27c03b1f4697
7
- data.tar.gz: 6247e0b3d8c74eec1e7dc3f2e9ccf21e6cdad3f02c35b9ff8d4c92e75b065c8aaf1a06f5bd4d491fd25b10bbcb80ee1f8325ca73783f11859f4f37d1371b20ba
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(parse_component_config) : parse_component_config[:configuration]
26
+ load_config_from_s3? ? @aws_config.s3_config(config) : config[:configuration]
27
27
  end
28
28
 
29
- private
29
+ def config
30
+ @config ||= JSON.parse(app_config_string, :symbolize_names => true)
31
+ end
30
32
 
31
- def load_config_from_s3?
32
- parse_component_config[:configuration].include?(:config_path) && BBC::Cosmos.production?
33
+ def environment
34
+ BBC::Cosmos.production? ? config[:environment] : ENV.fetch('APP_ENV', 'development')
33
35
  end
34
36
 
35
- def parse_component_config
36
- @parse_component_config ||= JSON.parse(app_config_string, :symbolize_names => true)
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
@@ -1,7 +1,7 @@
1
1
  module BBC
2
2
  module Cosmos
3
3
  module Config
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
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
- let (:expected_config) do
6
+
7
+ let (:expected_cosmos_config) do
7
8
  {
8
- :config_key => "config_value"
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.2.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 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk