whenever 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,14 @@
1
+ == 0.4.2 / April 26th, 2010
2
+
3
+ * runners now cd into the app's directory and then execute. [Michael Guterl]
4
+
5
+ * Fix STDERR output redirection to file to append instead of overwrite. [weplay]
6
+
7
+ * Move require of tempfile lib to file that actually uses it. [Finn Smith]
8
+
9
+ * bugfix: comparison Time with 0 failed. #32 [Dan Hixon]
10
+
11
+
1
12
  == 0.4.1 / November 30th, 2009
2
13
 
3
14
  * exit(0) instead of just exit to make JRuby happy. [Elan Meng]
data/README.rdoc CHANGED
@@ -7,18 +7,8 @@ Ryan Bates created a great Railscast about Whenever: http://railscasts.com/episo
7
7
  Discussion: http://groups.google.com/group/whenever-gem
8
8
 
9
9
  == Installation
10
-
11
- If you haven't already, get set up with http://gemcutter.org
12
-
13
- $ sudo gem install whenever
14
-
15
- In a Rails (2.1 or greater) application:
16
10
 
17
- in your "config/environment.rb" file:
18
-
19
- Rails::Initializer.run do |config|
20
- config.gem 'whenever', :lib => false, :source => 'http://gemcutter.org/'
21
- end
11
+ $ sudo gem install whenever
22
12
 
23
13
  == Getting started
24
14
 
@@ -91,7 +81,7 @@ If you've found a genuine bug or issue, please use the Issues section on github:
91
81
 
92
82
  == License
93
83
 
94
- Copyright (c) 2009 Javan Makhmali
84
+ Copyright (c) 2009+ Javan Makhmali
95
85
 
96
86
  Permission is hereby granted, free of charge, to any person
97
87
  obtaining a copy of this software and associated documentation
data/bin/whenever CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'optparse'
5
- require 'fileutils'
6
- require 'tempfile'
7
5
  require 'whenever'
8
6
 
9
7
  options = Hash.new
@@ -27,4 +25,4 @@ OptionParser.new do |opts|
27
25
  end
28
26
  end.parse!
29
27
 
30
- Whenever::CommandLine.execute(options)
28
+ Whenever::CommandLine.execute(options)
data/lib/whenever.rb CHANGED
@@ -12,10 +12,10 @@ end
12
12
  # It was previously defined as a dependency of this gem, but that became
13
13
  # problematic. See: http://github.com/javan/whenever/issues#issue/1
14
14
  begin
15
- require 'active_support'
15
+ require 'active_support/all'
16
16
  rescue LoadError
17
- warn 'To user Whenever you need the active_support gem:'
18
- warn '$ sudo gem install active_support'
17
+ warn 'To use Whenever you need the active_support gem:'
18
+ warn '$ gem install activesupport'
19
19
  exit(1)
20
20
  end
21
21
 
@@ -1,3 +1,6 @@
1
+ require 'fileutils'
2
+ require 'tempfile'
3
+
1
4
  module Whenever
2
5
  class CommandLine
3
6
 
@@ -105,4 +108,4 @@ module Whenever
105
108
  end
106
109
 
107
110
  end
108
- end
111
+ end
@@ -4,7 +4,7 @@ module Whenever
4
4
 
5
5
  def output
6
6
  path_required
