Module: HerokuPull
- Defined in:
- lib/heroku_pull.rb,
lib/heroku_pull/railtie.rb
Defined Under Namespace
Classes: Railtie
Class Attribute Summary collapse
-
.app_name ⇒ Object
Returns the value of attribute app_name.
Class Method Summary collapse
- .capture ⇒ Object
- .cmd_with_app_name(cmd) ⇒ Object
- .database(config_path = './config/database.yml') ⇒ Object
- .download ⇒ Object
- .filename ⇒ Object
- .restore ⇒ Object
Class Attribute Details
.app_name ⇒ Object
Returns the value of attribute app_name.
7 8 9 |
# File 'lib/heroku_pull.rb', line 7 def app_name @app_name end |
Class Method Details
.capture ⇒ Object
9 10 11 12 13 14 |
# File 'lib/heroku_pull.rb', line 9 def capture cmd = "heroku pgbackups:capture --expire" puts "Capture the database..." puts cmd system cmd_with_app_name(cmd) end |
.cmd_with_app_name(cmd) ⇒ Object
30 31 32 |
# File 'lib/heroku_pull.rb', line 30 def cmd_with_app_name(cmd) (HerokuPull.app_name ? "#{cmd} --app #{HerokuPull.app_name}" : cmd) end |
.database(config_path = './config/database.yml') ⇒ Object
38 39 40 41 42 |
# File 'lib/heroku_pull.rb', line 38 def database(config_path = './config/database.yml') ENV['RAILS_ENV'] ||= 'development' config = YAML::load_file(config_path) database = config[ENV['RAILS_ENV']]['database'] end |
.download ⇒ Object
16 17 18 19 20 21 |
# File 'lib/heroku_pull.rb', line 16 def download cmd = "wget -O #{filename} `#{cmd_with_app_name("heroku pgbackups:url")}`" puts "Download backup file..." puts cmd system cmd end |
.filename ⇒ Object
34 35 36 |
# File 'lib/heroku_pull.rb', line 34 def filename "./tmp/heroku_pull.sql" end |
.restore ⇒ Object
23 24 25 26 27 28 |
# File 'lib/heroku_pull.rb', line 23 def restore cmd = "pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{database} #{filename}" puts "Restore local database..." puts cmd system cmd end |