whenever 0.9.0 → 0.9.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: 57fab9163bf16e91c0bd53c2a07a42ff6d27808c
4
- data.tar.gz: a2391734b582cffc7ca2d1b03a4dd8302c84f7ca
3
+ metadata.gz: 0615f43fa1b0a98f86c01020d35ae339a2767917
4
+ data.tar.gz: cb5c35a7f4703864be41ef4d5692092a190a8cd2
5
5
  SHA512:
6
- metadata.gz: 923b43401e3f57f83c1a6095a58c127157bf884433939cf64c8deb766cb48873526c91faf009774358b965b9c3768a159fbb9cafde83ed3d68c1a38f68cae954
7
- data.tar.gz: 185ac668deaa57c7cfdd4b192b8d19b0bf5bc70e68fe5d5b54454ef6ecd6b30dba0889af0da219095bb4f50327158bf8be0342d17737adb60e9613c5ac5b0bb4
6
+ metadata.gz: 3aefffaf5046d3501ff117d470281dad9eb079b11a979e2b810adf707f69d5dbdaffc2aac56aaed8b3125637742506e5e29129af5fc0163463e6eab42bacb416
7
+ data.tar.gz: f1e06eb27177312e775da44615de0fd79a9cb8ba331f7d525cb82c28d158a0731edf5981660339a4651712667dfd9dba4dc16e04bcb2be2b90a5826dc1dbed71
@@ -4,6 +4,7 @@ rvm:
4
4
  - 1.9.2
5
5
  - 1.9.3
6
6
  - 2.0.0
7
+ - 2.1.0
7
8
  - ree
8
9
  - jruby
9
10
  - jruby-18mode
@@ -1,3 +1,12 @@
1
+ ### 0.9.1 / March 2, 2014
2
+
3
+ * Pass `--roles` option to `whenever` in Capistrano 3 tasks. [betesh, Javan Makhmali]
4
+
5
+ * Allow setting `:whenever_command` for Capistrano 3. [Javan Makhmali]
6
+
7
+ * Allow `:whenever` command to be mapped in SSHKit. [Javan Makhmali]
8
+
9
+
1
10
  ### 0.9.0 / December 17, 2013
2
11
 
3
12
  * Capistrano V3 support. [Philip Hallstrom]
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Javan Makhmali
1
+ Copyright (c) 2014 Javan Makhmali
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -106,7 +106,7 @@ In your "config/deploy.rb" file:
106
106
  require "whenever/capistrano"
107
107
  ```
108
108
 
109
- Take a look at the recipe for options you can set. <http://github.com/javan/whenever/blob/master/lib/whenever/capistrano/recipes.rb>
109
+ Take a look at the recipe for options you can set. <https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v2/recipes.rb>
110
110
  For example, if you're using bundler do this:
111
111
 
112
112
  ```ruby
@@ -139,14 +139,6 @@ In your "Capfile" file:
139
139
  require "whenever/capistrano"
140
140
  ```
141
141
 
142
- If you're using bundler do this. **DO NOT** set ':whenever_command' to 'bundle exec whenever'. It will **NOT** work.
143
- Be default, 'bundle exec whenever' will be called. If you need something different and the command contains a space
144
- you will need to map it via the following method. This is an issue with SSHKit.
145
-
146
- ```ruby
147
- SSHKit.config.command_map[:whenever] = "bundle exec whenever"
148
- ```
149
-
150
142
  Take a look at the load:defaults (bottom of file) task for options you can set. <http://github.com/javan/whenever/blob/master/lib/whenever/tasks/whenever.rake>. For example, to namespace the crontab entries by application and stage do this.
151
143
 
152
144
  ```ruby
@@ -215,7 +207,7 @@ If your production environment uses RVM (Ruby Version Manager) you will run into
215
207
 
216
208
  `rvm_trust_rvmrcs_flag=1`
217
209
 
218
- This tells rvm to trust all rvmrc files, which is documented here: http://wayneeseguin.beginrescueend.com/2010/08/22/ruby-environment-version-manager-rvm-1-0-0/
210
+ This tells rvm to trust all rvmrc files.
219
211
 
220
212
  ### The `whenever` command
221
213
 
@@ -243,8 +235,8 @@ It's a little bit dated now, but remains a good introduction.
243
235
 
244
236
  ----
245
237
 
