activejob-scheduler 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +90 -0
- data/Rakefile +5 -0
- data/activejob-scheduler.gemspec +28 -0
- data/bin/ajs +7 -0
- data/lib/active_job/scheduler.rb +7 -0
- data/lib/active_job/scheduler/cli.rb +113 -0
- data/lib/active_job/scheduler/job.rb +59 -0
- data/lib/active_job/scheduler/jobs.rb +32 -0
- data/lib/active_job/scheduler/task.rb +38 -0
- data/lib/active_job/scheduler/version.rb +5 -0
- data/spec/active_job/scheduler/job_spec.rb +44 -0
- data/spec/active_job/scheduler/jobs_spec.rb +24 -0
- data/spec/fixtures/jobs.yml +3 -0
- data/spec/spec_helper.rb +4 -0
- metadata +151 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d82e4890ae35e31690712e645bf35ed17563f411
|
|
4
|
+
data.tar.gz: 22080545aa6fd5a349d583f974e19674ddbadc3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 67873b9ceb54a39466f027030123de2e09d4015afb9ac9e6fbb3bfb89e89bff8b1926ae26f94e9b9a20aee55e44296166539c6740f8e2a96a2e27dd088c6f7a5
|
|
7
|
+
data.tar.gz: bbf7cb9b2dd1484d271e78ef6d8967c74cbc7194cc59d99853b84538c0c6517c124d197c5d1b8635a6395ffdc51250a4b328b17bdb1b47040abaa44549d07bd0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Tom Scott
|
|
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,90 @@
|
|
|
1
|
+
# ActiveJob::Scheduler
|
|
2
|
+
|
|
3
|
+
An extension to [ActiveJob][aj] for running background jobs
|
|
4
|
+
periodically, according to a schedule. Inspired by its predecessors,
|
|
5
|
+
[resque-scheduler][resque] and [sidekiq-scheduler][sidekiq],
|
|
6
|
+
`ActiveJob::Scheduler` hopes to bring the power of scheduled jobs into
|
|
7
|
+
everyone's hands, by way of the pre-defined ActiveJob API which most
|
|
8
|
+
popular queueing backend choices already support.
|
|
9
|
+
|
|
10
|
+
Like its predecessors, `ActiveJob::Scheduler` is built with
|
|
11
|
+
[Rufus::Scheduler][rufus], an immensely powerful task scheduling library
|
|
12
|
+
to make sure your jobs get kicked off at *exactly* the right time.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Add this line to your application's Gemfile:
|
|
17
|
+
|
|
18
|
+
gem 'activejob-scheduler'
|
|
19
|
+
|
|
20
|
+
And then execute:
|
|
21
|
+
|
|
22
|
+
$ bundle
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
Run the following command to generate a YAML-based schedule:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
$ rails generate activejob:schedule
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Edit this YAML file the same way you would with resque-scheduler or
|
|
33
|
+
sidekiq-scheduler (they define the same parameters). Then, it's your
|
|
34
|
+
choice as to how you wish to run it, either by the binary:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
$ bundle exec ajs
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or, with a Rake task:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
$ bundle exec rake activejob:schedule
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The schedule must run as a separate process, but it's very light...it
|
|
47
|
+
delegates all the real processing to your queue workers, and simply
|
|
48
|
+
enqueues jobs as the specified time rolls around.
|
|
49
|
+
|
|
50
|
+
## Development
|
|
51
|
+
|
|
52
|
+
Please use GitHub pull requests to contribute bug fixes or features, and
|
|
53
|
+
make sure to include tests with all your work.
|
|
54
|
+
|
|
55
|
+
### License
|
|
56
|
+
|
|
57
|
+
[University of Illinois/NCSA Open Source License][license]
|
|
58
|
+
|
|
59
|
+
Copyright (c) 2014 Tom Scott
|
|
60
|
+
All rights reserved.
|
|
61
|
+
|
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
63
|
+
a copy of this software and associated documentation files (the "Software"),
|
|
64
|
+
to deal with the Software without restriction, including without limitation
|
|
65
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
66
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
67
|
+
Software is furnished to do so, subject to the following conditions:
|
|
68
|
+
|
|
69
|
+
Redistributions of source code must retain the above copyright notice,
|
|
70
|
+
this list of conditions and the following disclaimers.
|
|
71
|
+
|
|
72
|
+
Redistributions in binary form must reproduce the above copyright notice,
|
|
73
|
+
this list of conditions and the following disclaimers in the documentation
|
|
74
|
+
and/or other materials provided with the distribution.
|
|
75
|
+
|
|
76
|
+
None of the names of its contributors may be used to endorse or promote
|
|
77
|
+
products derived from this Software without specific prior written permission.
|
|
78
|
+
|
|
79
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
80
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
81
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE
|
|
82
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
|
83
|
+
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
84
|
+
DEALINGS WITH THE SOFTWARE.
|
|
85
|
+
|
|
86
|
+
[aj]: https://github.com/rails/activejob
|
|
87
|
+
[resque]: https://github.com/resque/resque-scheduler
|
|
88
|
+
[sidekiq]: https://github.com/Moove-it/sidekiq-scheduler
|
|
89
|
+
[rufus]: https://github.com/jmettraux/rufus-scheduler
|
|
90
|
+
[license]: http://opensource.org/licenses/NCSA
|
data/Rakefile
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'active_job/scheduler/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "activejob-scheduler"
|
|
8
|
+
spec.version = ActiveJob::Scheduler::VERSION
|
|
9
|
+
spec.authors = ["Tom Scott"]
|
|
10
|
+
spec.email = ["tscott@telvue.com"]
|
|
11
|
+
spec.summary = %q{A scheduling apparatus for ActiveJob based on Rufus.}
|
|
12
|
+
spec.description = %q{A scheduling apparatus for ActiveJob based on Rufus. Resque::Scheduler for everyone!}
|
|
13
|
+
spec.homepage = "http://github.com/tubbo/activejob-scheduler"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
spec.add_development_dependency "rspec"
|
|
24
|
+
|
|
25
|
+
spec.add_dependency 'activejob'
|
|
26
|
+
spec.add_dependency 'rufus-scheduler'
|
|
27
|
+
spec.add_dependency 'activemodel'
|
|
28
|
+
end
|
data/bin/ajs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
|
|
3
|
+
module ActiveJob::Scheduler
|
|
4
|
+
# Controller for the schedule via the CLI.
|
|
5
|
+
class Cli
|
|
6
|
+
attr_reader :env, :options
|
|
7
|
+
|
|
8
|
+
# A short doc explaining the CLI.
|
|
9
|
+
USAGE = <<-EOF.gsub(/ {6}/, '')
|
|
10
|
+
Usage: activejob-scheduler [options]
|
|
11
|
+
|
|
12
|
+
Runs an active_job scheduler process directly (rather than via rake).
|
|
13
|
+
|
|
14
|
+
EOF
|
|
15
|
+
|
|
16
|
+
# The various options our CLI takes.
|
|
17
|
+
OPTIONS = [
|
|
18
|
+
{
|
|
19
|
+
args: ['-n', '--app-name [APP_NAME]',
|
|
20
|
+
'Application name for procline'],
|
|
21
|
+
callback: ->(options) { ->(n) { options[:app_name] = n } }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
args: ['-B', '--background', 'Run in the background [BACKGROUND]'],
|
|
25
|
+
callback: ->(options) { ->(b) { options[:background] = b } }
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
args: ['-D', '--dynamic-schedule',
|
|
29
|
+
'Enable dynamic scheduling [DYNAMIC_SCHEDULE]'],
|
|
30
|
+
callback: ->(options) { ->(d) { options[:dynamic] = d } }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
args: ['-E', '--environment [RAILS_ENV]', 'Environment name'],
|
|
34
|
+
callback: ->(options) { ->(e) { options[:env] = e } }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
args: ['-I', '--initializer-path [INITIALIZER_PATH]',
|
|
38
|
+
'Path to optional initializer ruby file'],
|
|
39
|
+
callback: ->(options) { ->(i) { options[:initializer_path] = i } }
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
args: ['-i', '--interval [RESQUE_SCHEDULER_INTERVAL]',
|
|
43
|
+
'Interval for checking if a scheduled job must run'],
|
|
44
|
+
callback: ->(options) { ->(i) { options[:poll_sleep_amount] = i } }
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
args: ['-l', '--logfile [LOGFILE]', 'Log file name'],
|
|
48
|
+
callback: ->(options) { ->(l) { options[:logfile] = l } }
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
args: ['-F', '--logformat [LOGFORMAT]', 'Log output format'],
|
|
52
|
+
callback: ->(options) { ->(f) { options[:logformat] = f } }
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
args: ['-P', '--pidfile [PIDFILE]', 'PID file name'],
|
|
56
|
+
callback: ->(options) { ->(p) { options[:pidfile] = p } }
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
args: ['-q', '--quiet', 'Run with minimal output [QUIET]'],
|
|
60
|
+
callback: ->(options) { ->(q) { options[:quiet] = q } }
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
args: ['-v', '--verbose', 'Run with verbose output [VERBOSE]'],
|
|
64
|
+
callback: ->(options) { ->(v) { options[:verbose] = v } }
|
|
65
|
+
}
|
|
66
|
+
].freeze
|
|
67
|
+
|
|
68
|
+
# Instantiate a new CLI handler with the given args.
|
|
69
|
+
def initialize(argv, env)
|
|
70
|
+
@env = env
|
|
71
|
+
@args = argv
|
|
72
|
+
@options = option_parser.parse! argv
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Start the scheduler CLI immediately from given command-line
|
|
76
|
+
# arguments.
|
|
77
|
+
def self.run(argv, env)
|
|
78
|
+
new(argv, env).run
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Now that we have args, actually begin running the schedule by
|
|
82
|
+
# loading each Job into Rufus::Scheduler. Rufus uses methods like
|
|
83
|
+
# `every` and `cron` to determine what kind of job you're pushing
|
|
84
|
+
# into it, so we use send() to give the Job object the power to make
|
|
85
|
+
# that choice.
|
|
86
|
+
def run
|
|
87
|
+
jobs.each do |job|
|
|
88
|
+
rufus.send job.interval, *job.rufus_params
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
rufus.start
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
private
|
|
95
|
+
def option_parser
|
|
96
|
+
OptionParser.new do |parser|
|
|
97
|
+
parser.banner = USAGE
|
|
98
|
+
|
|
99
|
+
OPTIONS.each do |opt|
|
|
100
|
+
parser.on(*opt[:args], &(opt[:callback].call(options)))
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def jobs
|
|
106
|
+
@jobs ||= Jobs.from_yaml
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def rufus
|
|
110
|
+
@rufus ||= Rufus::Scheduler.new
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'active_model'
|
|
2
|
+
|
|
3
|
+
module ActiveJob::Scheduler
|
|
4
|
+
# A model for use in the scheduler itself that wraps an existing
|
|
5
|
+
# ActiveJob::Base and enqueues it at some point. This is pretty much
|
|
6
|
+
# the holder for each stanza of YAML information as expressed in
|
|
7
|
+
# `config/jobs.yml`.
|
|
8
|
+
class Job
|
|
9
|
+
include ActiveModel::Model
|
|
10
|
+
|
|
11
|
+
# Attributes this object supports...
|
|
12
|
+
#
|
|
13
|
+
# - name: the name of the job in YAML
|
|
14
|
+
# - description: A short String description for shell docs
|
|
15
|
+
# - class: The class name of the job, by default derived from name.
|
|
16
|
+
# - interval: How we are describing the interval of passed time
|
|
17
|
+
# between runs (can be 'every', 'at', 'cron', or 'in')
|
|
18
|
+
#
|
|
19
|
+
# These are all specified in the YAML.
|
|
20
|
+
attr_accessor :name, :description, :job_class, :interval, :interval_value
|
|
21
|
+
attr_reader :attributes
|
|
22
|
+
|
|
23
|
+
# Interval types supported by the scheduler.
|
|
24
|
+
INTERVALS = %w(at in cron every)
|
|
25
|
+
|
|
26
|
+
validates :name, presence: true
|
|
27
|
+
validates :interval, presence: true
|
|
28
|
+
validates :interval_value, presence: true
|
|
29
|
+
|
|
30
|
+
# Set up and instantiate this Job object for use with the scheduler.
|
|
31
|
+
# Basically, this wraps the enqueued execution of an `ActiveJob::Base`.
|
|
32
|
+
def initialize(from_attrs={})
|
|
33
|
+
@interval, @interval_value = from_attrs.select { |attr, value|
|
|
34
|
+
INTERVALS.include? "#{attr}"
|
|
35
|
+
}.first.to_a.flatten
|
|
36
|
+
from_attrs.delete @interval
|
|
37
|
+
@attributes = from_attrs
|
|
38
|
+
super
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Description is the humanized name of the task by default.
|
|
42
|
+
def description
|
|
43
|
+
@description ||= name.titleize
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Enqueue this job with ActiveJob.
|
|
47
|
+
def enqueue
|
|
48
|
+
return false unless valid?
|
|
49
|
+
jobject.enqueue
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
def jobject
|
|
54
|
+
job_class.constantize
|
|
55
|
+
rescue StandardError
|
|
56
|
+
errors.add :job_class, "'#{job_class}' was not found"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module ActiveJob::Scheduler
|
|
4
|
+
class Jobs
|
|
5
|
+
include Enumerable
|
|
6
|
+
|
|
7
|
+
attr_reader :path
|
|
8
|
+
|
|
9
|
+
def initialize(from_path)
|
|
10
|
+
@path = from_path
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.from_yaml
|
|
14
|
+
new "config/jobs.yml"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def each
|
|
18
|
+
collection.each { |job| yield job }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
def collection
|
|
23
|
+
params.keys.map do |name|
|
|
24
|
+
Job.new params[name].merge name: name
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def params
|
|
29
|
+
@collection ||= YAML::load_file path
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'active_job/scheduler/cli'
|
|
2
|
+
require 'rake/tasklib'
|
|
3
|
+
|
|
4
|
+
module ActiveJob::Scheduler
|
|
5
|
+
# Run the scheduler as a Rake task, and preload the Rails environment.
|
|
6
|
+
#
|
|
7
|
+
# Example Task:
|
|
8
|
+
#
|
|
9
|
+
# ActiveJob::Scheduler::Task.new :schedule
|
|
10
|
+
#
|
|
11
|
+
# Example Shell Command:
|
|
12
|
+
#
|
|
13
|
+
# rake schedule
|
|
14
|
+
#
|
|
15
|
+
# The task can also be pre-loaded with a task called `schedule:setup`.
|
|
16
|
+
class Task < Rake::TaskLib
|
|
17
|
+
attr_reader :name
|
|
18
|
+
|
|
19
|
+
def initialize(with_name=:schedule)
|
|
20
|
+
@name = with_name
|
|
21
|
+
yield self if block_given?
|
|
22
|
+
define
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def define
|
|
26
|
+
namespace name do
|
|
27
|
+
task :setup
|
|
28
|
+
|
|
29
|
+
task :run do
|
|
30
|
+
ActiveJob::Scheduler::Cli.run ARGV, ENV
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
desc "Run the ActiveJob::Scheduler"
|
|
35
|
+
task name => ["#{name}:setup", "#{name}:run"]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'active_job/scheduler/job'
|
|
3
|
+
|
|
4
|
+
class Worker
|
|
5
|
+
def perform(record)
|
|
6
|
+
# do nothing
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module ActiveJob::Scheduler
|
|
11
|
+
describe Job do
|
|
12
|
+
subject do
|
|
13
|
+
Job.new \
|
|
14
|
+
name: 'testing',
|
|
15
|
+
every: '30s',
|
|
16
|
+
job_class: 'Worker'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
before do
|
|
20
|
+
allow(subject.send(:jobject)).to receive(:enqueue).and_return true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "finds the interval" do
|
|
24
|
+
expect(subject.interval).to eq(:every)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "finds the interval value" do
|
|
28
|
+
expect(subject.interval_value).to eq('30s')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "finds the job class name" do
|
|
32
|
+
expect(subject.job_class).to eq('Worker')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "it finds the description or gets one set" do
|
|
36
|
+
expect(subject.description).to eq('Testing')
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "enqueues the job with active_job" do
|
|
40
|
+
expect(subject).to be_valid
|
|
41
|
+
expect(subject.enqueue).to be_true
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'active_job/scheduler/jobs'
|
|
3
|
+
|
|
4
|
+
module ActiveJob::Scheduler
|
|
5
|
+
describe Jobs do
|
|
6
|
+
let :fixture_config do
|
|
7
|
+
File.expand_path('../../../fixtures/jobs.yml', __FILE__)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
subject { Jobs.new fixture_config }
|
|
11
|
+
|
|
12
|
+
it "reads from a yaml file on disk" do
|
|
13
|
+
expect(subject.path).to eq(fixture_config)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "defines jobs from each params stanza it sees" do
|
|
17
|
+
expect(subject.send(:collection).first).to be_a Job
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "iterates over the collection as an enumerable" do
|
|
21
|
+
expect(subject).to respond_to :each
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: activejob-scheduler
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Tom Scott
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ~>
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.5'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.5'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - '>='
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: activejob
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - '>='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rufus-scheduler
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - '>='
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - '>='
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: activemodel
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - '>='
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: A scheduling apparatus for ActiveJob based on Rufus. Resque::Scheduler
|
|
98
|
+
for everyone!
|
|
99
|
+
email:
|
|
100
|
+
- tscott@telvue.com
|
|
101
|
+
executables:
|
|
102
|
+
- ajs
|
|
103
|
+
extensions: []
|
|
104
|
+
extra_rdoc_files: []
|
|
105
|
+
files:
|
|
106
|
+
- .gitignore
|
|
107
|
+
- Gemfile
|
|
108
|
+
- LICENSE.txt
|
|
109
|
+
- README.md
|
|
110
|
+
- Rakefile
|
|
111
|
+
- activejob-scheduler.gemspec
|
|
112
|
+
- bin/ajs
|
|
113
|
+
- lib/active_job/scheduler.rb
|
|
114
|
+
- lib/active_job/scheduler/cli.rb
|
|
115
|
+
- lib/active_job/scheduler/job.rb
|
|
116
|
+
- lib/active_job/scheduler/jobs.rb
|
|
117
|
+
- lib/active_job/scheduler/task.rb
|
|
118
|
+
- lib/active_job/scheduler/version.rb
|
|
119
|
+
- spec/active_job/scheduler/job_spec.rb
|
|
120
|
+
- spec/active_job/scheduler/jobs_spec.rb
|
|
121
|
+
- spec/fixtures/jobs.yml
|
|
122
|
+
- spec/spec_helper.rb
|
|
123
|
+
homepage: http://github.com/tubbo/activejob-scheduler
|
|
124
|
+
licenses:
|
|
125
|
+
- MIT
|
|
126
|
+
metadata: {}
|
|
127
|
+
post_install_message:
|
|
128
|
+
rdoc_options: []
|
|
129
|
+
require_paths:
|
|
130
|
+
- lib
|
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - '>='
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: '0'
|
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - '>='
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
version: '0'
|
|
141
|
+
requirements: []
|
|
142
|
+
rubyforge_project:
|
|
143
|
+
rubygems_version: 2.0.3
|
|
144
|
+
signing_key:
|
|
145
|
+
specification_version: 4
|
|
146
|
+
summary: A scheduling apparatus for ActiveJob based on Rufus.
|
|
147
|
+
test_files:
|
|
148
|
+
- spec/active_job/scheduler/job_spec.rb
|
|
149
|
+
- spec/active_job/scheduler/jobs_spec.rb
|
|
150
|
+
- spec/fixtures/jobs.yml
|
|
151
|
+
- spec/spec_helper.rb
|