Class: Maguro::Heroku
- Inherits:
-
Object
- Object
- Maguro::Heroku
- Defined in:
- lib/maguro/heroku.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#organization ⇒ Object
readonly
Returns the value of attribute organization.
-
#production_name ⇒ Object
readonly
Returns the value of attribute production_name.
-
#staging_name ⇒ Object
readonly
Returns the value of attribute staging_name.
Instance Method Summary collapse
- #add_database(app_name) ⇒ Object
-
#add_pg_backup(app_name, length = "month") ⇒ Object
addons.heroku.com/pgbackups length can be “week” or “month”.
- #create ⇒ Object
- #create_app(app_name, remote_name) ⇒ Object
-
#initialize(builder, app_name, organization) ⇒ Heroku
constructor
A new instance of Heroku.
- #push ⇒ Object
Constructor Details
#initialize(builder, app_name, organization) ⇒ Heroku
Returns a new instance of Heroku.
6 7 8 9 10 11 12 |
# File 'lib/maguro/heroku.rb', line 6 def initialize(builder, app_name, organization) @builder = builder @app_name = app_name.gsub(/[_ ]/,'-') @organization = organization @production_name = "#{@organization}-#{@app_name}" @staging_name = "#{@organization}-#{@app_name}-staging" end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
4 5 6 |
# File 'lib/maguro/heroku.rb', line 4 def app_name @app_name end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
4 5 6 |
# File 'lib/maguro/heroku.rb', line 4 def builder @builder end |
#organization ⇒ Object (readonly)
Returns the value of attribute organization.
4 5 6 |
# File 'lib/maguro/heroku.rb', line 4 def organization @organization end |
#production_name ⇒ Object (readonly)
Returns the value of attribute production_name.
4 5 6 |
# File 'lib/maguro/heroku.rb', line 4 def production_name @production_name end |
#staging_name ⇒ Object (readonly)
Returns the value of attribute staging_name.
4 5 6 |
# File 'lib/maguro/heroku.rb', line 4 def staging_name @staging_name end |
Instance Method Details
#add_database(app_name) ⇒ Object
19 20 21 |
# File 'lib/maguro/heroku.rb', line 19 def add_database(app_name) builder.run "heroku addons:add heroku-postgresql --app #{app_name}" end |
#add_pg_backup(app_name, length = "month") ⇒ Object
addons.heroku.com/pgbackups length can be “week” or “month”
25 26 27 |
# File 'lib/maguro/heroku.rb', line 25 def add_pg_backup(app_name, length="month") builder.run "heroku addons:add pgbackups:auto-#{length} --app #{app_name}" end |
#create ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/maguro/heroku.rb', line 29 def create create_app(staging_name, "staging") create_app(production_name, "production") add_database(staging_name) add_database(production_name) add_pg_backup(staging_name, "week") add_pg_backup(production_name) end |
#create_app(app_name, remote_name) ⇒ Object
14 15 16 |
# File 'lib/maguro/heroku.rb', line 14 def create_app(app_name, remote_name) builder.run "heroku apps:create #{app_name} --remote #{remote_name}" end |
#push ⇒ Object
40 41 42 43 |
# File 'lib/maguro/heroku.rb', line 40 def push builder.git push: "production master:master" builder.git push: "staging master:master" end |