clockwork 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -0
- data/README.md +6 -1
- data/VERSION +1 -1
- data/bin/clockwork +1 -1
- data/bin/clockworkd +1 -1
- data/lib/clockwork.rb +4 -5
- data/test/clockwork_test.rb +11 -1
- metadata +19 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (3.2.13)
|
5
|
+
i18n (= 0.6.1)
|
6
|
+
multi_json (~> 1.0)
|
4
7
|
contest (0.1.3)
|
5
8
|
daemons (1.1.9)
|
6
9
|
git (1.2.5)
|
10
|
+
i18n (0.6.1)
|
7
11
|
jeweler (1.8.4)
|
8
12
|
bundler (~> 1.0)
|
9
13
|
git (>= 1.2.5)
|
@@ -13,6 +17,7 @@ GEM
|
|
13
17
|
metaclass (0.0.1)
|
14
18
|
mocha (0.13.2)
|
15
19
|
metaclass (~> 0.0.1)
|
20
|
+
multi_json (1.7.3)
|
16
21
|
rake (10.0.3)
|
17
22
|
rdoc (4.0.0)
|
18
23
|
json (~> 1.4)
|
@@ -22,6 +27,7 @@ PLATFORMS
|
|
22
27
|
ruby
|
23
28
|
|
24
29
|
DEPENDENCIES
|
30
|
+
activesupport
|
25
31
|
contest
|
26
32
|
daemons
|
27
33
|
jeweler
|
data/README.md
CHANGED
@@ -41,6 +41,11 @@ it as the module (thanks to [hoverlover](https://github.com/hoverlover/clockwork
|
|
41
41
|
require 'clockwork'
|
42
42
|
|
43
43
|
module Clockwork
|
44
|
+
|
45
|
+
configure do |cofig|
|
46
|
+
config[:tz] = "America/Chicago"
|
47
|
+
end
|
48
|
+
|
44
49
|
handler do |job|
|
45
50
|
puts "Running #{job}"
|
46
51
|
end
|
@@ -142,7 +147,7 @@ Run on every first day of month.
|
|
142
147
|
|
143
148
|
Clockwork.every(1.day, 'myjob', :if => lambda { |t| t.day == 1 })
|
144
149
|
|
145
|
-
The argument is an instance of `
|
150
|
+
The argument is an instance of `ActiveSupport::TimeWithZone` if the `:tz` option is set. Otherwise, it's an instance of `Time`.
|
146
151
|
|
147
152
|
This argument cannot be omitted. Please use _ as placeholder if not needed.
|
148
153
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.2
|
data/bin/clockwork
CHANGED
data/bin/clockworkd
CHANGED
data/lib/clockwork.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'logger'
|
2
|
-
require '
|
2
|
+
require 'active_support/time'
|
3
3
|
|
4
4
|
module Clockwork
|
5
5
|
|
@@ -73,8 +73,7 @@ module Clockwork
|
|
73
73
|
@thread = options[:thread]
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
@timezone = TZInfo::Timezone.get(tz) if tz
|
76
|
+
@timezone = options[:tz] || Clockwork.config[:tz]
|
78
77
|
end
|
79
78
|
|
80
79
|
def to_s
|
@@ -82,7 +81,7 @@ module Clockwork
|
|
82
81
|
end
|
83
82
|
|
84
83
|
def convert_timezone(t)
|
85
|
-
@timezone ? @timezone
|
84
|
+
@timezone ? t.in_time_zone(@timezone) : t
|
86
85
|
end
|
87
86
|
|
88
87
|
def time?(t)
|
@@ -139,7 +138,7 @@ module Clockwork
|
|
139
138
|
def configure
|
140
139
|
yield(config)
|
141
140
|
end
|
142
|
-
|
141
|
+
|
143
142
|
def config
|
144
143
|
@@configuration
|
145
144
|
end
|
data/test/clockwork_test.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require File.expand_path('../../lib/clockwork', __FILE__)
|
2
2
|
require 'rubygems'
|
3
3
|
require 'contest'
|
4
|
-
require 'mocha'
|
4
|
+
require 'mocha/setup'
|
5
5
|
require 'time'
|
6
|
+
require 'active_support/time'
|
6
7
|
|
7
8
|
module Clockwork
|
8
9
|
def log(msg)
|
@@ -244,6 +245,15 @@ class ClockworkTest < Test::Unit::TestCase
|
|
244
245
|
assert_will_run 'feb 1 2010 16:20:00'
|
245
246
|
end
|
246
247
|
|
248
|
+
test ":if it is compared to a time with zone" do
|
249
|
+
tz = "America/Chicago"
|
250
|
+
time = Time.utc(2012,5,25,10,00)
|
251
|
+
Clockwork.every(1.second, 'myjob', tz: tz, :if => lambda { |t|(
|
252
|
+
((time - 1.hour)..(time + 1.hour)).cover? t
|
253
|
+
)})
|
254
|
+
assert_will_run time
|
255
|
+
end
|
256
|
+
|
247
257
|
test ":if is not callable then raise ArgumentError" do
|
248
258
|
assert_raise(ArgumentError) do
|
249
259
|
Clockwork.every(1.second, 'myjob', :if => true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clockwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tzinfo
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 0.3.35
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: jeweler
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
140
|
version: '0'
|
125
141
|
segments:
|
126
142
|
- 0
|
127
|
-
hash:
|
143
|
+
hash: 533309331
|
128
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
145
|
none: false
|
130
146
|
requirements:
|