heroku_pull 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +42 -0
- data/Rakefile +10 -0
- data/heroku-pull.gemspec +26 -0
- data/lib/heroku_pull/railtie.rb +16 -0
- data/lib/heroku_pull/version.rb +5 -0
- data/lib/heroku_pull.rb +38 -0
- data/test/cases/heroku_pull_test.rb +39 -0
- data/test/config/database.yml +2 -0
- data/test/test_helper.rb +4 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 885d489c033a394d69e2f626f0603cf4205a54b2
|
4
|
+
data.tar.gz: 78e5e59fef91a2dcdc525c901815dfcbefc6676a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: efed176155c4acac02b54b03e99d77b299f7537018c83dd7764dc5cfe7038b27354c0ccc0fbaad864b66d3f17e0dc0cd922e65471241570644aba393f8cae577
|
7
|
+
data.tar.gz: b654139c33ec7e6e69b4cd4e9752e6231c517b5d7a893fe27605a48964bd3fb7c406771d8e6bc23e3cbf808d3ebed845aad6f272f5aeb3beeae7e542481a3725
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 David Padilla
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Heroku::Pull
|
2
|
+
|
3
|
+
Pull the Postgres database from Heroku Rails application into your local server.
|
4
|
+
|
5
|
+
## Works great with
|
6
|
+
|
7
|
+
[Heroku][1] and [Postgres.app][2]
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'heroku_pull', group: :development
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install heroku-pull
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Run
|
26
|
+
|
27
|
+
$ rake heroku:pull
|
28
|
+
|
29
|
+
And this should automatically overwrite your local development database
|
30
|
+
with a snapshot of the current database of your Heroku app.
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
39
|
+
|
40
|
+
|
41
|
+
[1]: http://heroku.com
|
42
|
+
[2]: http://postgresapp.com
|
data/Rakefile
ADDED
data/heroku-pull.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'heroku_pull/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "heroku_pull"
|
8
|
+
spec.version = Heroku::Pull::VERSION
|
9
|
+
spec.authors = ["David Padilla"]
|
10
|
+
spec.email = ["david@crowdint.com"]
|
11
|
+
spec.description = %q{Pull the current Postgres database from Heroku into your local server}
|
12
|
+
spec.summary = %q{Pull the current Postgres database from Heroku into your local server}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'railties'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rr"
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/railtie'
|
2
|
+
|
3
|
+
module HerokuPull
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
rake_tasks do
|
6
|
+
namespace :heroku do
|
7
|
+
desc "Pull the Postgres database from Heroku into local server"
|
8
|
+
task :pull do
|
9
|
+
HerokuPull.capture
|
10
|
+
HerokuPull.download
|
11
|
+
HerokuPull.restore
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/heroku_pull.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "heroku_pull/version"
|
2
|
+
require "heroku_pull/railtie"
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module HerokuPull
|
6
|
+
class << self
|
7
|
+
def capture
|
8
|
+
cmd = "heroku pgbackups:capture --expire"
|
9
|
+
puts "Capture the database..."
|
10
|
+
puts cmd
|
11
|
+
system cmd
|
12
|
+
end
|
13
|
+
|
14
|
+
def download
|
15
|
+
cmd = "wget -O #{filename} `heroku pgbackups:url`"
|
16
|
+
puts "Download backup file..."
|
17
|
+
puts cmd
|
18
|
+
system cmd
|
19
|
+
end
|
20
|
+
|
21
|
+
def restore
|
22
|
+
cmd = "pg_restore --verbose --clean --no-acl --no-owner -h localhost -d #{database} #{filename}"
|
23
|
+
puts "Restore local database..."
|
24
|
+
puts cmd
|
25
|
+
system cmd
|
26
|
+
end
|
27
|
+
|
28
|
+
def filename
|
29
|
+
"./tmp/heroku_pull.sql"
|
30
|
+
end
|
31
|
+
|
32
|
+
def database(config_path = './config/database.yml')
|
33
|
+
ENV['RAILS_ENV'] ||= 'development'
|
34
|
+
config = YAML::load_file(config_path)
|
35
|
+
database = config[ENV['RAILS_ENV']]['database']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class HerokuPullTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
stub(HerokuPull).puts
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_capture
|
9
|
+
expected_cmd = "heroku pgbackups:capture --expire"
|
10
|
+
mock(HerokuPull).system expected_cmd
|
11
|
+
|
12
|
+
HerokuPull.capture
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_download
|
16
|
+
expected_cmd = "wget -O ./tmp/heroku_pull.sql `heroku pgbackups:url`"
|
17
|
+
mock(HerokuPull).system expected_cmd
|
18
|
+
|
19
|
+
HerokuPull.download
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_restore
|
23
|
+
stub(HerokuPull).database { "test_db" }
|
24
|
+
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
|
26
|
+
|
27
|
+
HerokuPull.restore
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_filename
|
31
|
+
assert_equal "./tmp/heroku_pull.sql", HerokuPull.filename
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_database
|
35
|
+
assert_equal "test_db", HerokuPull.database('test/config/database.yml')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku_pull
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Padilla
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Pull the current Postgres database from Heroku into your local server
|
70
|
+
email:
|
71
|
+
- david@crowdint.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .travis.yml
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- heroku-pull.gemspec
|
83
|
+
- lib/heroku_pull.rb
|
84
|
+
- lib/heroku_pull/railtie.rb
|
85
|
+
- lib/heroku_pull/version.rb
|
86
|
+
- test/cases/heroku_pull_test.rb
|
87
|
+
- test/config/database.yml
|
88
|
+
- test/test_helper.rb
|
89
|
+
homepage: ''
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project:
|
109
|
+
rubygems_version: 2.0.3
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Pull the current Postgres database from Heroku into your local server
|
113
|
+
test_files:
|
114
|
+
- test/cases/heroku_pull_test.rb
|
115
|
+
- test/config/database.yml
|
116
|
+
- test/test_helper.rb
|