heroku_pull 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 885d489c033a394d69e2f626f0603cf4205a54b2
4
- data.tar.gz: 78e5e59fef91a2dcdc525c901815dfcbefc6676a
3
+ metadata.gz: 2a6cc33636d29944af26a86bf4d22d4fe25fe56a
4
+ data.tar.gz: 920265be9e844057fdd2211e78b2dffed3663522
5
5
  SHA512:
6
- metadata.gz: efed176155c4acac02b54b03e99d77b299f7537018c83dd7764dc5cfe7038b27354c0ccc0fbaad864b66d3f17e0dc0cd922e65471241570644aba393f8cae577
7
- data.tar.gz: b654139c33ec7e6e69b4cd4e9752e6231c517b5d7a893fe27605a48964bd3fb7c406771d8e6bc23e3cbf808d3ebed845aad6f272f5aeb3beeae7e542481a3725
6
+ metadata.gz: 6eb3b46ca76fc17f3770dadaf52935469b3f729e3e8ae1343d976a63bb64d60b37b80b80bedb70b875f6de6c066c4fc412b6c5b14f81c516f8ca233d4325a35e
7
+ data.tar.gz: f6eb9a33c2929e40ea451e7defb6dd2eb1ed8d48f8c61c466e4f5dc8ae2de03fe5cc174b0b4ee718d4a53852c6cea03be8818660d946bb2e8e332cd66ef30dd6
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Heroku::Pull
2
2
 
3
+ [![Build Status](https://travis-ci.org/dabit/heroku_pull.png?branch=master)](https://travis-ci.org/dabit/heroku_pull)
4
+
3
5
  Pull the Postgres database from Heroku Rails application into your local server.
4
6
 
5
7
  ## Works great with
@@ -18,7 +20,7 @@ And then execute:
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install heroku-pull
23
+ $ gem install heroku_pull
22
24
 
23
25
  ## Usage
24
26
 
@@ -29,6 +31,13 @@ Run
29
31
  And this should automatically overwrite your local development database
30
32
  with a snapshot of the current database of your Heroku app.
31
33
 
34
+ ### Multiple apps
35
+
36
+ If you have more than one Heroku app for the same repo use the `APP` env variable
37
+
38
+ $ APP=my_target_app rake heroku:pull
39
+
40
+
32
41
  ## Contributing
33
42
 
34
43
  1. Fork it
data/lib/heroku_pull.rb CHANGED
@@ -4,25 +4,31 @@ require "yaml"
4
4
 
5
5
  module HerokuPull
6
6
  class << self
7
+ attr_accessor :app_name
8
+
7
9
  def capture
8
10
  cmd = "heroku pgbackups:capture --expire"
9
11
  puts "Capture the database..."
10
12
  puts cmd
11
- system cmd
13
+ system_with_app_name cmd
12
14
  end
13
15
 
14
16
  def download
15
17
  cmd = "wget -O #{filename} `heroku pgbackups:url`"
16
18
  puts "Download backup file..."
17
19
  puts cmd
18
- system cmd
20
+ system_with_app_name cmd
19
21
  end
20
22
 
21
23
  def restore
22
24
  cmd = "pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{database} #{filename}"
23
25
  puts "Restore local database..."
24
26
  puts cmd
25
- system cmd
27
+ system_with_app_name cmd
28
+ end
29
+
30
+ def system_with_app_name(cmd)
31
+ system(HerokuPull.app_name ? "#{cmd} --app #{HerokuPull.app_name}" : cmd)
26
32
  end
27
33
 
28
34
  def filename
@@ -6,6 +6,7 @@ module HerokuPull
6
6
  namespace :heroku do
7
7
  desc "Pull the Postgres database from Heroku into local server"
8
8
  task :pull do
9
+ HerokuPull.app_name = ENV['APP']
9
10
  HerokuPull.capture
10
11
  HerokuPull.download
11
12
  HerokuPull.restore
@@ -1,5 +1,5 @@
1
1
  module Heroku
2
2
  module Pull
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -2,19 +2,25 @@ require 'test_helper'
2
2
 
3
3
  class HerokuPullTest < Test::Unit::TestCase
4
4
  def setup
5
+ HerokuPull.app_name = nil
5
6
  stub(HerokuPull).puts
6
7
  end
7
8
 
9
+ def test_app_name
10
+ HerokuPull.app_name = "APP_NAME"
11
+ assert_equal "APP_NAME", HerokuPull.app_name
12
+ end
13
+
8
14
  def test_capture
9
15
  expected_cmd = "heroku pgbackups:capture --expire"
10
- mock(HerokuPull).system expected_cmd
16
+ mock(HerokuPull).system_with_app_name expected_cmd
11
17
 
12
18
  HerokuPull.capture
13
19
  end
14
20
 
15
21
  def test_download
16
22
  expected_cmd = "wget -O ./tmp/heroku_pull.sql `heroku pgbackups:url`"
17
- mock(HerokuPull).system expected_cmd
23
+ mock(HerokuPull).system_with_app_name expected_cmd
18
24
 
19
25
  HerokuPull.download
20
26
  end
@@ -22,11 +28,26 @@ class HerokuPullTest < Test::Unit::TestCase
22
28
  def test_restore
23
29
  stub(HerokuPull).database { "test_db" }
24
30
  expected_cmd = "pg_restore --verbose --clean --no-acl --no-owner -h localhost -d test_db ./tmp/heroku_pull.sql"
25
- mock(HerokuPull).system expected_cmd
31
+ mock(HerokuPull).system_with_app_name expected_cmd
26
32
 
27
33
  HerokuPull.restore
28
34
  end
29
35
 
36
+ def test_system_with_app_name_set
37
+ HerokuPull.app_name = "APP_NAME"
38
+ expected_cmd = "COMMAND --app APP_NAME"
39
+ mock(HerokuPull).system expected_cmd
40
+
41
+ HerokuPull.system_with_app_name "COMMAND"
42
+ end
43
+
44
+ def test_system_with_app_name_not_set
45
+ expected_cmd = "COMMAND"
46
+ mock(HerokuPull).system expected_cmd
47
+
48
+ HerokuPull.system_with_app_name expected_cmd
49
+ end
50
+
30
51
  def test_filename
31
52
  assert_equal "./tmp/heroku_pull.sql", HerokuPull.filename
32
53
  end
@@ -1,2 +1,2 @@
1
- development:
1
+ test:
2
2
  database: test_db
data/test/test_helper.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'test/unit'
2
2
 
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+
3
5
  require 'rr'
4
6
  require 'heroku_pull'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_pull
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Padilla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-05 00:00:00.000000000 Z
11
+ date: 2014-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties