Class: HerokuSan::Configuration
- Inherits:
-
Object
- Object
- HerokuSan::Configuration
- Defined in:
- lib/heroku_san/configuration.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#external_configuration ⇒ Object
Returns the value of attribute external_configuration.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#stage_factory ⇒ Object
readonly
Returns the value of attribute stage_factory.
Instance Method Summary collapse
- #configured? ⇒ Boolean
- #generate_config ⇒ Object
-
#initialize(configurable, stage_factory = HerokuSan::Stage) ⇒ Configuration
constructor
A new instance of Configuration.
- #parse ⇒ Object
- #stages ⇒ Object
- #template ⇒ Object
Constructor Details
#initialize(configurable, stage_factory = HerokuSan::Stage) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 |
# File 'lib/heroku_san/configuration.rb', line 9 def initialize(configurable, stage_factory = HerokuSan::Stage) @config_file = configurable.config_file = { 'deploy' => HerokuSan::Deploy::Rails } @options = .merge(configurable. || {}) @stage_factory = stage_factory end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
3 4 5 |
# File 'lib/heroku_san/configuration.rb', line 3 def config_file @config_file end |
#configuration ⇒ Object
Returns the value of attribute configuration.
4 5 6 |
# File 'lib/heroku_san/configuration.rb', line 4 def configuration @configuration end |
#external_configuration ⇒ Object
Returns the value of attribute external_configuration.
5 6 7 |
# File 'lib/heroku_san/configuration.rb', line 5 def external_configuration @external_configuration end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/heroku_san/configuration.rb', line 6 def @options end |
#stage_factory ⇒ Object (readonly)
Returns the value of attribute stage_factory.
7 8 9 |
# File 'lib/heroku_san/configuration.rb', line 7 def stage_factory @stage_factory end |
Instance Method Details
#configured? ⇒ Boolean
30 31 32 |
# File 'lib/heroku_san/configuration.rb', line 30 def configured? !!configuration end |
#generate_config ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/heroku_san/configuration.rb', line 38 def generate_config # TODO: Convert true/false returns to success/exception if File.exists?(config_file) false else FileUtils.cp(template, config_file) true end end |
#parse ⇒ Object
18 19 20 |
# File 'lib/heroku_san/configuration.rb', line 18 def parse HerokuSan::Parser.new.parse(self) end |
#stages ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/heroku_san/configuration.rb', line 22 def stages configured? or parse configuration.inject({}) do |stages, (stage, settings)| stages[stage] = stage_factory.new(stage, settings.merge('deploy' => ([:deploy]||['deploy']))) stages end end |
#template ⇒ Object
34 35 36 |
# File 'lib/heroku_san/configuration.rb', line 34 def template File.(File.join(File.dirname(__FILE__), '../templates', 'heroku.example.yml')) end |