crony 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/README.md +2 -0
- data/Rakefile +1 -1
- data/crony.gemspec +2 -4
- data/lib/crony/parser.rb +10 -10
- data/lib/crony/presenters/time_presenter.rb +3 -3
- data/lib/crony/version.rb +1 -1
- metadata +64 -83
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -13,6 +13,8 @@ Crony is a 'spell-checker' for cron expressions. Ask it to parse that cron
|
|
13
13
|
expression you just wrote, and it'll let you know if it's gonna do anything
|
14
14
|
close to what you meant it to.
|
15
15
|
|
16
|
+
[![Build Status](https://travis-ci.org/mikowitz/crony.png?branch=master)](https://travis-ci.org/mikowitz/crony)
|
17
|
+
|
16
18
|
See Usage below for examples.
|
17
19
|
|
18
20
|
## Installation
|
data/Rakefile
CHANGED
data/crony.gemspec
CHANGED
@@ -17,8 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_development_dependency
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency('guard-cucumber')
|
23
|
-
gem.add_development_dependency('rb-fsevent')
|
20
|
+
gem.add_development_dependency 'cucumber'
|
21
|
+
gem.add_development_dependency 'rake'
|
24
22
|
end
|
data/lib/crony/parser.rb
CHANGED
@@ -3,32 +3,32 @@ module Crony
|
|
3
3
|
def self.parse(element)
|
4
4
|
@element = element
|
5
5
|
case @element
|
6
|
-
when '*' then { every
|
7
|
-
when /^l$/i then { last
|
6
|
+
when '*' then { :every => true }
|
7
|
+
when /^l$/i then { :last => true }
|
8
8
|
when /(\d|\w{3})l$/i
|
9
9
|
@element = @element.sub(/l$/i, '')
|
10
|
-
{ last
|
10
|
+
{ :last => true, :collection => parse_collection }
|
11
11
|
when /.*#\d$/
|
12
12
|
@element, nth_week = @element.scan(/(.*)#(\d)$/)[0]
|
13
|
-
{ nth_week
|
13
|
+
{ :nth_week => nth_week, :collection => parse_collection }
|
14
14
|
when /\d+w$/i
|
15
15
|
@element = @element.sub(/w$/i, '')
|
16
|
-
{ nearest
|
16
|
+
{ :nearest => true, :collection => parse_collection }
|
17
17
|
when /\//
|
18
18
|
start, frequency = @element.scan(/(.*)\/(.*)/)[0]
|
19
19
|
case start
|
20
20
|
when '*'
|
21
|
-
{ frequency
|
21
|
+
{ :frequency => frequency }
|
22
22
|
when /^\d+$/ #single number
|
23
|
-
{ frequency
|
23
|
+
{ :frequency => frequency, :start => start }
|
24
24
|
when /^\d+-\d+$/
|
25
25
|
range_start, range_end = *start.scan(/(\d+)-(\d+)/)[0]
|
26
|
-
{ frequency
|
26
|
+
{ :frequency => frequency, :start => range_start, :stop => range_end }
|
27
27
|
end
|
28
28
|
when /^\d+-\d+$/
|
29
29
|
range_start, range_end = *@element.scan(/(\d+)-(\d+)/)[0]
|
30
|
-
{ start
|
31
|
-
else { collection
|
30
|
+
{ :start => range_start, :stop => range_end }
|
31
|
+
else { :collection => parse_collection }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -8,10 +8,10 @@ module Crony
|
|
8
8
|
when /[ev]e/ then minute.format
|
9
9
|
when 're' then "every hour from xx:#{minute.start.two_digits} to xx:#{minute.stop.two_digits}"
|
10
10
|
when 'ss' then "#{time(hour.single_element, minute.single_element)}"
|
11
|
-
when 'sc' then "#{hour.collection.map{|
|
11
|
+
when 'sc' then "#{hour.collection.map{|h| time(h, minute.single_element)}.to_sentence}"
|
12
12
|
when 'us' then "#{minute.format(false)} between #{time_range(hour.single_element, minute.start, hour.single_element, 59)}"
|
13
|
-
when 'uc' then "#{minute.format(false)} between #{hour.collection.map{|
|
14
|
-
when /c[cs]/ then "#{hour.collection.map{|
|
13
|
+
when 'uc' then "#{minute.format(false)} between #{hour.collection.map{|h| time_range(h, minute.start, h, 59)}.to_sentence}"
|
14
|
+
when /c[cs]/ then "#{hour.collection.map{|h| minute.collection.map{|m| time(h, m)}}.flatten.to_sentence}"
|
15
15
|
when /[ucsfr]r/ then ("%s of every hour between %s" % [minute.format, hour.format]).squeeze(' ')
|
16
16
|
when /^[fr][cs]$/ then "#{minute.format(hour.collection)}"
|
17
17
|
when /^.[rsc]$/ then ("%s between %s" % [minute.format, hour.format]).squeeze(' ')
|
data/lib/crony/version.rb
CHANGED
metadata
CHANGED
@@ -1,88 +1,62 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: crony
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Michael Berkowitz
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: guard
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
38
|
-
type: :development
|
17
|
+
|
18
|
+
date: 2013-02-07 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
39
21
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: guard-cucumber
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
22
|
+
name: cucumber
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
49
24
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
54
32
|
type: :development
|
33
|
+
requirement: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
55
35
|
prerelease: false
|
56
|
-
|
36
|
+
name: rake
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
57
38
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
70
46
|
type: :development
|
71
|
-
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
47
|
+
requirement: *id002
|
78
48
|
description: Spell-checker for cron expressions
|
79
|
-
email:
|
49
|
+
email:
|
80
50
|
- michael.berkowitz@gmail.com
|
81
51
|
executables: []
|
52
|
+
|
82
53
|
extensions: []
|
54
|
+
|
83
55
|
extra_rdoc_files: []
|
84
|
-
|
56
|
+
|
57
|
+
files:
|
85
58
|
- .gitignore
|
59
|
+
- .travis.yml
|
86
60
|
- Gemfile
|
87
61
|
- Guardfile
|
88
62
|
- LICENSE.txt
|
@@ -109,35 +83,42 @@ files:
|
|
109
83
|
- lib/crony/presenters/year_presenter.rb
|
110
84
|
- lib/crony/version.rb
|
111
85
|
- lib/utility_functions.rb
|
112
|
-
homepage:
|
86
|
+
homepage: ""
|
113
87
|
licenses: []
|
88
|
+
|
114
89
|
post_install_message:
|
115
90
|
rdoc_options: []
|
116
|
-
|
91
|
+
|
92
|
+
require_paths:
|
117
93
|
- lib
|
118
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
95
|
none: false
|
120
|
-
requirements:
|
121
|
-
- -
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
|
124
|
-
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
104
|
none: false
|
126
|
-
requirements:
|
127
|
-
- -
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
version: "0"
|
130
112
|
requirements: []
|
113
|
+
|
131
114
|
rubyforge_project:
|
132
|
-
rubygems_version: 1.8.
|
115
|
+
rubygems_version: 1.8.25
|
133
116
|
signing_key:
|
134
117
|
specification_version: 3
|
135
|
-
summary: Confirm that the cron expression you just wrote does what you meant it to
|
136
|
-
|
137
|
-
test_files:
|
118
|
+
summary: Confirm that the cron expression you just wrote does what you meant it to do.
|
119
|
+
test_files:
|
138
120
|
- features/date.feature
|
139
121
|
- features/rubycron.feature
|
140
122
|
- features/step_definitions/crony_steps.rb
|
141
123
|
- features/support/env.rb
|
142
124
|
- features/time.feature
|
143
|
-
has_rdoc:
|