kronparser 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +8 -0
- data/lib/kronparser.rb +8 -15
- data/lib/kronparser/version.rb +1 -1
- data/spec/kronparser_spec.rb +1 -0
- metadata +35 -54
data/MIT-LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Copyright (c) 2012 mechamogera
|
2
|
+
https://github.com/mechamogera/kronparser
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/kronparser.rb
CHANGED
@@ -110,7 +110,7 @@ class KronParser
|
|
110
110
|
|
111
111
|
value = nil
|
112
112
|
next_mon, forward = next_elem(:mon, options[:mon] + 1)
|
113
|
-
date = Date.new(options[:year] + forward, next_mon, 1)
|
113
|
+
date = Date.new(options[:year] + forward, next_mon, 1)
|
114
114
|
next_wday = @data[:wday].find { |x| x >= date.wday }
|
115
115
|
value = 1 + (next_wday ? (next_wday - date.wday) : (7 - date.wday + @data[:wday].first))
|
116
116
|
|
@@ -128,27 +128,20 @@ class KronParser
|
|
128
128
|
if (type != :day) || (@day_type != :wday)
|
129
129
|
next_value = @data[type].find { |x| x >= value }
|
130
130
|
forward = next_value.nil? ? 1 : 0
|
131
|
-
next_value =
|
132
|
-
end
|
131
|
+
next_value = first_elem(type, options) unless next_value
|
133
132
|
|
134
|
-
|
135
|
-
return next_value, forward
|
133
|
+
return next_value, forward if (type != :day) || (@day_type == :day)
|
136
134
|
end
|
137
135
|
|
138
|
-
wday_forward =
|
139
|
-
next_wday_value =
|
136
|
+
wday_forward = 1
|
137
|
+
next_wday_value = nil
|
140
138
|
date = Date.new(options[:year], options[:mon], value) rescue nil
|
141
139
|
if date
|
142
140
|
next_wday = @data[:wday].find { |x| x >= date.wday }
|
143
|
-
next_wday_value
|
144
|
-
if next_wday_value <= 31
|
145
|
-
wday_forward = 0
|
146
|
-
else
|
147
|
-
next_wday_value, wday_forward = first_elem(type, options), 1
|
148
|
-
end
|
149
|
-
else
|
150
|
-
next_wday_value, wday_forward = first_elem(type, options), 1
|
141
|
+
next_wday_value = value + (next_wday ? (next_wday - date.wday) : (7 - date.wday + @data[:wday].first))
|
142
|
+
wday_forward = 0 if next_wday_value <= 31
|
151
143
|
end
|
144
|
+
next_wday_value = first_elem(type, options) if wday_forward == 1
|
152
145
|
|
153
146
|
case @day_type
|
154
147
|
when :wday
|
data/lib/kronparser/version.rb
CHANGED
data/spec/kronparser_spec.rb
CHANGED
@@ -127,6 +127,7 @@ describe KronParser do
|
|
127
127
|
["* * 29 2 5", :next, "2012/02/03 23:59:59", "2012/02/10 00:00:00"],
|
128
128
|
["* * 29 2 5", :next, "2012/02/24 23:59:59", "2012/02/29 00:00:00"],
|
129
129
|
["* * 29 2 5", :next, "2012/02/29 23:59:59", "2013/02/01 00:00:00"],
|
130
|
+
["* * 29 2,5 5", :next, "2012/02/29 23:59:59", "2012/05/04 00:00:00"],
|
130
131
|
]
|
131
132
|
|
132
133
|
test_data.each do |cron_time_format, target_method, now_date, get_date|
|
metadata
CHANGED
@@ -1,48 +1,37 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: kronparser
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
segments_generated: true
|
10
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- mechamogera
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
type: :development
|
23
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
segments_generated: true
|
30
|
-
version: "0"
|
12
|
+
date: 2012-10-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
31
15
|
name: rspec
|
32
|
-
requirement:
|
16
|
+
requirement: &70325128253200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
33
23
|
prerelease: false
|
24
|
+
version_requirements: *70325128253200
|
34
25
|
description: datermine next scheduled crontab run
|
35
|
-
email:
|
36
|
-
-
|
26
|
+
email:
|
27
|
+
- ''
|
37
28
|
executables: []
|
38
|
-
|
39
29
|
extensions: []
|
40
|
-
|
41
30
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
31
|
+
files:
|
44
32
|
- .gitignore
|
45
33
|
- Gemfile
|
34
|
+
- MIT-LICENSE
|
46
35
|
- README.md
|
47
36
|
- Rakefile
|
48
37
|
- kronparser.gemspec
|
@@ -51,38 +40,30 @@ files:
|
|
51
40
|
- lib/kronparser/version.rb
|
52
41
|
- spec/kronparser_spec.rb
|
53
42
|
- spec/spec_helper.rb
|
54
|
-
has_rdoc: true
|
55
43
|
homepage: https://github.com/mechamogera/kronparser
|
56
44
|
licenses: []
|
57
|
-
|
58
45
|
post_install_message:
|
59
46
|
rdoc_options: []
|
60
|
-
|
61
|
-
require_paths:
|
47
|
+
require_paths:
|
62
48
|
- lib
|
63
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
segments_generated: true
|
78
|
-
version: "0"
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
79
61
|
requirements: []
|
80
|
-
|
81
62
|
rubyforge_project: kronparser
|
82
|
-
rubygems_version: 1.
|
63
|
+
rubygems_version: 1.8.10
|
83
64
|
signing_key:
|
84
65
|
specification_version: 3
|
85
66
|
summary: datermine next scheduled crontab run
|
86
|
-
test_files:
|
67
|
+
test_files:
|
87
68
|
- spec/kronparser_spec.rb
|
88
69
|
- spec/spec_helper.rb
|