heroku_pull 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/heroku_pull.rb +9 -3
- data/lib/heroku_pull/railtie.rb +1 -0
- data/lib/heroku_pull/version.rb +1 -1
- data/test/cases/heroku_pull_test.rb +24 -3
- data/test/config/database.yml +1 -1
- data/test/test_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a6cc33636d29944af26a86bf4d22d4fe25fe56a
|
4
|
+
data.tar.gz: 920265be9e844057fdd2211e78b2dffed3663522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eb3b46ca76fc17f3770dadaf52935469b3f729e3e8ae1343d976a63bb64d60b37b80b80bedb70b875f6de6c066c4fc412b6c5b14f81c516f8ca233d4325a35e
|
7
|
+
data.tar.gz: f6eb9a33c2929e40ea451e7defb6dd2eb1ed8d48f8c61c466e4f5dc8ae2de03fe5cc174b0b4ee718d4a53852c6cea03be8818660d946bb2e8e332cd66ef30dd6
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Heroku::Pull
|
2
2
|
|
3
|
+
[](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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/lib/heroku_pull/railtie.rb
CHANGED
data/lib/heroku_pull/version.rb
CHANGED
@@ -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).
|
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).
|
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).
|
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
|
data/test/config/database.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
test:
|
2
2
|
database: test_db
|
data/test/test_helper.rb
CHANGED
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.
|
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:
|
11
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|