bbc-cosmos-config 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79c7e6e9d25bd0b420f64c1ff9a40d7169213853
4
- data.tar.gz: a75a6eec5d9c383947fe9acf4a177762160979f7
3
+ metadata.gz: b47f0a25aa77447781e9ab8e3fd92bf05dbb196a
4
+ data.tar.gz: de2a7788432ed15f1dbac720067e0a78d264c6a2
5
5
  SHA512:
6
- metadata.gz: ec8c2680261eaf01c8d63c8908e32d766aba95f639d251f9acb78048fc95f6364108dd169d3c1f59b0be1f87cb6d8b7555226929e6b1cf41013ef6098fa44391
7
- data.tar.gz: b7ab0af393e5cf8ec8161e2c475499122aca053dda495fe2d2a8167851e4442d6a4251b4dea807072fb368dcf4d2f637d6960be801f6101e05342152f7612d9f
6
+ metadata.gz: 6405bb3f1d94bb1ac2e4737fc0c499e446633d6fff01d7298dfb9ba5700a4ca8f5a08383c7b008efd2ff6321539bed76d30ccc307cedcde1d18aeb9abc4ede7d
7
+ data.tar.gz: 8f28b67717086d440d742afa00a743436ff45a929591f52ed205370012ff39bc0087d1ed10b12caba0cac2835290a71f1b128d7ac04397af81092b381bdbe588
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Bbc::Cosmos::Config
1
+ # BBC::Cosmos::Config
2
2
 
3
- TODO: Write a gem description
3
+ Abstracts logic (required by multiple other BBC specific gems) surrounding configuration data loading and access.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,11 +18,19 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ```
22
+ require "bbc/cosmos/config"
23
+
24
+ BBC::Cosmos.production? # => true/false depending on ENV["APP_ENV"]
25
+
26
+ BBC::Cosmos::Config.aws # => returns object that provides methods for accessing AWS information
27
+ BBC::Cosmos::Config.cosmos # => returns object that provides methods for accessing Cosmos information
28
+ BBC::Cosmos::Config.app # => returns object that provides methods for specific json configuration key values
29
+ ```
22
30
 
23
31
  ## Contributing
24
32
 
25
- 1. Fork it ( http://github.com/<my-github-username>/bbc-cosmos-config/fork )
33
+ 1. Fork it ( http://github.com/BBC-News/bbc-cosmos-config/fork )
26
34
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
35
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
36
  4. Push to the branch (`git push origin my-new-feature`)
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["kenoir@gmail.com"]
11
11
  spec.summary = "Config wrapper gem for Ruby apps running on Cosmos"
12
12
  spec.description = "Does what is says in the summary"
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/BBC-News/bbc-cosmos-config"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -14,7 +14,7 @@ module BBC
14
14
 
15
15
  module Config
16
16
  def self.aws
17
- @@aws_config ||= AWS.new(::AWS::EC2.new)
17
+ @@aws_config ||= AWS.new(::AWS::EC2.new, ::AWS::S3.new)
18
18
  end
19
19
 
20
20
  def self.cosmos
@@ -2,8 +2,9 @@ module BBC
2
2
  module Cosmos
3
3
  module Config
4
4
  class AWS
5
- def initialize(ec2)
5
+ def initialize(ec2, s3)
6
6
  @ec2 = ec2
7
+ @s3 = s3
7
8
  end
8
9
 
9
10
  def tags
@@ -18,8 +19,20 @@ module BBC
18
19
  BBC::Cosmos.production? ? aws_instance_id : "instance_id"
19
20
  end
20
21
 
22
+ def config(config, path)
23
+ BBC::Cosmos.production? ? s3_config(config[:component_resources_bucket], path, config[:configuration][:commit]) : config[:configuration]
24
+ end
25
+
21
26
  private
22
27
 
28
+ def s3_config_location
29
+ tags['Renderer']
30
+ end
31
+
32
+ def s3_config(bucket, path, version)
33
+ JSON.parse(@s3.buckets[bucket].objects["#{path}/config/#{version}/#{s3_config_location}.json"], :symbolize_names => true)
34
+ end
35
+
23
36
  def instance
24
37
  BBC::Cosmos.production? ? aws_instance : dummy_instance
25
38
  end
@@ -19,7 +19,7 @@ module BBC
19
19
  end
20
20
 
21
21
  def component_config
22
- @component_config ||= parse_component_config[:configuration]
22
+ @component_config ||= @aws_config.config(parse_component_config, parse_component_config[:configuration][:path])
23
23
  end
24
24
 
25
25
  private
@@ -1,7 +1,7 @@
1
1
  module BBC
2
2
  module Cosmos
3
3
  module Config
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
6
6
  end
7
7
  end
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.0.4
4
+ version: 0.0.5
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-03-31 00:00:00.000000000 Z
11
+ date: 2014-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -186,7 +186,7 @@ files:
186
186
  - spec/config_spec.rb
187
187
  - spec/fixtures/app_config.json
188
188
  - spec/spec_helper.rb
189
- homepage: ''
189
+ homepage: https://github.com/BBC-News/bbc-cosmos-config
190
190
  licenses:
191
191
  - MIT
192
192
  metadata: {}