Class: HerokuRails::HerokuTargets
- Inherits:
-
Object
- Object
- HerokuRails::HerokuTargets
- Defined in:
- lib/heroku_rails/heroku_targets.rb
Defined Under Namespace
Classes: HerokuTarget, LocalProxy, TargetsContainer
Constant Summary collapse
- DEFAULTS_KEY =
"_defaults"
Instance Attribute Summary collapse
-
#staging_targets ⇒ Object
readonly
Returns the value of attribute staging_targets.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(targets_hash) ⇒ HerokuTargets
constructor
A new instance of HerokuTargets.
Constructor Details
#initialize(targets_hash) ⇒ HerokuTargets
Returns a new instance of HerokuTargets.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/heroku_rails/heroku_targets.rb', line 22 def initialize(targets_hash) defaults = if targets_hash.keys.first == DEFAULTS_KEY targets_hash.delete(DEFAULTS_KEY) else {} end specified = targets_hash.collect { |name, values| heroku_target = HerokuTarget.new(defaults.merge(values), name) [heroku_target.heroku_app, heroku_target] } built_in = [["local", LocalProxy.new(defaults)]] @targets = TargetsContainer[(specified + built_in)].freeze @staging_targets = TargetsContainer[@targets.select { |_name, target| target.staging? }] end |
Instance Attribute Details
#staging_targets ⇒ Object (readonly)
Returns the value of attribute staging_targets.
18 19 20 |
# File 'lib/heroku_rails/heroku_targets.rb', line 18 def staging_targets @staging_targets end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
18 19 20 |
# File 'lib/heroku_rails/heroku_targets.rb', line 18 def targets @targets end |
Class Method Details
.from_file(yaml_file) ⇒ Object
13 14 15 |
# File 'lib/heroku_rails/heroku_targets.rb', line 13 def from_file(yaml_file) new(YAML.safe_load(File.read(yaml_file))) end |
.from_string(heroku_targets_yml) ⇒ Object
9 10 11 |
# File 'lib/heroku_rails/heroku_targets.rb', line 9 def from_string(heroku_targets_yml) new(YAML.safe_load(heroku_targets_yml)) end |