Class: Spore::Parser
- Inherits:
-
Object
- Object
- Spore::Parser
- Defined in:
- lib/spore/parser.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ Parser
constructor
A new instance of Parser.
- #translate(app_id, hash) ⇒ Object
Constructor Details
#initialize(config) ⇒ Parser
Returns a new instance of Parser.
13 14 15 16 17 |
# File 'lib/spore/parser.rb', line 13 def initialize(config) @config = config spore = JSON.parse(File.read config.spore_file) translate(spore["id"], spore["envs"][config.environment]) end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
12 13 14 |
# File 'lib/spore/parser.rb', line 12 def hash @hash end |
Class Method Details
Instance Method Details
#translate(app_id, hash) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/spore/parser.rb', line 19 def translate(app_id, hash) @hash = {} hash.each do |key, value| # Translate APP_ENV to RAILS_ENV key = "RAILS_ENV" if key == "APP_ENV" @hash[key] = @config.fetch(app_id, value) end @hash end |