Class: HerokuRails::HerokuTargets::HerokuTarget
- Inherits:
-
Object
- Object
- HerokuRails::HerokuTargets::HerokuTarget
- Defined in:
- lib/heroku_rails/heroku_targets.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #database_url ⇒ Object
- #db_color ⇒ Object
- #deploy_ref ⇒ Object
- #display_name ⇒ Object
- #dump_filename ⇒ Object
- #git_remote ⇒ Object
- #heroku_app ⇒ Object
-
#initialize(values_hash, name = nil) ⇒ HerokuTarget
constructor
A new instance of HerokuTarget.
- #local? ⇒ Boolean
- #repository ⇒ Object
- #required_value(required_name) ⇒ Object
- #staging? ⇒ Boolean
- #to_s ⇒ Object
- #trackable_release_stage ⇒ Object
Constructor Details
#initialize(values_hash, name = nil) ⇒ HerokuTarget
Returns a new instance of HerokuTarget.
50 51 52 53 54 55 56 |
# File 'lib/heroku_rails/heroku_targets.rb', line 50 def initialize(values_hash, name = nil) @values = values_hash.symbolize_keys.freeze @name = name.to_sym if name i[heroku_app git_remote deploy_ref].each do |required_name| raise required_value(required_name) unless @values[required_name] || local? end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
48 49 50 |
# File 'lib/heroku_rails/heroku_targets.rb', line 48 def name @name end |
Instance Method Details
#database_url ⇒ Object
78 79 80 |
# File 'lib/heroku_rails/heroku_targets.rb', line 78 def database_url @values[:database_url] end |
#db_color ⇒ Object
90 91 92 |
# File 'lib/heroku_rails/heroku_targets.rb', line 90 def db_color @values[:db_color] || "DATABASE" end |
#deploy_ref ⇒ Object
86 87 88 |
# File 'lib/heroku_rails/heroku_targets.rb', line 86 def deploy_ref @values[:deploy_ref] end |
#display_name ⇒ Object
70 71 72 |
# File 'lib/heroku_rails/heroku_targets.rb', line 70 def display_name @values[:display_name] || @values[:heroku_app] end |
#dump_filename ⇒ Object
102 103 104 |
# File 'lib/heroku_rails/heroku_targets.rb', line 102 def dump_filename File.("tmp/latest_#{heroku_app}_backup.dump") end |
#git_remote ⇒ Object
82 83 84 |
# File 'lib/heroku_rails/heroku_targets.rb', line 82 def git_remote @values[:git_remote] end |
#heroku_app ⇒ Object
74 75 76 |
# File 'lib/heroku_rails/heroku_targets.rb', line 74 def heroku_app @values[:heroku_app] end |
#local? ⇒ Boolean
66 67 68 |
# File 'lib/heroku_rails/heroku_targets.rb', line 66 def local? false end |
#repository ⇒ Object
94 95 96 |
# File 'lib/heroku_rails/heroku_targets.rb', line 94 def repository @values[:repository] || raise(required_value(:repository)) end |
#required_value(required_name) ⇒ Object
58 59 60 |
# File 'lib/heroku_rails/heroku_targets.rb', line 58 def required_value(required_name) ArgumentError.new("please specify '#{required_name}:' ") end |
#staging? ⇒ Boolean
62 63 64 |
# File 'lib/heroku_rails/heroku_targets.rb', line 62 def staging? @values[:staging] end |
#to_s ⇒ Object
98 99 100 |
# File 'lib/heroku_rails/heroku_targets.rb', line 98 def to_s display_name end |
#trackable_release_stage ⇒ Object
106 107 108 |
# File 'lib/heroku_rails/heroku_targets.rb', line 106 def trackable_release_stage @values[:trackable_release_stage].presence || (staging? ? "staging" : "production") end |