capper 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/capper.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "capper"
3
- s.version = "0.2.4"
3
+ s.version = "0.3.0"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.licenses = ["MIT"]
6
6
  s.authors = ["Benedikt Böhm"]
data/lib/capper/base.rb CHANGED
@@ -4,10 +4,10 @@ unless Capistrano::Configuration.respond_to?(:instance)
4
4
  abort "capper requires Capistrano 2"
5
5
  end
6
6
 
7
- # add some nice colors
8
- require "capistrano_colors"
9
-
10
7
  # mixin various helpers
8
+ require 'capistrano_colors/configuration'
9
+ require 'capistrano_colors/logger'
10
+
11
11
  require 'capper/utils/load'
12
12
 
13
13
  require 'capper/utils/templates'
@@ -18,6 +18,24 @@ include Capper::Utils::Multistage
18
18
 
19
19
  # define a bunch of defaults that make sense
20
20
  Capper.load do
21
+ # do not trace by default
22
+ logger.level = Capistrano::Logger::DEBUG
23
+
24
+ # add custom color scheme
25
+ colorize([
26
+ { :match => /executing `.*/, :color => :yellow, :level => 2, :prio => -10, :attribute => :bright, :prepend => "== Currently " },
27
+ { :match => /executing ".*/, :color => :magenta, :level => 2, :prio => -20 },
28
+ { :match => /sftp upload complete/, :color => :hide, :level => 2, :prio => -20 },
29
+
30
+ { :match => /^transaction:.*/, :color => :blue, :level => 1, :prio => -10, :attribute => :bright },
31
+ { :match => /.*out\] (fatal:|ERROR:).*/, :color => :red, :level => 1, :prio => -10 },
32
+ { :match => /Permission denied/, :color => :red, :level => 1, :prio => -20 },
33
+ { :match => /sh: .+: command not found/, :color => :magenta, :level => 1, :prio => -30 },
34
+
35
+ { :match => /^err ::/, :color => :red, :level => 0, :prio => -10 },
36
+ { :match => /.*/, :color => :blue, :level => 0, :prio => -20, :attribute => :bright },
37
+ ])
38
+
21
39
  # apps should not require root access
22
40
  set(:use_sudo, false)
23
41
  set(:group_writable, false)
@@ -46,8 +64,9 @@ Capper.load do
46
64
  will not destroy any deployed revisions or data.
47
65
  DESC
48
66
  task :setup, :except => { :no_release => true } do
67
+ shared = %w(system log pids) | shared_children
49
68
  dirs = [releases_path, shared_path]
50
- dirs += shared_children.map { |d| File.join(shared_path, d) }
69
+ dirs += shared.map { |d| File.join(shared_path, d) }
51
70
  run "mkdir -p #{dirs.join(' ')}"
52
71
  end
53
72
  end
@@ -5,6 +5,9 @@ require 'bundler/capistrano'
5
5
  require "capper/rvm"
6
6
 
7
7
  Capper.load do
8
+ # always execute rake with bundler to make sure we use the right version
9
+ set(:rake, "bundle exec rake")
10
+
8
11
  # do not install a global bundle
9
12
  # instead, use the gemset selected by rvm_ruby_string
10
13
  set(:bundle_dir) { File.join(shared_path, 'bundle', rvm_ruby_string) }
data/lib/capper/config.rb CHANGED
@@ -1,13 +1,25 @@
1
1
  require File.dirname(__FILE__) + '/base' unless defined?(Capper)
2
2
 
3
3
  Capper.load do
4
- _cset(:config_repo) { abort "Please specify the config repository, set :config_repo, 'foo'" }
4
+ _cset(:config_repo, nil)
5
5
 
6
6
  after "deploy:setup" do
7
- run "rm -rf #{config_path} && git clone #{config_repo} #{config_path}"
7
+ unless config_repo.nil?
8
+ run "rm -rf #{config_path} && git clone -q #{config_repo} #{config_path}"
9
+ end
8
10
  end
9
11
 
10
12
  after "deploy:update_code" do
11
- run "cd #{config_path} && git pull"
13
+ unless config_repo.nil?
14
+ run "cd #{config_path} && git pull -q"
15
+ end
16
+
17
+ fetch(:config_files, []).each do |f|
18
+ run "cp #{config_path}/#{f} #{release_path}/config/"
19
+ end
20
+
21
+ fetch(:symlinks, {}).each do |source, dest|
22
+ run "rm -rf #{release_path}/#{dest} && ln -nfs #{shared_path}/#{source} #{release_path}/#{dest}"
23
+ end
12
24
  end
13
25
  end
data/lib/capper/gem.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/base' unless defined?(Capper)
2
+
3
+ Capper.load do
4
+ task "gem:setup" do
5
+ put("gem: --no-ri --no-rdoc", "#{deploy_to}/.gemrc")
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/base' unless defined?(Capper)
2
+
3
+ # hoptoad requires bundler
4
+ require 'capper/bundler'
5
+
6
+ Capper.load do
7
+ # redefine the notify task without after hooks, so we can use them in
8
+ # specific stages only.
9
+ namespace :hoptoad do
10
+ desc "Notify Hoptoad of the deployment"
11
+ task :notify, :except => { :no_release => true } do
12
+ rails_env = fetch(:hoptoad_env, fetch(:rails_env, "production"))
13
+ local_user = ENV['USER'] || ENV['USERNAME']
14
+ executable = fetch(:rake, 'rake')
15
+
16
+ notify_command = "#{executable} hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
17
+ notify_command << " DRY_RUN=true" if dry_run
18
+ notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY']
19
+
20
+ puts "Notifying Hoptoad of Deploy (#{notify_command})"
21
+ `#{notify_command}`
22
+ puts "Hoptoad Notification Complete."
23
+ end
24
+ end
25
+ end
data/lib/capper/rvm.rb CHANGED
@@ -3,6 +3,8 @@ require File.dirname(__FILE__) + '/base' unless defined?(Capper)
3
3
  $:.unshift(File.expand_path('./lib', ENV['rvm_path']))
4
4
  require 'rvm/capistrano'
5
5
 
6
+ require "capper/gem"
7
+
6
8
  Capper.load do
7
9
  set(:rvm_type, :user)
8
10
  set(:rvm_ruby_string, File.read(".rvmrc").gsub(/^rvm use --create (.*)/, '\1').strip)
@@ -28,6 +30,7 @@ Capper.load do
28
30
  end
29
31
  end
30
32
 
33
+ before "rvm:setup", "gem:setup"
31
34
  before "deploy:setup", "rvm:setup"
32
35
  after "deploy:symlink", "rvm:trust_rvmrc"
33
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-29 00:00:00.000000000Z
12
+ date: 2011-08-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis
16
- requirement: &12597200 !ruby/object:Gem::Requirement
16
+ requirement: &22259260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12597200
24
+ version_requirements: *22259260
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capistrano
27
- requirement: &12596760 !ruby/object:Gem::Requirement
27
+ requirement: &22258820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *12596760
35
+ version_requirements: *22258820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: capistrano_colors
38
- requirement: &12596340 !ruby/object:Gem::Requirement
38
+ requirement: &22258400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *12596340
46
+ version_requirements: *22258400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &12595840 !ruby/object:Gem::Requirement
49
+ requirement: &22257900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *12595840
57
+ version_requirements: *22257900
58
58
  description: Capistrano is a collection of opinionated Capistrano recipes
59
59
  email:
60
60
  - bb@xnull.de
@@ -76,7 +76,9 @@ files:
76
76
  - lib/capper/base.rb
77
77
  - lib/capper/bundler.rb
78
78
  - lib/capper/config.rb
79
+ - lib/capper/gem.rb
79
80
  - lib/capper/git.rb
81
+ - lib/capper/hoptoad.rb
80
82
  - lib/capper/multistage.rb
81
83
  - lib/capper/rails.rb
82
84
  - lib/capper/rvm.rb