clockwork 1.1.0 → 1.2.0

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: aeec7e9d85ccbc4235df4e959852c62964bd756c
4
- data.tar.gz: b17b8d59d78d23e19813fee904a5f32817566f4f
3
+ metadata.gz: a1c0df23cd1bd9f2a974f5d5461b162d5449858b
4
+ data.tar.gz: 57d4d055c37fea9164a51ea16afb34cf72b6ca16
5
5
  SHA512:
6
- metadata.gz: 46e85795da235c9ad95081f33d871e58712fd37cfaca1ba02239722a8bbeb109aea00538c9e8a852ad8f752f5847a494098da15a7c6ec1e34daea1d9b23ac031
7
- data.tar.gz: 68ba156bc2bd8400fe74f10420f543eeb547167b14bc35ef108357674074b2b8cd0e834daddfa04802425b88c08c1e9e307148ed84862075ed28ae068fa52644
6
+ metadata.gz: 61a97fce154912af62947c6591f771ce532e1b87bc4b25cd83d6983ac2d1618ebe9c98a4c2df7cc939a3af2d04aa9bef6b29169f3b38ca07eb63fece32a97fdc
7
+ data.tar.gz: f9a24be2f061626b409b69fa43f53b0ee16da421d892a5b5afd4bc86623ce41e74ab598bf0b89a9451c42c0279cc76314b92f8fb1706922312cdf51c53092dee
@@ -1,7 +1,11 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
1
4
  rvm:
2
5
  - 1.9.3
3
6
  - 2.0.0
4
- - 2.1.0
7
+ - 2.1
8
+ - 2.2
5
9
  - jruby-19mode
6
10
  - # rbx-2.2.7
7
11
  gemfile:
data/README.md CHANGED
@@ -36,7 +36,7 @@ module Clockwork
36
36
  end
37
37
  ```
38
38
 
39
- Run it with the clockwork binary:
39
+ Run it with the clockwork executable:
40
40
 
41
41
  ```
42
42
  $ clockwork clock.rb
@@ -269,6 +269,9 @@ You can specify the day of week to run:
269
269
  every(1.week, 'myjob', :at => 'Monday 16:20')
270
270
  ```
271
271
 
272
+ If another task is already running at the specified time, clockwork will skip execution of the task with the `:at` option.
273
+ If this is a problem, please use the `:thread` option to prevent the long running task from blocking clockwork's scheduler.
274
+
272
275
  ### :tz
273
276
 
274
277
  `:tz` parameter lets you specify a timezone (default is the local timezone):
@@ -300,11 +303,11 @@ Clockwork.every(1.second, 'myjob', :if => lambda { |_| true })
300
303
 
301
304
  ### :thread
302
305
 
303
- In default, clockwork runs in single-process, single-thread.
304
- If an event handler takes long time, the main routine of clockwork is blocked until it ends.
306
+ By default, clockwork runs in a single-process and single-thread.
307
+ If an event handler takes a long time, the main routine of clockwork is blocked until it ends.
305
308
  Clockwork does not misbehave, but the next event is blocked, and runs when the process is returned to the clockwork routine.
306
309
 
307
- This `:thread` option is to avoid blocking. An event with `:thread => true` runs in a different thread.
310
+ The `:thread` option is to avoid blocking. An event with `thread: true` runs in a different thread.
308
311
 
309
312
  ```ruby
310
313
  Clockwork.every(1.day, 'run.me.in.new.thread', :thread => true)
@@ -390,7 +393,7 @@ Anatomy of a clock file
390
393
  -----------------------
391
394
 
392
395
  clock.rb is standard Ruby. Since we include the Clockwork module (the
393
- clockwork binary does this automatically, or you can do it explicitly), this
396
+ clockwork executable does this automatically, or you can do it explicitly), this
394
397
  exposes a small DSL to define the handler for events, and then the events themselves.
395
398
 
396
399
  The handler typically looks like this:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "clockwork"
3
- s.version = "1.1.0"
3
+ s.version = "1.2.0"
4
4
 
5
5
  s.authors = ["Adam Wiggins", "tomykaira"]
6
6
  s.license = 'MIT'
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency "bundler", "~> 1.3"
24
24
  s.add_development_dependency "rake"
25
25
  s.add_development_dependency "daemons"
26
- s.add_development_dependency "contest"
26
+ s.add_development_dependency "test-unit"
27
27
  s.add_development_dependency "minitest", "~> 4.0"
28
28
  s.add_development_dependency "mocha"
29
29
  end
@@ -42,7 +42,11 @@ module Clockwork
42
42
  (@callbacks[event.to_sym]||=[]) << block
43
43
  end
44
44
 
