capistrano-conditional 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b993e23a21fae3f4070e2e14427b7bb2699edd2a
4
+ data.tar.gz: d429a2ef57a187e3168998f550acf760782be43e
5
+ SHA512:
6
+ metadata.gz: a199f14d69b1e6292d79fa3e0379b46e1f57cc35c5da6ff7ccd6bdb4fc9a73aacc3ea7a16d496e0da1637c70efbb78fa97bcffd459622fbaef4b591f792dc051
7
+ data.tar.gz: d44ab7a4b1eba8f5a1c1ca86b68c2b064616dd37f228ed53e9b0a87d7e44d0d4dac4f55f9491105fc0f1e2a125864683e665de80684c5c80a09aff09f519f9e2
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # changelog
2
+
3
+ ## 0.0.4 -- December 20, 2013
4
+ * Updated dependecy - does not work with capistrano 3+
5
+ * Updated README examples
6
+ * Added changelog
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem extends capistrano deployments to allow certain tasks to only be run under certain conditions -- i.e. conditionally.
4
4
 
5
+ It hasn't yet been extended to work with Capistrano 3; pull requests welcomed!
6
+
5
7
  ## Installation
6
8
 
7
9
  Add to your Gemfile:
@@ -47,27 +49,52 @@ If you need more custom control, <code>:if</code> and <code>:unless</code> expec
47
49
 
48
50
  ## Example Usage
49
51
 
52
+ These snippets go in <code>config/deploy.rb</code> or any other file that gets loaded via capistrano.
53
+
54
+ ### A random collection of examples:
55
+
56
+ #### Using [whenever](https://github.com/javan/whenever)
57
+
58
+ Only run the rake task to update the crontab if the schedule has changed:
59
+
50
60
  ConditionalDeploy.register :whenever, :watchlist => 'config/schedule.rb' do
51
61
  after "deploy:symlink", "deploy:update_crontab"
52
62
  end
53
63
 
54
- ConditionalDeploy.register :sphinx, :watchlist => ['db/schema.rb', 'db/migrate'] do
64
+ #### Using [thinking-sphinx](https://github.com/pat/thinking-sphinx)
65
+
66
+ Only restart the sphinx daemon if our database or schema has changed. Otherwise, just copy the generated sphinx config from the previous release:
67
+
68
+ SPHINX_WATCHLIST = ['db/schema.rb', 'db/migrate', 'sphinx.yml', 'app/indices']
69
+
70
+ ConditionalDeploy.register :sphinx, :watchlist => SPHINX_WATCHLIST do
55
71
  before "deploy:update_code", "thinking_sphinx:stop"
56
72
  before "deploy:start", "thinking_sphinx:start"
57
73
  before "deploy:restart", "thinking_sphinx:start"
58
74
  end
