rake_heroku 0.0.1
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.
- data/.gitignore +17 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/TODO.md +18 -0
- data/lib/rake_heroku.rb +5 -0
- data/lib/rake_heroku/railtie.rb +10 -0
- data/lib/rake_heroku/version.rb +3 -0
- data/lib/tasks/clone.rake +27 -0
- data/rake_heroku.gemspec +24 -0
- data/spec/rake_heroku/clone_spec.rb +38 -0
- data/spec/spec_helper.rb +3 -0
- metadata +112 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Version 0.0.1
|
4
|
+
|
5
|
+
* Initial commit for the rake heroku:clone task.
|
6
|
+
* Allows cloning a database from a heroku server to another server or to your local machine.
|
7
|
+
* Requires heroku remote(s) to be set up and servers to have pgbackups installed.
|
8
|
+
* Restores to your local machine with pg_restore
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Dan Luchi
|
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,26 @@
|
|
1
|
+
# Rake Heroku #
|
2
|
+
|
3
|
+
A collection of useful scripts for interacting with heroku deployed rails applications.
|
4
|
+
|
5
|
+
## Installation ##
|
6
|
+
|
7
|
+
Eventually you will be able to add this in your Gemfile, like so:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rake_heroku'
|
11
|
+
```
|
12
|
+
|
13
|
+
But for now, just copy the rake tasks into your lib/tasks folder.
|
14
|
+
|
15
|
+
## Tasks ##
|
16
|
+
|
17
|
+
Clone a database from one server to another:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
rake heroku:clone_db from=[SERVER_NAME] to=[SERVER_NAME]
|
21
|
+
```
|
22
|
+
|
23
|
+
or to your local development environment:
|
24
|
+
```ruby
|
25
|
+
rake heroku:clone_db from=[SERVER_NAME] to=local
|
26
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Implement rake heroku:clone and test with rspec first since that seems to be more common.
|
2
|
+
Convert to minitest later once I've gotten something working.
|
3
|
+
|
4
|
+
Find some articles and examples for testing rake tasks, googling this is proving difficult
|
5
|
+
|
6
|
+
Good article from Thoughbot: http://robots.thoughtbot.com/post/11957424161/test-rake-tasks-like-a-boss
|
7
|
+
And another from Thoughbot on accepting parameters: http://robots.thoughtbot.com/post/18129303042/how-to-use-arguments-in-a-rake-task
|
8
|
+
|
9
|
+
Good article on gem development with tests: https://github.com/radar/guides/blob/master/gem-development.md
|
10
|
+
|
11
|
+
Determine standard/best configuration practices
|
12
|
+
rails g rake_heroku:setup
|
13
|
+
place configuration in config/initializers/rake_heroku.rb
|
14
|
+
|
15
|
+
Would Heroku Syntax be cleaner? How would that be implemented?
|
16
|
+
It would look something like this:
|
17
|
+
heroku db:clone --from [remote] --to [remote] (--force)
|
18
|
+
heroku apps:create [name] --config [config] --clone_db [remote] --branch [branch]
|
data/lib/rake_heroku.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :heroku do
|
2
|
+
|
3
|
+
desc "create a clean database copy from one heroku app to another"
|
4
|
+
task "clone" do
|
5
|
+
if ENV['from'].blank? || ENV['to'].blank?
|
6
|
+
puts "Usage: rake heroku:clone from=[app_name] to=[app_name]"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
sh "heroku pgbackups:capture --expire --app #{ENV['from']}"
|
11
|
+
if ENV['to'] == 'local'
|
12
|
+
db = ENV['db']
|
13
|
+
sh "rake db:reset"
|
14
|
+
sh "curl -o latest.dump `heroku pgbackups:url --app #{ENV['from']}`"
|
15
|
+
sh "pg_restore --verbose --clean --create --no-owner -h localhost #{"-d #{db}" if db} latest.dump"
|
16
|
+
else
|
17
|
+
reset = "heroku pg:reset DATABASE_URL --app #{ENV['to']}"
|
18
|
+
reset += " --confirm #{ENV['to']}" if ENV['force'] == 'true'
|
19
|
+
sh reset
|
20
|
+
url = "heroku pgbackups:url --app #{ENV['from']}"
|
21
|
+
restore = "heroku pgbackups:restore DATABASE_URL `#{url}` --app #{ENV['to']}"
|
22
|
+
restore += " --confirm #{ENV['to']}" if ENV['force'] == 'true'
|
23
|
+
sh restore
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/rake_heroku.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rake_heroku/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rake_heroku"
|
8
|
+
spec.version = RakeHeroku::VERSION
|
9
|
+
spec.authors = ["Dan Luchi"]
|
10
|
+
spec.email = ["dluchi@gmail.com"]
|
11
|
+
spec.description = %q{A collection of useful scripts for interacting with heroku deployed rails applications.}
|
12
|
+
spec.summary = %q{A collection of useful scripts for interacting with heroku deployed rails applications.}
|
13
|
+
spec.homepage = "http://github.com/danluchi/rake_heroku"
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
describe "heroku:clone from=staging to=new_server" do
|
2
|
+
# Should output the following to your shell
|
3
|
+
# heroku pgbackups:capture --expire --app staging
|
4
|
+
# heroku pg:reset DATABASE_URL --app new_server
|
5
|
+
# heroku pgbackups:restore DATABASE_URL `heroku pgbackups:url --app staging` --app new_server
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "heroku:clone from=staging to=new_server force=true" do
|
9
|
+
# Should output the following to your shell
|
10
|
+
# heroku pgbackups:capture --expire --app staging
|
11
|
+
# heroku pg:reset DATABASE_URL --app new_server --confirm new_server
|
12
|
+
# heroku pgbackups:restore DATABASE_URL `heroku pgbackups:url --app staging` --app new_server --confirm new_server
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "heroku:clone from=staging to=local" do
|
16
|
+
# Should output the following to your shell
|
17
|
+
# heroku pgbackups:capture --expire --app staging
|
18
|
+
# rake db:reset
|
19
|
+
# curl -o latest.dump `heroku pgbackups:url --app staging`
|
20
|
+
# pg_restore --verbose --clean --create --no-owner -h localhost latest.dump
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "heroku:clone from=staging to=local db=my_development" do
|
24
|
+
# Should output the following to your shell
|
25
|
+
# heroku pgbackups:capture --expire --app staging
|
26
|
+
# rake db:reset
|
27
|
+
# curl -o latest.dump `heroku pgbackups:url --app staging`
|
28
|
+
# pg_restore --verbose --clean --create --no-owner -h localhost -d my_development latest.dump
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "heroku:clone from=staging" do
|
32
|
+
# ERROR: to= must be specified
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "heroku:clone to=local" do
|
36
|
+
# ERROR: from= must be specified
|
37
|
+
end
|
38
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake_heroku
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dan Luchi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.14'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.14'
|
62
|
+
description: A collection of useful scripts for interacting with heroku deployed rails
|
63
|
+
applications.
|
64
|
+
email:
|
65
|
+
- dluchi@gmail.com
|
66
|
+
executables: []
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- CHANGELOG.md
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- TODO.md
|
77
|
+
- lib/rake_heroku.rb
|
78
|
+
- lib/rake_heroku/railtie.rb
|
79
|
+
- lib/rake_heroku/version.rb
|
80
|
+
- lib/tasks/clone.rake
|
81
|
+
- rake_heroku.gemspec
|
82
|
+
- spec/rake_heroku/clone_spec.rb
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
homepage: http://github.com/danluchi/rake_heroku
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.8.25
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: A collection of useful scripts for interacting with heroku deployed rails
|
109
|
+
applications.
|
110
|
+
test_files:
|
111
|
+
- spec/rake_heroku/clone_spec.rb
|
112
|
+
- spec/spec_helper.rb
|