246
- Compatible with Ruby 1.8.7-2.0.0, JRuby, and Rubinius. [![Build Status](https://secure.travis-ci.org/javan/whenever.png)](http://travis-ci.org/javan/whenever)
238
+ Compatible with Ruby 1.8.7-2.1.0, JRuby, and Rubinius. [![Build Status](https://secure.travis-ci.org/javan/whenever.png)](http://travis-ci.org/javan/whenever)
247
239
 
248
240
  ----
249
241
 
250
- Copyright &copy; 2013 Javan Makhmali
242
+ Copyright &copy; 2014 Javan Makhmali
@@ -1,40 +1,39 @@
1
1
  namespace :whenever do
2
- desc "Update application's crontab entries using Whenever"
3
- task :update_crontab do
4
- on roles fetch(:whenever_roles) do
2
+ def setup_whenever_task(*args, &block)
3
+ SSHKit.config.command_map[:whenever] = fetch(:whenever_command)
4
+
5
+ on roles fetch(:whenever_roles) do |host|
6
+ args = args + Array(yield(host)) if block_given?
5
7
  within release_path do
6
- if fetch(:whenever_command)
7
- execute fetch(:whenever_command), fetch(:whenever_update_flags)
8
- else
9
- execute :bundle, :exec, :whenever, fetch(:whenever_update_flags)
8
+ with fetch(:whenever_command_environment_variables) do
9
+ execute :whenever, *args
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
+ desc "Update application's crontab entries using Whenever"
16
+ task :update_crontab do
17
+ setup_whenever_task do |host|
18
+ roles = host.roles_array.join(",")
19
+ [fetch(:whenever_update_flags), "--roles=#{roles}"]
20
+ end
21
+ end
22
+
15
23
  desc "Clear application's crontab entries using Whenever"
16
24
  task :clear_crontab do
17
- on roles fetch(:whenever_roles) do
18
- within release_path do
19
- if fetch(:whenever_command)
20
- execute %{#{fetch(:whenever_command)} #{fetch(:whenever_clear_flags)}}
21
- else
22
- execute :bundle, :exec, :whenever, fetch(:whenever_clear_flags)
23
- end
24
- end
25
- end
25
+ setup_whenever_task(fetch(:whenever_clear_flags))
26
26
  end
27
27
 
28
- after 'deploy:updated', 'whenever:update_crontab'
29
- after 'deploy:reverted', 'whenever:update_crontab'
30
-
28
+ after "deploy:updated", "whenever:update_crontab"
29
+ after "deploy:reverted", "whenever:update_crontab"
31
30
  end
32
31
 
33
32
  namespace :load do
34
33
  task :defaults do
35
34
  set :whenever_roles, ->{ :db }
36
- set :whenever_options, ->{ {:roles => fetch(:whenever_roles)} }
37
- set :whenever_command, ->{ }
35
+ set :whenever_command, ->{ "bundle exec whenever" }
36
+ set :whenever_command_environment_variables, ->{ {} }
38
37
  set :whenever_identifier, ->{ fetch :application }
39
38
  set :whenever_environment, ->{ fetch :rails_env, "production" }
40
39
  set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
@@ -17,11 +17,8 @@ module Whenever
17
17
  end
18
18
 
19
19
  def output
20
- job = process_template(@template, @options).strip
21
- out = process_template(@job_template, @options.merge(:job => job)).strip
22
- if out =~ /\n/
23
- raise ArgumentError, "Task contains newline"
24
- end
20
+ job = process_template(@template, @options)
21
+ out = process_template(@job_template, @options.merge(:job => job))
25
22
  out.gsub(/%/, '\%')
26
23
  end
27
24
 
@@ -43,7 +40,7 @@ module Whenever
43
40
  else
44
41
  option
45
42
  end
46
- end
43
+ end.squish
47
44
  end
48
45
 
49
46
  def escape_single_quotes(str)
@@ -9,20 +9,7 @@ set :path, Whenever.path
9
9
  # http://blog.scoutapp.com/articles/2010/09/07/rvm-and-cron-in-production
10
10
  set :job_template, "/bin/bash -l -c ':job'"
11
11
 
12
- job_type :command, ":task :output"
13
-
14
- # Run rake through bundler if possible
15
- if Whenever.bundler?
16
- job_type :rake, "cd :path && :environment_variable=:environment bundle exec rake :task --silent :output"
17
- job_type :script, "cd :path && :environment_variable=:environment bundle exec script/:task :output"
18
- else
19
- job_type :rake, "cd :path && :environment_variable=:environment rake :task --silent :output"
20
- job_type :script, "cd :path && :environment_variable=:environment script/:task :output"
21
- end
22
-
23
- # Create a runner job that's appropriate for the Rails version
24
- def runner_for_app
25
- case
12
+ set :runner_command, case
26
13
  when Whenever.bin_rails?
27
14
  "bin/rails runner"
28
15
  when Whenever.script_rails?
@@ -30,6 +17,10 @@ def runner_for_app
30
17
  else
31
18
  "script/runner"
32
19
  end
33
- end
34
20
 
35
- job_type :runner, "cd :path && #{runner_for_app} -e :environment ':task' :output"
21
+ set :bundle_command, Whenever.bundler? ? "bundle exec" : ""
22
+
23
+ job_type :command, ":task :output"
24
+ job_type :rake, "cd :path && :environment_variable=:environment :bundle_command rake :task --silent :output"
25
+ job_type :script, "cd :path && :environment_variable=:environment :bundle_command script/:task :output"
26
+ job_type :runner, "cd :path && :runner_command -e :environment ':task' :output"
@@ -1,40 +1,39 @@
1
1
  namespace :whenever do
2
- desc "Update application's crontab entries using Whenever"
3
- task :update_crontab do
4
- on roles fetch(:whenever_roles) do
2
+ def setup_whenever_task(*args, &block)
3
+ SSHKit.config.command_map[:whenever] = fetch(:whenever_command)
4
+
5
+ on roles fetch(:whenever_roles) do |host|
6
+ args = args + Array(yield(host)) if block_given?
5
7
  within release_path do
6
- if fetch(:whenever_command)
7
- execute fetch(:whenever_command), fetch(:whenever_update_flags)
8
- else
9
- execute :bundle, :exec, :whenever, fetch(:whenever_update_flags)
8
+ with fetch(:whenever_command_environment_variables) do
9
+ execute :whenever, *args
10
10
  end
11
11
  end
12
12
  end
13
13
  end
14
14
 
15
+ desc "Update application's crontab entries using Whenever"
16
+ task :update_crontab do
17
+ setup_whenever_task do |host|
18
+ roles = host.roles_array.join(",")
19
+ [fetch(:whenever_update_flags), "--roles=#{roles}"]
20
+ end
21
+ end
22
+
15
23
  desc "Clear application's crontab entries using Whenever"
16
24
  task :clear_crontab do
17
- on roles fetch(:whenever_roles) do
18
- within release_path do
19
- if fetch(:whenever_command)
20
- execute %{#{fetch(:whenever_command)} #{fetch(:whenever_clear_flags)}}
21
- else
22
- execute :bundle, :exec, :whenever, fetch(:whenever_clear_flags)
23
- end
24
- end
25
- end
25
+ setup_whenever_task(fetch(:whenever_clear_flags))
26
26
  end
27
27
 
28
- after 'deploy:updated', 'whenever:update_crontab'
29
- after 'deploy:reverted', 'whenever:update_crontab'
30
-
28
+ after "deploy:updated", "whenever:update_crontab"
29
+ after "deploy:reverted", "whenever:update_crontab"
31
30
  end
32
31
 
33
32
  namespace :load do
34
33
  task :defaults do
35
34
  set :whenever_roles, ->{ :db }
36
- set :whenever_options, ->{ {:roles => fetch(:whenever_roles)} }
37
- set :whenever_command, ->{ }
35
+ set :whenever_command, ->{ "bundle exec whenever" }
36
+ set :whenever_command_environment_variables, ->{ {} }
38
37
  set :whenever_identifier, ->{ fetch :application }
39
38
  set :whenever_environment, ->{ fetch :rails_env, "production" }
40
39
  set :whenever_variables, ->{ "environment=#{fetch :whenever_environment}" }
@@ -1,3 +1,3 @@
1
1
  module Whenever
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
@@ -54,14 +54,13 @@ class JobTest < Test::Unit::TestCase
54
54
  assert_equal %q(before percent preceded by a backslash -> \\\% <- after), job.output
55
55
  end
56
56
 
57
- should "reject newlines" do
57
+ should "squish spaces and newlines" do
58
58
  job = new_job(
59
59
  :template => "before :foo after",
60
- :foo => "newline -> \n <- newline"
60
+ :foo => "newline -> \n <- newline space -> <- space"
61
61
  )
62
- assert_raise ArgumentError do
63
- job.output
64
- end
62
+
63
+ assert_equal "before newline -> <- newline space -> <- space after", job.output
65
64
  end
66
65
  end
67
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenever
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javan Makhmali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-18 00:00:00.000000000 Z
11
+ date: 2014-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.1.11
147
+ rubygems_version: 2.0.14
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Cron jobs in ruby.