45
- def every(period, job, options={}, &block)
45
+ def every(period, job='unnamed', options={}, &block)
46
+ if job.is_a?(Hash) and options.empty?
47
+ options = job
48
+ job = "unnamed"
49
+ end
46
50
  if options[:at].respond_to?(:each)
47
51
  every_with_multiple_times(period, job, options, &block)
48
52
  else
@@ -1,11 +1,12 @@
1
1
  require File.expand_path('../../lib/clockwork', __FILE__)
2
2
  require 'rubygems'
3
- require 'contest'
3
+ require 'test/unit'
4
4
  require 'mocha/setup'
5
5
  require 'time'
6
6
  require 'active_support/time'
7
+ require 'active_support/test_case'
7
8
 
8
- class AtTest < Test::Unit::TestCase
9
+ class AtTest < ActiveSupport::TestCase
9
10
  def time_in_day(hour, minute)
10
11
  Time.new(2013, 1, 1, hour, minute, 0)
11
12
  end
@@ -1,5 +1,5 @@
1
1
  require File.expand_path('../../lib/clockwork', __FILE__)
2
- require 'contest'
2
+ require 'test/unit'
3
3
  require 'mocha/setup'
4
4
 
5
5
  class ClockworkTest < Test::Unit::TestCase
@@ -1,7 +1,8 @@
1
- require 'contest'
1
+ require 'test/unit'
2
2
  require 'mocha/setup'
3
3
  require 'time'
4
4
  require 'active_support/time'
5
+ require 'active_support/test_case'
5
6
 
6
7
  require_relative '../../lib/clockwork'
7
8
  require_relative '../../lib/clockwork/database_events'
@@ -9,7 +10,7 @@ require_relative 'test_helpers'
9
10
 
10
11
  module DatabaseEvents
11
12
 
12
- class SyncPerformerTest < Test::Unit::TestCase
13
+ class SyncPerformerTest < ActiveSupport::TestCase
13
14
 
14
15
  setup do
15
16
  @now = Time.now
@@ -58,7 +59,7 @@ module DatabaseEvents
58
59
  setup_sync(model: DatabaseEventModel, :every => @sync_frequency, :events_run => @events_run)
59
60
 
60
61
  tick_at(@now, :and_every_second_for => 1.second)
61
-
62
+
62
63
  assert_equal ["DatabaseEventModel:1"], @events_run
63
64
  end
64
65
 
@@ -263,7 +264,7 @@ module DatabaseEvents
263
264
  setup do
264
265
  @events_run = []
265
266
  @utc_time_now = Time.now.utc
266
-
267
+
267
268
  DatabaseEventModel.create(:frequency => 1.days, :at => @utc_time_now.strftime('%H:%M'), :tz => 'America/Montreal')
268
269
  setup_sync(model: DatabaseEventModel, :every => 1.minute, :events_run => @events_run)
269
270
  end
@@ -1,7 +1,7 @@
1
1
  require File.expand_path('../../lib/clockwork', __FILE__)
2
- require 'contest'
2
+ require 'active_support/test_case'
3
3
 
4
- class EventTest < Test::Unit::TestCase
4
+ class EventTest < ActiveSupport::TestCase
5
5
  describe "#thread?" do
6
6
  setup do
7
7
  @manager = mock
@@ -1,11 +1,12 @@
1
1
  require File.expand_path('../../lib/clockwork', __FILE__)
2
2
  require 'rubygems'
3
- require 'contest'
3
+ require 'test/unit'
4
4
  require 'mocha/setup'
5
5
  require 'time'
6
6
  require 'active_support/time'
7
+ require 'active_support/test_case'
7
8
 
8
- class ManagerTest < Test::Unit::TestCase
9
+ class ManagerTest < ActiveSupport::TestCase
9
10
  setup do
10
11
  @manager = Clockwork::Manager.new
11
12
  class << @manager
@@ -156,6 +157,16 @@ class ManagerTest < Test::Unit::TestCase
156
157
  assert_equal false, @manager.config[:thread]
157
158
  end
158
159
 
160
+ test "should accept unnamed job" do
161
+ event = @manager.every(1.minute)
162
+ assert_equal 'unnamed', event.job
163
+ end
164
+
165
+ test "should accept options without job name" do
166
+ event = @manager.every(1.minute, {})
167
+ assert_equal 'unnamed', event.job
168
+ end
169
+
159
170
  describe ':at option' do
160
171
  test "once a day at 16:20" do
161
172
  @manager.every(1.day, 'myjob', :at => '16:20')
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: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wiggins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-19 00:00:00.000000000 Z
12
+ date: 2015-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tzinfo
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: contest
85
+ name: test-unit
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="