bbc-cosmos-config 0.1.2 → 0.2.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: 06826ade40d88f16e273cb0099ec5a580c3e6596
4
- data.tar.gz: 9d05af314d0cbedf4007b584b1ad9d5abd69b7ae
3
+ metadata.gz: 65576a9095db870fd1b74e0b7aa89a41c888d5e4
4
+ data.tar.gz: 2dda163f88bb77a9ddebccbe264bca8f620ada17
5
5
  SHA512:
6
- metadata.gz: 7443864e61b82887a612ff0564042aa2ccf528f75699b6a84d8df7947b1573f91db6f8f2030aa959e891f67133b927f9557222e8004415f90fab90f886c057f6
7
- data.tar.gz: 67ef52b4d2807b2ff7f6e730aa6338b2ea5fbe4cb15c0cbc61652618cb36d9b3f739b5371b57a5d88fa9d73cac98eb2ae2e602c48832d6b23a5fc1e07e684e5c
6
+ metadata.gz: 2428006bfe08f0dd2b85c3aac40cc5bb761925d7857aa8440930901d61f7d4d6c90e69aef270b7fc241d9f303e2b9f5b2ce6b0cd6da875d202fb27c03b1f4697
7
+ data.tar.gz: 6247e0b3d8c74eec1e7dc3f2e9ccf21e6cdad3f02c35b9ff8d4c92e75b065c8aaf1a06f5bd4d491fd25b10bbcb80ee1f8325ca73783f11859f4f37d1371b20ba
@@ -19,18 +19,22 @@ module BBC
19
19
  @instance_id ||= BBC::Cosmos.production? ? aws_instance_id : "instance_id"
20
20
  end
21
21
 
22
- def config(config, path)
23
- @config ||= BBC::Cosmos.production? ? s3_config(config[:component_resources_bucket], path, config[:environment], config[:configuration][:commit]) : config[:configuration]
24
- end
25
-
26
22
  private
27
23
 
28
24
  def s3_config_location
29
25
  tags['AppName']
30
26
  end
31
27
 
32
- def s3_config(bucket, path, env, version)
33
- JSON.parse(@s3.buckets[bucket].objects["#{path}/#{env}/config/#{version}/#{s3_config_location}.json"].read, :symbolize_names => true)
28
+ def s3_config(config)
29
+ path = [
30
+ config[:configuration][:config_path],
31
+ config[:environment],
32
+ 'config',
33
+ config[:configuration][:commit],
34
+ "#{s3_config_location}.json"
35
+ ].join('/')
36
+
37
+ JSON.parse(@s3.buckets[config[:component_resources_bucket]].objects[path].read, :symbolize_names => true)
34
38
  end
35
39
 
36
40
  def instance
@@ -23,16 +23,17 @@ module BBC
23
23
  end
24
24
 
25
25
  def component_config
26
- @component_config ||= @aws_config.config(
27
- parse_component_config,
28
- parse_component_config[:configuration][:config_path]
29
- )
26
+ load_config_from_s3? ? @aws_config.s3_config(parse_component_config) : parse_component_config[:configuration]
30
27
  end
31
28
 
32
29
  private
33
30
 
31
+ def load_config_from_s3?
32
+ parse_component_config[:configuration].include?(:config_path) && BBC::Cosmos.production?
33
+ end
34
+
34
35
  def parse_component_config
35
- JSON.parse(app_config_string, :symbolize_names => true)
36
+ @parse_component_config ||= JSON.parse(app_config_string, :symbolize_names => true)
36
37
  end
37
38
 
38
39
  def app_config_string
@@ -1,7 +1,7 @@
1
1
  module BBC
2
2
  module Cosmos
3
3
  module Config
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbc-cosmos-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Kenny
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  version: '0'
207
207
  requirements: []
208
208
  rubyforge_project:
209
- rubygems_version: 2.0.3
209
+ rubygems_version: 2.2.2
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: Config wrapper gem for Ruby apps running on Cosmos