75
+
76
+ ConditionalDeploy.register :no_sphinx, :none_match => SPHINX_WATCHLIST do
77
+ after "deploy:update_code", "sphinx:copy_config"
78
+ end
79
+
80
+ namespace :sphinx do
81
+ desc 'Copy the config file from previous release, if available, or else rerun configuration'
82
+ task :copy_config, :roles => :app do
83
+ run "([ -f #{current_path}/config/#{stage}.sphinx.conf ] && cp #{current_path}/config/#{stage}.sphinx.conf #{release_path}/config/#{stage}.sphinx.conf) || true"
84
+ run "[ -f #{release_path}/config/#{stage}.sphinx.conf ] || (cd #{release_path} && bundle exec rake ts:config RAILS_ENV=#{stage})"
85
+ end
86
+ end
87
+
88
+
89
+ #### Using [jammit](https://github.com/documentcloud/jammit)
90
+
91
+ For pre-asset-pipeline versions of Rails, this snippet will reprocess your assets with [jammit](https://github.com/documentcloud/jammit) only if necessary:
59
92
 
60
93
  ConditionalDeploy.register :jammit, :watchlist => ['public/images/embed', 'public/stylesheets', 'public/javascripts', 'public/assets', 'config/assets.yml'] do
61
94
  after 'deploy:symlink', 'deploy:rebuild_assets'
62
95
  end
63
96
 
64
- # Restart the resque workers unless the only changes were to static assets, views, or controllers.
65
- ConditionalDeploy.register(:resque, :unless => lambda { |changed| changed.all?{|f| f['public/'] || f['app/controllers/'] || f['app/views/'] } }) do
66
- before "deploy:restart", "resque:workers:restart"
67
- end
68
-
69
- # ... note that you still have to actually DEFINE the tasks laid out above (e.g. deploy:update_crontab)
70
-
97
+ #### Migrations
71
98
 
72
99
  I've got <code>cap deploy</code> in muscle memory, and I used to find myself forgetting to run <code>cap deploy:migrations</code> until after I tested the new changes and found staging wasn't working right. I now add the following code to my apps, so I never have to worry about it again:
73
100
 
@@ -91,9 +118,8 @@ Since I use it on every project, I've wrapped that logic up in a single command:
91
118
 
92
119
  By default <code>capistrano-conditional</code> will abort the deployment if you have uncommited changes in your working directory. You can skip this check on an individual run by setting the ALLOW_UNCOMMITED environment variable (e.g. <code>cap deploy ALLOW_UNCOMMITTED=1</code>).
93
120
 
94
- If you need to force a particular conditional to run, you can also do that via the environment. Given the examples above, if you want to run the conditional named <code>whenever</code> even though config/schedule.rb hasn't been changed, just run <code>code deploy RUN_WHENEVER=1</code>.
121
+ If you need to force a particular conditional to run, you can also do that via the environment. Given the examples above, if you want to run the conditional named <code>whenever</code> even though config/schedule.rb hasn't been changed, just run <code>cap deploy RUN_WHENEVER=1</code>. Similarly, if you needed to skip the <code>whenever</code> conditional which would otherwise be run, you can use <code>cap deploy SKIP_WHENEVER=1</code>.
95
122
 
96
123
  ## License
97
124
 
98
- Copyright &copy; 2011 [Deviantech, Inc.](http://www.deviantech.com) and released under the MIT license.
99
-
125
+ Copyright &copy; 2013 [Deviantech, Inc.](http://www.deviantech.com) and released under the MIT license.
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Capistrano::Conditional::VERSION
8
8
  s.authors = ["Kali Donovan"]
9
9
  s.email = ["kali@deviantech.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/deviantech/capistrano-conditional"
11
11
  s.summary = %q{Adds support for conditional deployment tasks in capistrano}
12
12
  s.description = %q{Allows making tasks for git-based projects conditional based on the specific files to be deployed.}
13
13
 
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  # s.add_development_dependency "rspec"
23
23
  s.add_runtime_dependency "git"
24
- s.add_runtime_dependency "capistrano"
24
+ s.add_runtime_dependency "capistrano", '~> 2.5'
25
25
  end
@@ -64,14 +64,14 @@ class ConditionalDeploy
64
64
  end
65
65
 
66
66
  log
67
- log "Conditional Deployment Report:", Capistrano::Logger::IMPORTANT
67
+ log "Conditional Deployment Report:"
68
68
  log
69
- log "\tLast deployed commit: #{@last_deployed.message}", Capistrano::Logger::DEBUG
69
+ log "\tLast deployed commit: #{@last_deployed.message}"
70
70
  log
71
- log "\tFiles Modified:", Capistrano::Logger::DEBUG
71
+ log "\tFiles Modified:"
72
72
  @changed.each {|f| log "\t\t- #{f}"}
73
73
  log
74
- log "\tConditional Runlist:", Capistrano::Logger::DEBUG
74
+ log "\tConditional Runlist:"
75
75
  if @to_run.empty?
76
76
  log "\t\t* No conditional tasks have been added"
77
77
  else
@@ -86,7 +86,9 @@ class ConditionalDeploy
86
86
  def screen_conditionals
87
87
  @@conditionals.each do |job|
88
88
  force = job.name && ENV["RUN_#{job.name.to_s.upcase}"]
89
+ skip = job.name && ENV["SKIP_#{job.name.to_s.upcase}"]
89
90
  next unless force || job.applies?(@changed)
91
+ next if skip
90
92
  @to_run << job
91
93
  end
92
94
  end
@@ -1,11 +1,16 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ log_formatter([
3
+ { :match => /^Conditional$/, :color => :cyan, :style => :dim, :priority => 10 }
4
+ ])
5
+
6
+
2
7
  abort "\ncapistrano-conditional is not compatible with Capistrano 1.x\n" unless respond_to?(:namespace)
3
8
  abort "\nGit is not defined (are you in a git repository, with the Git gem installed?)\n" unless defined?(Git)
4
9
 
5
10
  namespace :conditional do
6
11
  desc "Initializes the conditional deployment functionality"
7
12
  task :apply do
8
- deployed_hash = capture("cd #{current_path} && git log --format=oneline -n 1", :pty => false).split[0]
13
+ deployed_hash = capture("cat #{current_path}/REVISION").strip
9
14
  ConditionalDeploy.apply_conditions!( deployed_hash )
10
15
  end
11
16
 
@@ -47,8 +47,6 @@ module Capistrano
47
47
  !condition_true?(:unless)
48
48
  end
49
49
 
50
-
51
-
52
50
  def any_files_match?(key)
53
51
  return true unless conditions[key]
54
52
  Array(conditions[key]).any? do |watched|
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Conditional
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,38 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-conditional
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kali Donovan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-12-01 00:00:00.000000000Z
11
+ date: 2013-12-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: git
16
- requirement: &70332715168240 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70332715168240
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: capistrano
27
- requirement: &70332715294620 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ~>
31
32
  - !ruby/object:Gem::Version
32
- version: '0'
33
+ version: '2.5'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70332715294620
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
36
41
  description: Allows making tasks for git-based projects conditional based on the specific
37
42
  files to be deployed.
38
43
  email:
@@ -42,6 +47,7 @@ extensions: []
42
47
  extra_rdoc_files: []
43
48
  files:
44
49
  - .gitignore
50
+ - CHANGELOG.md
45
51
  - Gemfile
46
52
  - README.md
47
53
  - Rakefile
@@ -51,28 +57,27 @@ files:
51
57
  - lib/capistrano-conditional/integration.rb
52
58
  - lib/capistrano-conditional/unit.rb
53
59
  - lib/capistrano-conditional/version.rb
54
- homepage: ''
60
+ homepage: https://github.com/deviantech/capistrano-conditional
55
61
  licenses: []
62
+ metadata: {}
56
63
  post_install_message:
57
64
  rdoc_options: []
58
65
  require_paths:
59
66
  - lib
60
67
  required_ruby_version: !ruby/object:Gem::Requirement
61
- none: false
62
68
  requirements:
63
- - - ! '>='
69
+ - - '>='
64
70
  - !ruby/object:Gem::Version
65
71
  version: '0'
66
72
  required_rubygems_version: !ruby/object:Gem::Requirement
67
- none: false
68
73
  requirements:
69
- - - ! '>='
74
+ - - '>='
70
75
  - !ruby/object:Gem::Version
71
76
  version: '0'
72
77
  requirements: []
73
78
  rubyforge_project: capistrano-conditional
74
- rubygems_version: 1.8.10
79
+ rubygems_version: 2.1.11
75
80
  signing_key:
76
- specification_version: 3
81
+ specification_version: 4
77
82
  summary: Adds support for conditional deployment tasks in capistrano
78
83
  test_files: []