heroku_rake_tasks 0.1.0 → 0.1.1

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: 86ed25399f37aa9db25f8c50a8ca622f86bf0a9a
4
- data.tar.gz: e3e14f3e03703807c116c635086f86d4dade8f46
3
+ metadata.gz: 3b303a0211668bf5a2186b52210cc44f55fd75fd
4
+ data.tar.gz: eb42d427461888c6adf1bcf3ba570f963890a5ac
5
5
  SHA512:
6
- metadata.gz: 6541b8da3b449195a7fae5a441f1a636f579500accf75d823ae4f3c3a85c4031cc61ca33043bd6c4e1096e41e369410de71a2429600ab009c80b3097ef857d2c
7
- data.tar.gz: 57d1cd16f5177c832ebf5569a7cc16297ed810b7db644413278f665d482c31cbb56526384c22115f2c02f3503f5f812c105b981d28b4af9f3d3600ed01c7c80b
6
+ metadata.gz: acd778069f1637e8a6fcf1649497ee844f5a6713e59f2068b6747e5681b4c8f9317a5f7b93b4144caf1043170f8316aa6d5931ffb5b6f344503cb3779dc6f43b
7
+ data.tar.gz: c36d7c71ca6e9de61a2bb961fd0bec6020c42582ee6963cc7626e73f31e4de3463b0637462823de176d649e76909e902ea04ef6b300d5892f1c8f941535a39d5
data/README.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # HerokuRakeTasks
2
2
 
3
- TODO: Write a gem description
3
+ Rake tasks to manage an Heroku Application
4
+
5
+ [![Gem Version](http://img.shields.io/gem/v/heroku_rake_tasks.svg)][gem]
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/bencolon/heroku_rake_tasks.svg)][codeclimate]
7
+ [![Dependency Status](http://img.shields.io/gemnasium/bencolon/heroku_rake_tasks.svg)][gemnasium]
8
+
9
+ [gem]: https://rubygems.org/gems/heroku_rake_tasks
10
+ [codeclimate]: https://codeclimate.com/github/bencolon/heroku_rake_tasks
11
+ [gemnasium]: https://gemnasium.com/bencolon/heroku_rake_tasks
4
12
 
5
13
  ## Installation
6
14
 
@@ -18,7 +26,22 @@ Or install it yourself as:
18
26
 
19
27
  ## Usage
20
28
 
21
- TODO: Write usage instructions here
29
+ ```bash
30
+ rake h:config # Display the application env vars
31
+ rake h:console # Start a Rails console
32
+ rake h:db:dump # Dump the remote database to ./remote.dump
33
+ rake h:db:restore # Restore the local database from ./remote.dump
34
+ rake h:db:sync # Sync the remote database to the local one
35
+ rake h:dbconsole # Start a DB console
36
+ rake h:deploy # Deploy the application
37
+ rake h:deploy:commits # Show the deployment-pending commits log
38
+ rake h:deploy:diff # Show the deployment-pending source code changes
39
+ rake h:deploy:migrate # Deploy the application and run the migration(s)
40
+ rake h:logs # Display recent log output for the application
41
+ rake h:logs:tail # Tail the logs for the application
42
+ rake h:ps # List the application dynos
43
+ rake h:restart # Restart the application
44
+ ```
22
45
 
23
46
  ## Contributing
24
47
 
@@ -1,3 +1,3 @@
1
1
  module HerokuRakeTasks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,33 +1,58 @@
1
1
 
2
2
  namespace :h do
3
-
4
3
  desc 'Deploy the application'
5
4
  task :deploy do
6
- bundlerize { sh "git push #{remote} origin/#{deploy_branch}:master" }
5
+ deploy
7
6
  end
8
7
 
9
8
  namespace :deploy do
10
9
  desc 'Deploy the application and run the migration(s)'
11
- task :deploy do
10
+ task :migrate do
12
11
  bundlerize { sh "heroku maintenance:on -r #{remote}" }
13
- bundlerize { sh "git push #{remote} origin/#{deploy_branch}:master" }
12
+ deploy
14
13
  bundlerize { sh "heroku run rake db:migrate -r #{remote}" }
15
14
  bundlerize { sh "heroku restart -r #{remote}" }
16
15
  bundlerize { sh "heroku maintenance:off -r #{remote}" }
17
16
  end
17
+
18
+ desc 'Show the deployment-pending commits log'
19
+ task :commits do
20
+ bundlerize { sh "git log origin/dev...#{remote}/master --oneline --graph --decorate --no-merges" }
21
+ end
22
+
23
+ desc 'Show the deployment-pending source code changes'
24
+ task :diff do
25
+ bundlerize { sh "git diff origin/dev #{remote}/master --name-only" }
26
+ end
18
27
  end
19
28
 
20
29
  desc 'Display recent log output for the application'
21
30
  task :logs do
22
31
  bundlerize { sh "heroku logs -r #{remote}" }
23
- no_warning
24
32
  end
25
33
 
26
34
  namespace :logs do
27
35
  desc 'Tail the logs for the application'
28
36
  task :tail do
29
37
  bundlerize { sh "heroku logs -t -r #{remote}" }
30
- no_warning
38
+ end
39
+ end
40
+
41
+ namespace :db do
42
+ desc 'Sync the remote database with the local one'
43
+ task :sync do
44
+ dump
45
+ restore
46
+ end
47
+
48
+ desc 'Dump the remote database to ./remote.dump'
49
+ task :dump do
50
+ dump
51
+ end
52
+
53
+ desc 'Restore the local database from ./remote.dump'
54
+ task :restore do
55
+ restore
31
56
  end
32
57
  end
33
58
 
@@ -42,17 +67,17 @@ namespace :h do
42
67
  end
43
68
 
44
69
  desc 'Start a DB console'
45
- task :console do
70
+ task :dbconsole do
46
71
  bundlerize { sh "heroku pg:psql -r #{remote}" }
47
72
  end
48
73
 
49
74
  desc 'Display the application env vars'
50
- task :console do
75
+ task :config do
51
76
  bundlerize { sh "heroku config -r #{remote}" }
52
77
  end
53
78
 
54
79
  desc 'List the application dynos'
55
- task :console do
80
+ task :ps do
56
81
  bundlerize { sh "heroku ps -r #{remote}" }
57
82
  end
58
83
 
@@ -68,6 +93,10 @@ namespace :h do
68
93
  end
69
94
  end
70
95
 
96
+ def deploy
97
+ bundlerize { sh "git push #{remote} origin/#{deploy_branch}:master" }
98
+ end
99
+
71
100
  def deploy_branch
72
101
  case remote
73
102
  when "staging"
@@ -77,8 +106,27 @@ namespace :h do
77
106
  end
78
107
  end
79
108
 
109
+ def dump
110
+ bundlerize { sh "heroku pgbackups:capture -r #{remote}" }
111
+ bundlerize { sh "curl -o remote.dump $(heroku pgbackups:url -r #{remote})" }
112
+ end
113
+
114
+ def restore
115
+ bundlerize { sh "pg_restore -h localhost -U postgres -d #{dev_db_name} remote.dump --verbose --clean --no-acl --no-owner" }
116
+ end
117
+
118
+ def dev_db_name
119
+ Rails.configuration.database_configuration["development"]["database"]
120
+ end
121
+
80
122
  def no_warning
81
123
  task remote.to_sym do
82
124
  end
83
125
  end
84
126
  end
127
+
128
+ Rake::Task.tasks.each do |t|
129
+ t.enhance do
130
+ no_warning
131
+ end
132
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_rake_tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Colon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2014-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler