Permalink
Browse files

Documentation update. Closes #72

  • Loading branch information...
1 parent d52901b commit f113bd0cfa1077f03e66ed94c75098af7e7d3fb1 @kmayer kmayer committed Mar 4, 2012
Showing with 143 additions and 118 deletions.
  1. +41 −31 README.rdoc
  2. +1 −1 lib/heroku_san/version.rb
  3. +101 −86 lib/tasks.rb
View
72 README.rdoc
@@ -68,37 +68,47 @@ Need to add remotes for each app?
A full list of tasks provided:
- rake after_deploy # Callback after deploys
- rake all # Select all Heroku apps for later command
- rake before_deploy # Callback before deploys
- rake capture # Captures a bundle on Heroku
- rake console # Opens a remote console
- rake db:pull # Pull the Heroku database
- rake db:push # Push local database to Heroku database
- rake deploy[commit] # Pushes the given commit, migrates and restarts (default: HEAD)
- rake deploy:force[commit] # Force-pushes the given commit, migrates and restarts (default: HEAD)
- rake heroku:apps # Lists configured apps
- rake heroku:apps:local # Lists configured apps without hitting Heroku
- rake heroku:config # Add config:vars to each application
- rake heroku:config:list # Lists config variables as set on Heroku
- rake heroku:config:list:local # Lists local config variables without setting them
- rake heroku:create # Creates the Heroku app
- rake heroku:create_config # Creates an example configuration file
- rake heroku:gems # Generate the Heroku gems manifest from gem dependencies
- rake heroku:maintenance # Enable maintenance mode
- rake heroku:maintenance_off # Disable maintenance mode
- rake heroku:push[commit] # Pushes the given commit (default: HEAD)
- rake heroku:push:force[commit] # Force-pushes the given commit (default: HEAD)
- rake heroku:rack_env # Add proper RACK_ENV to each application
- rake heroku:rake[task] # Runs a rake task remotely
- rake heroku:remotes # Add git remotes for all apps in this project
- rake heroku:share # Adds a collaborator
- rake heroku:unshare # Removes a collaborator
- rake logs # Shows the Heroku logs
- rake migrate # Migrates and restarts remote servers
- rake restart # Restarts remote servers
-
-Frequently used tasks are not namespaced, everything else lives under heroku.
+ rake heroku:apps # Lists configured apps
+ rake heroku:apps:local # Lists configured apps without hitting heroku
+ rake heroku:config # Add config:vars to each application.
+ rake heroku:config:list # Lists config variables as set on Heroku
+ rake heroku:config:list:local # Lists local config variables without setting them
+ rake heroku:config:rack_env # Add proper RACK_ENV to each application
+ rake heroku:console # Opens a remote console
+ rake heroku:create # Creates the Heroku app
+ rake heroku:create_config # Creates an example configuration file
+ rake heroku:db:migrate # Migrates and restarts remote servers
+ rake heroku:db:pull # Pull database from stage to local dev database
+ rake heroku:deploy[commit] # Pushes the given commit, migrates and restarts (default: HEAD)
+ rake heroku:deploy:after # Callback after deploys
+ rake heroku:deploy:before # Callback before deploys
+ rake heroku:deploy:force[commit] # Force-pushes the given commit, migrates and restarts (default: HEAD)
+ rake heroku:logs # Shows the Heroku logs
+ rake heroku:logs:tail # Tail the Heroku logs (requires logging:expanded)
+ rake heroku:maintenance # Enable maintenance mode
+ rake heroku:maintenance_off # Disable maintenance mode
+ rake heroku:maintenance_on # Enable maintenance mode
+ rake heroku:push[commit] # Pushes the given commit (default: HEAD)
+ rake heroku:push:force[commit] # Force-pushes the given commit (default: HEAD)
+ rake heroku:rake[task] # Runs a rake task remotely
+ rake heroku:remotes # Add git remotes for all apps in this project
+ rake heroku:restart # Restarts remote servers
+ rake heroku:share # Adds a collaborator (asks for email)
+ rake heroku:unshare # Removes a collaborator (asks for email)
+ rake heroku:stage:all # Select all Heroku apps for later command
+
+Frequently used tasks are aliased into the global namespace:
+
+ task :all => 'heroku:stage:all'
+ task :deploy => 'heroku:deploy'
+ task 'deploy:force' => 'heroku:deploy:force'
+ task :before_deploy => 'heroku:deploy:before'
+ task :after_deploy => 'heroku:deploy:after'
+ task :console => 'heroku:console'
+ task :restart => 'heroku:restart'
+ task :migrate => 'heroku:db:migrate'
+ task :logs => 'heroku:logs:default'
+ task 'logs:tail' => 'heroku:logs:tail'
== Links
View
2 lib/heroku_san/version.rb
@@ -1,3 +1,3 @@
module HerokuSan
- VERSION = "2.0.rc.1"
+ VERSION = "2.1.0"
end
View
187 lib/tasks.rb
@@ -5,25 +5,26 @@
@heroku_san.all.each do |stage|
desc "Select #{stage} Heroku app for later commands"
- task stage do
+ task "heroku:stage:#{stage}" do
@heroku_san << stage
end
-end
-
-desc 'Select all Heroku apps for later command'
-task :all do
- @heroku_san << @heroku_san.all
+ task stage => "heroku:stage:#{stage}"
end
namespace :heroku do
+ desc 'Select all Heroku apps for later command'
+ task 'stage:all' do
+ @heroku_san << @heroku_san.all
+ end
+
desc "Creates the Heroku app"
task :create do
each_heroku_app do |stage|
stage.create
end
end
- desc "Generate the Heroku gems manifest from gem dependencies"
+ #desc "Generate the Heroku gems manifest from gem dependencies"
task :gems => 'gems:base' do
raise HerokuSan::Deprecated
end
@@ -35,7 +36,7 @@
end
end
- desc 'Adds a collaborator'
+ desc 'Adds a collaborator (asks for email)'
task :share do
print "Email address of collaborator to add: "
$stdout.flush
@@ -45,7 +46,7 @@
end
end
- desc 'Removes a collaborator'
+ desc 'Removes a collaborator (asks for email)'
task :unshare do
print "Email address of collaborator to remove: "
$stdout.flush
@@ -78,18 +79,6 @@
end
end
- desc 'Add proper RACK_ENV to each application'
- task :rack_env => :all do
- each_heroku_app do |stage|
- command = "heroku config --app #{stage.app}"
- puts command
- config = Hash[`#{command}`.scan(/^(.+?)\s*=>\s*(.+)$/)]
- if config['RACK_ENV'] != stage.name
- stage.push_config RACK_ENV: stage.name
- end
- end
- end
-
desc 'Add config:vars to each application.'
task :config do
each_heroku_app do |stage|
@@ -113,6 +102,18 @@
end
namespace :config do
+ desc 'Add proper RACK_ENV to each application'
+ task :rack_env => :all do
+ each_heroku_app do |stage|
+ command = "heroku config --app #{stage.app}"
+ puts command
+ config = Hash[`#{command}`.scan(/^(.+?)\s*=>\s*(.+)$/)]
+ if config['RACK_ENV'] != stage.name
+ stage.push_config RACK_ENV: stage.name
+ end
+ end
+ end
+
desc "Lists config variables as set on Heroku"
task :list do
each_heroku_app do |stage|
@@ -176,100 +177,114 @@
stage.maintenance :off
end
end
-end
-
-desc "Pushes the given commit, migrates and restarts (default: HEAD)"
-task :deploy, [:commit] => [:before_deploy] do |t, args|
- each_heroku_app do |stage|
- stage.deploy(args[:commit])
- stage.migrate
- end
- Rake::Task[:after_deploy].execute
-end
-namespace :deploy do
- desc "Force-pushes the given commit, migrates and restarts (default: HEAD)"
- task :force, [:commit] => [:before_deploy] do |t, args|
+ desc "Pushes the given commit, migrates and restarts (default: HEAD)"
+ task :deploy, [:commit] => [:before_deploy] do |t, args|
each_heroku_app do |stage|
- stage.deploy(args[:commit], :force)
+ stage.deploy(args[:commit])
stage.migrate
end
Rake::Task[:after_deploy].execute
end
-end
-
-task :force_deploy do
- raise Deprecated
-end
-desc "Callback before deploys"
-task :before_deploy do
-end
+ namespace :deploy do
+ desc "Force-pushes the given commit, migrates and restarts (default: HEAD)"
+ task :force, [:commit] => [:before_deploy] do |t, args|
+ each_heroku_app do |stage|
+ stage.deploy(args[:commit], :force)
+ stage.migrate
+ end
+ Rake::Task[:after_deploy].execute
+ end
-desc "Callback after deploys"
-task :after_deploy do
-end
+ desc "Callback before deploys"
+ task :before do
+ end
-desc "Captures a bundle on Heroku"
-task :capture do
- raise Deprecated
-end
+ desc "Callback after deploys"
+ task :after do
+ end
-desc "Opens a remote console"
-task :console do
- each_heroku_app do |stage|
- stage.run 'console'
end
-end
-desc "Restarts remote servers"
-task :restart do
- each_heroku_app do |stage|
- stage.restart
+ task :force_deploy do
+ raise HerokuSan::Deprecated
end
-end
-desc "Migrates and restarts remote servers"
-task :migrate do
- each_heroku_app do |stage|
- stage.migrate
+ #desc "Captures a bundle on Heroku"
+ task :capture do
+ raise HerokuSan::Deprecated
end
-end
-namespace :logs do
- desc "Shows the Heroku logs"
- task :default do
+ desc "Opens a remote console"
+ task :console do
each_heroku_app do |stage|
- stage.logs
+ stage.run 'console'
end
end
- desc "Tail the Heroku logs (requires logging:expanded)"
- task :tail do
+ desc "Restarts remote servers"
+ task :restart do
each_heroku_app do |stage|
- stage.logs(:tail)
+ stage.restart
end
end
-end
-task :logs => 'logs:default'
+ namespace :logs do
+ task :default do
+ each_heroku_app do |stage|
+ stage.logs
+ end
+ end
-namespace :db do
- task :pull do
- each_heroku_app do |stage|
- sh "heroku pgdumps:capture --app #{stage.app}"
- dump = `heroku pgdumps --app #{stage.app}`.split("\n").last.split(" ").first
- sh "mkdir -p #{Rails.root}/db/dumps"
- file = "#{Rails.root}/db/dumps/#{dump}.sql.gz"
- url = `heroku pgdumps:url --app #{stage.app} #{dump}`.chomp
- sh "wget", url, "-O", file
- sh "rake db:drop db:create"
- sh "gunzip -c #{file} | #{Rails.root}/script/dbconsole"
- sh "rake jobs:clear"
+ desc "Tail the Heroku logs (requires logging:expanded)"
+ task :tail do
+ each_heroku_app do |stage|
+ stage.logs(:tail)
+ end
+ end
+ end
+
+ desc "Shows the Heroku logs"
+ task :logs => 'logs:default'
+
+ namespace :db do
+ desc "Migrates and restarts remote servers"
+ task :migrate do
+ each_heroku_app do |stage|
+ stage.migrate
+ end
+ end
+
+ desc "Pull database from stage to local dev database"
+ task :pull do
+ each_heroku_app do |stage|
+ sh "heroku pgdumps:capture --app #{stage.app}"
+ dump = `heroku pgdumps --app #{stage.app}`.split("\n").last.split(" ").first
+ sh "mkdir -p #{Rails.root}/db/dumps"
+ file = "#{Rails.root}/db/dumps/#{dump}.sql.gz"
+ url = `heroku pgdumps:url --app #{stage.app} #{dump}`.chomp
+ sh "wget", url, "-O", file
+ sh "rake db:drop db:create"
+ sh "gunzip -c #{file} | #{Rails.root}/script/dbconsole"
+ sh "rake jobs:clear"
+ end
end
end
end
+task :all => 'heroku:stage:all'
+task :deploy => 'heroku:deploy'
+task 'deploy:force' => 'heroku:deploy:force'
+task :before_deploy => 'heroku:deploy:before'
+task :after_deploy => 'heroku:deploy:after'
+task :console => 'heroku:console'
+task :restart => 'heroku:restart'
+task :migrate => 'heroku:db:migrate'
+task :logs => 'heroku:logs:default'
+task 'logs:tail' => 'heroku:logs:tail'
+task 'heroku:rack_env' => 'heroku:config:rack_env'
+
def each_heroku_app(&block)
@heroku_san.each_app(&block)
puts

0 comments on commit f113bd0

Please sign in to comment.