7
- %Q(#{File.join(@path, 'script', 'runner')} -e #{@environment} #{task.inspect})
7
+ %Q(cd #{File.join(@path)} && script/runner -e #{@environment} #{task.inspect})
8
8
  end
9
9
 
10
10
  end
@@ -60,7 +60,7 @@ module Whenever
60
60
  end
61
61
 
62
62
  if shortcut
63
- if @at > 0
63
+ if @at.is_a?(Time) || (@at.is_a?(Numeric) && @at>0)
64
64
  raise ArgumentError, "You cannot specify an ':at' when using the shortcuts for times."
65
65
  else
66
66
  return shortcut
@@ -32,11 +32,17 @@ module Whenever
32
32
  def redirect_from_hash
33
33
  case
34
34
  when stdout == '/dev/null' && stderr == '/dev/null'
35
- ">> /dev/null 2>&1"
35
+ "> /dev/null 2>&1"
36
+ when stdout && stderr == '/dev/null'
37
+ ">> #{stdout} 2> /dev/null"
36
38
  when stdout && stderr
37
- ">> #{stdout} 2> #{stderr}"
39
+ ">> #{stdout} 2>> #{stderr}"
40
+ when stderr == '/dev/null'
41
+ "2> /dev/null"
38
42
  when stderr
39
- "2> #{stderr}"
43
+ "2>> #{stderr}"
44
+ when stdout == '/dev/null'
45
+ "> /dev/null"
40
46
  when stdout
41
47
  ">> #{stdout}"
42
48
  else
@@ -1,3 +1,3 @@
1
1
  module Whenever
2
- VERSION = '0.4.1'
2
+ VERSION = '0.4.2'
3
3
  end unless defined?(Whenever::VERSION)
@@ -91,7 +91,7 @@ class OutputAtTest < Test::Unit::TestCase
91
91
  end
92
92
 
93
93
  should "output the runner using one entry because the times are aligned" do
94
- assert_match '2 5,15 * * 1,3,5 /your/path/script/runner -e production "blahblah"', @output
94
+ assert_match '2 5,15 * * 1,3,5 cd /your/path && script/runner -e production "blahblah"', @output
95
95
  end
96
96
  end
97
97
 
@@ -168,9 +168,9 @@ class OutputAtTest < Test::Unit::TestCase
168
168
 
169
169
  should "output all of the commands @daily" do
170
170
  assert_match '@daily cd /your/path && RAILS_ENV=production /usr/bin/env rake blah:blah', @output
171
- assert_match '@daily /your/path/script/runner -e production "runner_1"', @output
171
+ assert_match '@daily cd /your/path && script/runner -e production "runner_1"', @output
172
172
  assert_match '@daily command_1', @output
173
- assert_match '@daily /your/path/script/runner -e production "runner_2"', @output
173
+ assert_match '@daily cd /your/path && script/runner -e production "runner_2"', @output
174
174
  assert_match '@daily command_2', @output
175
175
  end
176
176
  end
@@ -46,7 +46,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
46
46
  end
47
47
 
48
48
  should "output the command without the log syntax appended" do
49
- assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2> dev_err$/, @output
49
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
50
50
  end
51
51
  end
52
52
 
@@ -80,7 +80,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
80
80
 
81
81
  should "output the command with the overridden redirection syntax appended" do
82
82
  assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
83
- assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2> dev_err$/, @output
83
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
84
84
  end
85
85
  end
86
86
 
@@ -130,7 +130,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
130
130
  end
131
131
 
132
132
  should "output the command without the redirection syntax appended" do
133
- assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2> dev_err$/, @output
133
+ assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
134
134
  end
135
135
  end
136
136
 
@@ -145,8 +145,8 @@ class OutputRedirectionTest < Test::Unit::TestCase
145
145
  file
146
146
  end
147
147
 
148
- should "output the command without the standard errror syntax appended" do
149
- assert_match /^.+ .+ .+ .+ blahblah 2> dev_null$/, @output
148
+ should "output the command without the standard error syntax appended" do
149
+ assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, @output
150
150
  end
151
151
  end
152
152
 
@@ -177,7 +177,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
177
177
  end
178
178
 
179
179
  should "output the command without the log syntax appended" do
180
- assert_match /^.+ .+ .+ .+ blahblah 2> dev_err$/, @output
180
+ assert_match /^.+ .+ .+ .+ blahblah 2>> dev_err$/, @output
181
181
  end
182
182
  end
183
183
 
@@ -207,7 +207,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
207
207
  end
208
208
 
209
209
  should "output the command with stdout directed to /dev/null" do
210
- assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null$/, @output
210
+ assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null$/, @output
211
211
  end
212
212
  end
213
213
 
@@ -237,7 +237,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
237
237
  end
238
238
 
239
239
  should "output the command with stderr directed to /dev/null" do
240
- assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, @output
240
+ assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, @output
241
241
  end
242
242
  end
243
243
 
@@ -267,7 +267,7 @@ class OutputRedirectionTest < Test::Unit::TestCase
267
267
  end
268
268
 
269
269
  should "output the command with stderr directed to /dev/null" do
270
- assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2> my_error.log$/, @output
270
+ assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, @output
271
271
  end
272
272
  end
273
273
 
@@ -286,4 +286,4 @@ class OutputRedirectionTest < Test::Unit::TestCase
286
286
  assert_match /^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, @output
287
287
  end
288
288
  end
289
- end
289
+ end
@@ -14,7 +14,7 @@ class OutputRunnerTest < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  should "output the runner using that path" do
17
- assert_match two_hours + ' /my/path/script/runner -e production "blahblah"', @output
17
+ assert_match two_hours + ' cd /my/path && script/runner -e production "blahblah"', @output
18
18
  end
19
19
  end
20
20
 
@@ -30,7 +30,7 @@ class OutputRunnerTest < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  should "output the runner using that path" do
33
- assert_match two_hours + ' /some/other/path/script/runner -e production "blahblah"', @output
33
+ assert_match two_hours + ' cd /some/other/path && script/runner -e production "blahblah"', @output
34
34
  end
35
35
  end
36
36
 
@@ -47,7 +47,7 @@ class OutputRunnerTest < Test::Unit::TestCase
47
47
  end
48
48
 
49
49
  should "output the runner using that path" do
50
- assert_match two_hours + ' /my/path/script/runner -e production "blahblah"', @output
50
+ assert_match two_hours + ' cd /my/path && script/runner -e production "blahblah"', @output
51
51
  end
52
52
  end
53
53
 
@@ -65,7 +65,7 @@ class OutputRunnerTest < Test::Unit::TestCase
65
65
  end
66
66
 
67
67
  should "use the path" do
68
- assert_match two_hours + ' /my/path/script/runner -e production "blahblah"', @output
68
+ assert_match two_hours + ' cd /my/path && script/runner -e production "blahblah"', @output
69
69
  assert_no_match /\/rails\/path/, @output
70
70
  end
71
71
  end
@@ -101,7 +101,7 @@ class OutputRunnerTest < Test::Unit::TestCase
101
101
  end
102
102
 
103
103
  should "output the runner using that environment" do
104
- assert_match two_hours + ' /my/path/script/runner -e silly "blahblah"', @output
104
+ assert_match two_hours + ' cd /my/path && script/runner -e silly "blahblah"', @output
105
105
  end
106
106
  end
107
107
 
@@ -118,7 +118,7 @@ class OutputRunnerTest < Test::Unit::TestCase
118
118
  end
119
119
 
120
120
  should "output the runner using that environment" do
121
- assert_match two_hours + ' /my/path/script/runner -e serious "blahblah"', @output
121
+ assert_match two_hours + ' cd /my/path && script/runner -e serious "blahblah"', @output
122
122
  end
123
123
  end
124
124
 
@@ -135,7 +135,7 @@ class OutputRunnerTest < Test::Unit::TestCase
135
135
  end
136
136
 
137
137
  should "output the runner using the override environment" do
138
- assert_match two_hours + ' /my/path/script/runner -e serious "blahblah"', @output
138
+ assert_match two_hours + ' cd /my/path && script/runner -e serious "blahblah"', @output
139
139
  end
140
140
  end
141
141
 
@@ -152,7 +152,7 @@ class OutputRunnerTest < Test::Unit::TestCase
152
152
  end
153
153
 
154
154
  should "output the runner using the overridden path and environment" do
155
- assert_match two_hours + ' /serious/path/script/runner -e serious "blahblah"', @output
155
+ assert_match two_hours + ' cd /serious/path && script/runner -e serious "blahblah"', @output
156
156
  end
157
157
  end
158
158
 
@@ -169,7 +169,7 @@ class OutputRunnerTest < Test::Unit::TestCase
169
169
  end
170
170
 
171
171
  should "output the runner using the overridden path and environment" do
172
- assert_match two_hours + ' /serious/path/script/runner -e serious "blahblah"', @output
172
+ assert_match two_hours + ' cd /serious/path && script/runner -e serious "blahblah"', @output
173
173
  end
174
174
  end
175
175
 
@@ -186,7 +186,7 @@ class OutputRunnerTest < Test::Unit::TestCase
186
186
  end
187
187
 
188
188
  should "output the runner using the original environmnet" do
189
- assert_match two_hours + ' /silly/path/script/runner -e silly "blahblah"', @output
189
+ assert_match two_hours + ' cd /silly/path && script/runner -e silly "blahblah"', @output
190
190
  end
191
191
  end
192
192
 
@@ -202,7 +202,7 @@ class OutputRunnerTest < Test::Unit::TestCase
202
202
  end
203
203
 
204
204
  should "output the runner using the original environmnet" do
205
- assert_match two_hours + ' /my/path/script/runner -e production "Product.import(\"http://example.com/product.xml\")"', @output
205
+ assert_match two_hours + ' cd /my/path && script/runner -e production "Product.import(\"http://example.com/product.xml\")"', @output
206
206
  end
207
207
  end
208
208
 
data/whenever.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{whenever}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Javan Makhmali"]
12
- s.date = %q{2009-11-30}
12
+ s.date = %q{2010-04-26}
13
13
  s.description = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
14
14
  s.email = %q{javan@javan.us}
15
15
  s.executables = ["whenever", "wheneverize"]
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
47
47
  s.homepage = %q{http://github.com/javan/whenever}
48
48
  s.rdoc_options = ["--charset=UTF-8"]
49
49
  s.require_paths = ["lib"]
50
- s.rubygems_version = %q{1.3.5}
50
+ s.rubygems_version = %q{1.3.6}
51
51
  s.summary = %q{Clean ruby syntax for defining and deploying messy cron jobs.}
52
52
  s.test_files = [
53
53
  "test/command_line_test.rb",
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenever
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ - 2
9
+ version: 0.4.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Javan Makhmali
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-30 00:00:00 -05:00
17
+ date: 2010-04-26 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: chronic
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 2
30
+ - 3
23
31
  version: 0.2.3
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description: Clean ruby syntax for defining and deploying messy cron jobs.
26
35
  email: javan@javan.us
27
36
  executables:
@@ -71,18 +80,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
80
  requirements:
72
81
  - - ">="
73
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
74
85
  version: "0"
75
- version:
76
86
  required_rubygems_version: !ruby/object:Gem::Requirement
77
87
  requirements:
78
88
  - - ">="
79
89
  - !ruby/object:Gem::Version
90
+ segments:
91
+ - 0
80
92
  version: "0"
81
- version:
82
93
  requirements: []
83
94
 
84
95
  rubyforge_project:
85
- rubygems_version: 1.3.5
96
+ rubygems_version: 1.3.6
86
97
  signing_key:
87
98
  specification_version: 3
88
99
  summary: Clean ruby syntax for defining and deploying messy cron jobs.