lib/bbc/cosmos/config/cosmos.rb in bbc-cosmos-config-0.2.0 vs lib/bbc/cosmos/config/cosmos.rb in bbc-cosmos-config-0.3.0
- old
+ new
@@ -21,20 +21,24 @@
def component_name
@aws_config.tags["Component"].downcase
end
def component_config
- load_config_from_s3? ? @aws_config.s3_config(parse_component_config) : parse_component_config[:configuration]
+ load_config_from_s3? ? @aws_config.s3_config(config) : config[:configuration]
end
- private
+ def config
+ @config ||= JSON.parse(app_config_string, :symbolize_names => true)
+ end
- def load_config_from_s3?
- parse_component_config[:configuration].include?(:config_path) && BBC::Cosmos.production?
+ def environment
+ BBC::Cosmos.production? ? config[:environment] : ENV.fetch('APP_ENV', 'development')
end
- def parse_component_config
- @parse_component_config ||= JSON.parse(app_config_string, :symbolize_names => true)
+ private
+
+ def load_config_from_s3?
+ config[:configuration].include?(:config_path) && BBC::Cosmos.production?
end
def app_config_string
File.open(config_location).read
end