rufus-scheduler-cronline-occurrences 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +2 -0
- data/lib/rufus-scheduler-cronline-occurrences.rb +1 -0
- data/lib/rufus/scheduler/cronline/occurrences.rb +20 -0
- data/lib/rufus/scheduler/cronline/occurrences/version.rb +9 -0
- data/rufus-scheduler-cronline-occurrences.gemspec +26 -0
- data/spec/occurrences_spec.rb +50 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/version_spec.rb +7 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3c0ab9b20ac5d4a97643264045122507e32ebcd
|
4
|
+
data.tar.gz: 0d8019b614f53c229ad5f5102d9b2578b85f8e77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5b442cbf246234efe755ca45bea8828de83b6781e7c50acf7b01155b1c0267a6f68b1722c1429b2229f6ceb14ee6831e51d83e0b5319564d01fad8b3254c316
|
7
|
+
data.tar.gz: b2e5eda342525e41f397b746827098311d6f4bb608d51b86cbbbbf712ccf0a0fe728751c6e95055fa033577dd6bd38c560379eecd6051a57c9c0f6ced2ebd1c6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Keiichiro Nagano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Rufus::Scheduler::Cronline::Occurrences
|
2
|
+
|
3
|
+
This gem provides Rufus::Scheduler::Cronline#occurrences method which
|
4
|
+
returns potential trigger time within the [ time0, time1 ] span.
|
5
|
+
(time0 exclusive, time1 inclusive)
|
6
|
+
|
7
|
+
## Note
|
8
|
+
|
9
|
+
I tried to use Rufus::Scheduler#occurrences but it depends on machine time.
|
10
|
+
It returns nothing on past time.
|
11
|
+
This gem is machine-time independent.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'rufus-scheduler-cronline-occurrences'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install rufus-scheduler-cronline-occurrences
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
```
|
32
|
+
Rufus::Scheduler.parse('*/2 * * * * *').occurrences(Time.parse('2014-07-31 00:00:00 +0900'), Time.parse('2014-07-31 00:00:10 +0900'))
|
33
|
+
=> [2014-07-31 00:00:02 +0900,
|
34
|
+
2014-07-31 00:00:04 +0900,
|
35
|
+
2014-07-31 00:00:06 +0900,
|
36
|
+
2014-07-31 00:00:08 +0900,
|
37
|
+
2014-07-31 00:00:10 +0900]
|
38
|
+
```
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( https://github.com/knagano/rufus-scheduler-cronline-occurrences/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'rufus/scheduler/cronline/occurrences'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rufus/scheduler/cronline/occurrences/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rufus-scheduler-cronline-occurrences"
|
8
|
+
spec.version = Rufus::Scheduler::CronLine::Occurrences::VERSION
|
9
|
+
spec.authors = ["Keiichiro Nagano"]
|
10
|
+
spec.email = ["knagano@CPAN.org"]
|
11
|
+
spec.summary = %q{Rufus::Scheduler::CronLine#occurrences}
|
12
|
+
spec.description = %q{Rufus::Scheduler::CronLine#occurrences}
|
13
|
+
spec.homepage = "https://github.com/knagano/rufus-scheduler-cronline-occurrences"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'rufus-scheduler', "~> 3.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency 'rspec', '>= 2.13.0'
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Rufus::Scheduler' do
|
4
|
+
describe 'CronLine' do
|
5
|
+
describe '#occurrences' do
|
6
|
+
it 'normal case' do
|
7
|
+
occurrences = Rufus::Scheduler.parse('*/2 * * * * *')
|
8
|
+
.occurrences(Time.parse('2014-07-31 00:00:01 +0900'), Time.parse('2014-07-31 00:00:11 +0900'))
|
9
|
+
expect(occurrences.size).to eq 5
|
10
|
+
expect(occurrences[0]).to eq Time.parse('2014-07-31 00:00:02 +0900')
|
11
|
+
expect(occurrences[1]).to eq Time.parse('2014-07-31 00:00:04 +0900')
|
12
|
+
expect(occurrences[2]).to eq Time.parse('2014-07-31 00:00:06 +0900')
|
13
|
+
expect(occurrences[3]).to eq Time.parse('2014-07-31 00:00:08 +0900')
|
14
|
+
expect(occurrences[4]).to eq Time.parse('2014-07-31 00:00:10 +0900')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'first arg exclusive, second arg inclusive' do
|
18
|
+
occurrences = Rufus::Scheduler.parse('*/2 * * * * *')
|
19
|
+
.occurrences(Time.parse('2014-07-31 00:00:00 +0900'), Time.parse('2014-07-31 00:00:10 +0900'))
|
20
|
+
expect(occurrences.size).to eq 5
|
21
|
+
expect(occurrences[0]).to eq Time.parse('2014-07-31 00:00:02 +0900')
|
22
|
+
expect(occurrences[1]).to eq Time.parse('2014-07-31 00:00:04 +0900')
|
23
|
+
expect(occurrences[2]).to eq Time.parse('2014-07-31 00:00:06 +0900')
|
24
|
+
expect(occurrences[3]).to eq Time.parse('2014-07-31 00:00:08 +0900')
|
25
|
+
expect(occurrences[4]).to eq Time.parse('2014-07-31 00:00:10 +0900')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'zero occurrence' do
|
29
|
+
occurrences = Rufus::Scheduler.parse('*/2 * * * * *')
|
30
|
+
.occurrences(Time.parse('2014-07-31 00:00:00 +0900'), Time.parse('2014-07-31 00:00:01 +0900'))
|
31
|
+
expect(occurrences.size).to eq 0
|
32
|
+
expect(occurrences).to eq []
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'first arg and second one are same' do
|
36
|
+
occurrences = Rufus::Scheduler.parse('*/2 * * * * *')
|
37
|
+
.occurrences(Time.parse('2014-07-31 00:00:00 +0900'), Time.parse('2014-07-31 00:00:00 +0900'))
|
38
|
+
expect(occurrences.size).to eq 0
|
39
|
+
expect(occurrences).to eq []
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'second arg precedes first one' do
|
43
|
+
occurrences = Rufus::Scheduler.parse('*/2 * * * * *')
|
44
|
+
.occurrences(Time.parse('2014-07-31 00:00:10 +0900'), Time.parse('2014-07-31 00:00:00 +0900'))
|
45
|
+
expect(occurrences.size).to eq 0
|
46
|
+
expect(occurrences).to eq []
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rufus-scheduler-cronline-occurrences
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keiichiro Nagano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rufus-scheduler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.13.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.13.0
|
69
|
+
description: Rufus::Scheduler::CronLine#occurrences
|
70
|
+
email:
|
71
|
+
- knagano@CPAN.org
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/rufus-scheduler-cronline-occurrences.rb
|
82
|
+
- lib/rufus/scheduler/cronline/occurrences.rb
|
83
|
+
- lib/rufus/scheduler/cronline/occurrences/version.rb
|
84
|
+
- rufus-scheduler-cronline-occurrences.gemspec
|
85
|
+
- spec/occurrences_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- spec/version_spec.rb
|
88
|
+
homepage: https://github.com/knagano/rufus-scheduler-cronline-occurrences
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Rufus::Scheduler::CronLine#occurrences
|
112
|
+
test_files:
|
113
|
+
- spec/occurrences_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
- spec/version_spec.rb
|