rufus-scheduler 2.0.15 → 2.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -2,6 +2,12 @@
2
2
  = rufus-scheduler CHANGELOG.txt
3
3
 
4
4
 
5
+ == rufus-scheduler - 2.0.16 released 2011/12/31
6
+
7
+ - hardened Rufus.parse_time_string
8
+ - running job thread: getting rid of the job pointer once job is done
9
+
10
+
5
11
  == rufus-scheduler - 2.0.15 released 2011/12/20
6
12
 
7
13
  - Scheduler#running_jobs (Thanks Louis Coilliot)
data/lib/rufus/sc/jobs.rb CHANGED
@@ -188,7 +188,12 @@ module Scheduler
188
188
 
189
189
  trigger_block
190
190
 
191
+ job_thread[
192
+ "rufus_scheduler__trigger_thread__#{@scheduler.object_id}"
193
+ ] = nil
194
+
191
195
  job_thread = nil
196
+
192
197
  to_job.unschedule if to_job
193
198
 
194
199
  rescue Exception => e
@@ -122,42 +122,22 @@ module Rufus
122
122
  #
123
123
  def Rufus.parse_time_string(string)
124
124
 
125
- return string.to_f if FLOAT_DURATION.match(string)
125
+ if m = string.match(/^(\d*)\.?(\d*)([A-Za-z])(.*)$/)
126
126
 
127
- string = string.strip
127
+ number = "#{m[1]}.#{m[2]}".to_f
128
+ multiplier = DURATIONS[m[3]]
128
129
 
129
- index = -1
130
- result = 0.0
130
+ raise ArgumentError.new("unknown time char '#{m[3]}'") unless multiplier
131
131
 
132
- number = ''
132
+ return number * multiplier + parse_time_string(m[4])
133
133
 
134
- loop do
134
+ else
135
135
 
136
- index = index + 1
136
+ return string.to_i / 1000.0 if string.match(/^\d+$/)
137
+ return string.to_f if string.match(/^\d*\.?\d*$/)
137
138
 
138
- if index >= string.length
139
- result = result + (Float(number) / 1000.0) if number.length > 0
140
- break
141
- end
142
-
143
- c = string[index, 1]
144
-
145
- if (c >= '0' and c <= '9')
146
- number = number + c
147
- next
148
- end
149
-
150
- value = Integer(number)
151
- number = ''
152
-
153
- multiplier = DURATIONS[c]
154
-
155
- raise ArgumentError.new("unknown time char '#{c}'") unless multiplier
156
-
157
- result = result + (value * multiplier)
139
+ raise ArgumentError.new("cannot parse '#{string}'")
158
140
  end
159
-
160
- result
161
141
  end
162
142
 
163
143
  class << self
@@ -26,7 +26,7 @@
26
26
  module Rufus
27
27
  module Scheduler
28
28
 
29
- VERSION = '2.0.15'
29
+ VERSION = '2.0.16'
30
30
  end
31
31
  end
32
32
 
data/spec/rtime_spec.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  require 'spec_base'
9
9
 
10
10
 
11
- describe 'rufus/otime' do
11
+ describe 'rufus/rtime' do
12
12
 
13
13
  def pts(s)
14
14
  Rufus.parse_time_string(s)
@@ -24,6 +24,7 @@ describe 'rufus/otime' do
24
24
 
25
25
  it 'parses duration strings' do
26
26
 
27
+ pts('').should == 0.0
27
28
  pts('5.0').should == 5.0
28
29
  pts('0.5').should == 0.5
29
30
  pts('.5').should == 0.5
@@ -32,10 +33,12 @@ describe 'rufus/otime' do
32
33
  pts('1000').should == 1.0
33
34
  pts('1').should == 0.001
34
35
  pts('1s').should == 1.0
36
+ pts('2.5s').should == 2.5
35
37
  pts('1h').should == 3600.0
36
38
  pts('1h10s').should == 3610.0
37
39
  pts('1w2d').should == 777600.0
38
40
  pts('1d1w1d').should == 777600.0
41
+ pts('1.0d1.0w1.0d').should == 777600.0
39
42
  end
40
43
 
41
44
  it 'generates duration strings' do
@@ -61,7 +64,7 @@ describe 'rufus/otime' do
61
64
  end
62
65
  end
63
66
 
64
- describe 'rufus/otime#at_to_f' do
67
+ describe 'rufus/rtime#at_to_f' do
65
68
 
66
69
  def atf(o)
67
70
  Rufus.at_to_f(o)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-scheduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-20 00:00:00.000000000 +09:00
12
+ date: 2011-12-31 00:00:00.000000000 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: tzinfo
17
- requirement: &2156163440 !ruby/object:Gem::Requirement
17
+ requirement: &2153487720 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.3.23
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2156163440
25
+ version_requirements: *2153487720
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
- requirement: &2156163000 !ruby/object:Gem::Requirement
28
+ requirement: &2153487240 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2156163000
36
+ version_requirements: *2153487240
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &2156162340 !ruby/object:Gem::Requirement
39
+ requirement: &2153486660 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 2.7.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2156162340
47
+ version_requirements: *2153486660
48
48
  description: job scheduler for Ruby (at, cron, in and every jobs).
49
49
  email:
50
50
  - jmettraux@gmail.com