heroku-rake 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in heroku-rake.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Adam McCrea
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,53 @@
1
+ # heroku-rake
2
+
3
+ heroku-rake is a lightweight gem that provides rake tasks for deploying Rails
4
+ apps to Heroku. It does not attempt to recreate all functionality of the
5
+ [Heroku Toolbelt](https://toolbelt.heroku.com). It is simply a convenience for
6
+ deployment since deploying to Heroku typically involves a series of steps
7
+ (backup, push, migrate) that are easy to forget when running manually. It is
8
+ configurable so you can decide which steps are appropriate for different types
9
+ of deployment.
10
+
11
+ ## Prerequisites
12
+
13
+ This gem assumes that you have the [Heroku
14
+ Toolbelt](https://toolbelt.heroku.com) installed. It simply shells out to the
15
+ `heroku` command. We're also assuming you've created your Heroku app and the
16
+ necessary Git remotes.
17
+
18
+ The gem also currently assumes you're using Rails. Pull requests to make it
19
+ framework-agnostic would be welcomed.
20
+
21
+ ## Installation
22
+
23
+ Add this line to the development group in your application's Gemfile:
24
+
25
+ ```ruby
26
+ gem 'heroku-rake'
27
+ ```
28
+
29
+ Generate the skeleton deploy tasks:
30
+
31
+ ```shell
32
+ rails generate heroku:rake_tasks
33
+ ```
34
+
35
+ ## Usage & Configuration
36
+
37
+ Update the constants in lib/tasks/deploy.rake to refelect the Git remotes you
38
+ have set up for Heroku. Out of the box, you will only need to care about three
39
+ rake tasks:
40
+
41
+ ```shell
42
+ rake deploy # Basic deploy to Heroku (no migrations), use TO=remote to specify an environment
43
+ rake deploy:migrations # Deploy to Heroku with migrations, use TO=remote to specify an environment
44
+ rake deploy:migrations:safe # Deploy to Heroku with migrations and maintenance mode, use TO=remote to specify an env...
45
+ ```
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'heroku-rake/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "heroku-rake"
8
+ gem.version = Heroku::Rake::VERSION
9
+ gem.authors = ["Adam McCrea"]
10
+ gem.email = ["adam@adamlogic.com"]
11
+ gem.description = %q{Rake tasks to simpliy Rails deployment to Heroku}
12
+ gem.summary = %q{Rake tasks to simpliy Rails deployment to Heroku}
13
+ gem.homepage = "http://github.com/newcontext/heroku-rails"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,9 @@
1
+ module Heroku
2
+ class RakeTasksGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def create_rake_file
6
+ copy_file 'deploy.rake', 'lib/tasks/deploy.rake'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ HEROKU_GIT_REMOTES = { production: 'heroku-app-name' }
2
+ DEFAULT_REMOTE = 'production'
3
+ PING_ENDPOINT = '/ping' # A working URL that can be pinged to spin up your dynos
4
+
5
+ desc 'Basic deploy to Heroku (no migrations), use TO=remote to specify an environment'
6
+ task :deploy => ['heroku:push',
7
+ 'heroku:ping']
8
+
9
+ namespace :deploy do
10
+ desc 'Deploy to Heroku with migrations, use TO=remote to specify an environment'
11
+ task :migrations => ['heroku:db:backup',
12
+ 'heroku:push',
13
+ 'heroku:db:migrate',
14
+ 'heroku:restart',
15
+ 'heroku:ping']
16
+
17
+ namespace :migrations do
18
+ desc 'Deploy to Heroku with migrations and maintenance mode, use TO=remote to specify an environment'
19
+ task :safe => ['heroku:maintenance:on',
20
+ 'heroku:db:backup',
21
+ 'heroku:push',
22
+ 'heroku:db:migrate',
23
+ 'heroku:restart',
24
+ 'heroku:maintenance:off',
25
+ 'heroku:ping']
26
+
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ require "heroku-rake/version"
2
+
3
+ module Heroku
4
+ module Rake
5
+ class Railtie < ::Rails::Railtie
6
+ rake_tasks do
7
+ load "heroku-rake/tasks/heroku.rake"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,55 @@
1
+ namespace :heroku do
2
+ task :heroku_command_line_client do
3
+ unless `heroku version` =~ /ruby/
4
+ abort "Please install the heroku toolbelt or command line client"
5
+ end
6
+ end
7
+
8
+ task :push => :heroku_command_line_client do
9
+ current_branch = `git branch | grep '*' | cut -d ' ' -f 2`.strip
10
+ git_remote = `git remote -v | grep 'git@heroku.*:#{heroku_app}.git' | grep -e push | cut -f 1 | cut -d : -f 3`.strip
11
+
12
+ puts "***** DEPLOYING TO #{heroku_app} *****"
13
+ puts "***** use the TO=git_remote option to specify a different environment *****"
14
+
15
+ sh "git push #{git_remote} #{current_branch}:master"
16
+ end
17
+
18
+ task :restart => :heroku_command_line_client do
19
+ sh "heroku restart --app #{heroku_app}"
20
+ end
21
+
22
+ task :ping => :heroku_command_line_client do
23
+ url = `heroku domains`.split("\n").last.strip
24
+ url = "#{heroku_app}.herokuapp.com" if url[/No domain names/]
25
+ sh "curl http://#{url}#{PING_ENDPOINT}"
26
+ end
27
+
28
+ namespace :db do
29
+ task :backup => :heroku_command_line_client do
30
+ sh "heroku pgbackups:capture --app #{heroku_app}"
31
+ end
32
+
33
+ task :migrate => :heroku_command_line_client do
34
+ puts "***** MIGRATING #{heroku_app} *****"
35
+ sh "heroku run rake db:migrate --app #{heroku_app}"
36
+ end
37
+ end
38
+
39
+ namespace :maintenance do
40
+ task :on => :heroku_command_line_client do
41
+ sh "heroku maintenance:on --app #{heroku_app}"
42
+ end
43
+
44
+ task :off => :heroku_command_line_client do
45
+ sh "heroku maintenance:off --app #{heroku_app}"
46
+ end
47
+ end
48
+
49
+ def heroku_app
50
+ ENV['TO'] ||= DEFAULT_REMOTE
51
+ app_name = HEROKU_GIT_REMOTES[ENV['TO'].to_sym]
52
+
53
+ app_name
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module Heroku
2
+ module Rake
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heroku-rake
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adam McCrea
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Rake tasks to simpliy Rails deployment to Heroku
15
+ email:
16
+ - adam@adamlogic.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - heroku-rake.gemspec
27
+ - lib/generators/heroku/rake_tasks_generator.rb
28
+ - lib/generators/heroku/templates/deploy.rake
29
+ - lib/heroku-rake.rb
30
+ - lib/heroku-rake/tasks/heroku.rake
31
+ - lib/heroku-rake/version.rb
32
+ homepage: http://github.com/newcontext/heroku-rails
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.24
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Rake tasks to simpliy Rails deployment to Heroku
56
+ test_files: []