say_when 0.4.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +13 -4
- data/Gemfile +1 -9
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +6 -6
- data/lib/generators/say_when/migration/migration_generator.rb +8 -5
- data/lib/generators/say_when/migration/templates/migration.rb +8 -7
- data/lib/say_when/base_job.rb +2 -0
- data/lib/say_when/cron_expression.rb +129 -191
- data/lib/say_when/processor/active_messaging.rb +7 -8
- data/lib/say_when/processor/base.rb +5 -3
- data/lib/say_when/processor/shoryuken.rb +14 -0
- data/lib/say_when/processor/simple.rb +2 -0
- data/lib/say_when/railtie.rb +9 -0
- data/lib/say_when/scheduler.rb +49 -90
- data/lib/say_when/storage/active_record/acts.rb +16 -16
- data/lib/say_when/storage/active_record/job.rb +17 -24
- data/lib/say_when/storage/active_record/job_execution.rb +5 -8
- data/lib/say_when/storage/memory/base.rb +3 -1
- data/lib/say_when/storage/memory/job.rb +14 -42
- data/lib/say_when/tasks.rb +4 -4
- data/lib/say_when/triggers/base.rb +4 -3
- data/lib/say_when/triggers/cron_strategy.rb +4 -3
- data/lib/say_when/triggers/instance_strategy.rb +4 -3
- data/lib/say_when/triggers/once_strategy.rb +3 -2
- data/lib/say_when/version.rb +3 -1
- data/lib/say_when.rb +8 -7
- data/lib/tasks/say_when.rake +3 -1
- data/say_when.gemspec +26 -19
- data/test/active_record_helper.rb +13 -0
- data/{spec → test}/db/schema.rb +4 -4
- data/{spec/spec_helper.rb → test/minitest_helper.rb} +9 -19
- data/test/say_when/cron_expression_spec.rb +74 -0
- data/{spec/say_when/processor/active_messaging_spec.rb → test/say_when/processor/active_messaging_test.rb} +17 -13
- data/test/say_when/scheduler_test.rb +75 -0
- data/test/say_when/storage/active_record/job_test.rb +90 -0
- data/test/say_when/storage/memory/job_test.rb +32 -0
- data/test/say_when/storage/memory/trigger_test.rb +54 -0
- data/test/say_when/triggers/once_strategy_test.rb +23 -0
- data/{spec → test}/support/models.rb +5 -3
- metadata +97 -54
- data/.travis.yml +0 -4
- data/generators/say_when_migration/say_when_migration_generator.rb +0 -11
- data/generators/say_when_migration/templates/migration.rb +0 -48
- data/spec/active_record_spec_helper.rb +0 -9
- data/spec/say_when/cron_expression_spec.rb +0 -72
- data/spec/say_when/scheduler_spec.rb +0 -126
- data/spec/say_when/storage/active_record/job_spec.rb +0 -97
- data/spec/say_when/storage/memory/job_spec.rb +0 -45
- data/spec/say_when/storage/memory/trigger_spec.rb +0 -54
- data/spec/say_when/triggers/once_strategy_spec.rb +0 -22
- data/spec/spec.opts +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5f6591f3f5206b517960a08efa500fbf3334ff56
|
4
|
+
data.tar.gz: 4daa2a598bf163817da9b7987938cc7216ed1f58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 236e345d76fb90f946e90a6d7ed8581bf670823b36965da9110e680f39847656c309e00ecc77d931e113a27648bc29bc37f72223f9a32c94f45a240c64fbff47
|
7
|
+
data.tar.gz: 3eb871a517e9e1c7246d7b52957b423c56fc58d47127f1523d2383a6f605314901684ad2a21c70bc3bd620964f6346403d3bf9e10ec70a79a9192a6cb55fda13
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in say_when.gemspec
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
gem "rspec", "=1.3.2", git: 'https://github.com/makandra/rspec.git', branch: '1-3-lts'
|
7
|
-
|
8
|
-
git 'https://github.com/makandra/rails.git', :branch => '2-3-lts' do
|
9
|
-
gem 'rails', '~>2.3.18'
|
10
|
-
gem 'activesupport', :require => false
|
11
|
-
gem 'railslts-version', :require => false
|
12
|
-
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Kuklewicz
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# SayWhen
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'say_when'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install say_when
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/say_when/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require '
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
t.
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
t.pattern = 'test/**/*_test.rb'
|
7
7
|
end
|
8
8
|
|
9
|
-
task :
|
9
|
+
task default: :test
|
@@ -1,18 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'rails/generators'
|
2
4
|
require 'rails/generators/migration'
|
3
|
-
require 'rails/generators/active_record
|
5
|
+
require 'rails/generators/active_record'
|
4
6
|
|
5
7
|
module SayWhen
|
6
|
-
class MigrationGenerator <
|
8
|
+
class MigrationGenerator < ActiveRecord::Generators::Base
|
7
9
|
|
8
10
|
include Rails::Generators::Migration
|
9
11
|
extend ActiveRecord::Generators::Migration
|
10
12
|
|
11
13
|
source_root File.expand_path('../templates', __FILE__)
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
argument :name, type: :string, default: 'random_name'
|
16
|
+
|
17
|
+
def manifest
|
18
|
+
migration_template 'migration.rb', 'db/migrate/create_say_when_tables.rb'
|
15
19
|
end
|
16
|
-
|
17
20
|
end
|
18
21
|
end
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
class CreateSayWhenTables < ActiveRecord::Migration
|
2
4
|
|
3
5
|
def self.up
|
4
6
|
|
5
7
|
create_table :say_when_jobs, :force => true do |t|
|
6
|
-
|
7
8
|
t.string :group
|
8
9
|
t.string :name
|
9
10
|
|
@@ -25,9 +26,12 @@ class CreateSayWhenTables < ActiveRecord::Migration
|
|
25
26
|
t.string :scheduled_type
|
26
27
|
t.integer :scheduled_id
|
27
28
|
|
28
|
-
t.timestamps
|
29
|
+
t.timestamps null: false
|
29
30
|
end
|
30
31
|
|
32
|
+
add_index :say_when_jobs, [:next_fire_at, :status]
|
33
|
+
add_index :say_when_jobs, [:scheduled_type, :scheduled_id]
|
34
|
+
|
31
35
|
create_table :say_when_job_executions, :force => true do |t|
|
32
36
|
t.integer :job_id
|
33
37
|
t.string :status
|
@@ -36,15 +40,12 @@ class CreateSayWhenTables < ActiveRecord::Migration
|
|
36
40
|
t.datetime :end_at
|
37
41
|
end
|
38
42
|
|
39
|
-
add_index :
|
40
|
-
add_index :
|
41
|
-
add_index :say_when_jobs, [:next_fire_at, :status]
|
42
|
-
add_index :say_when_jobs, [:last_fire_at, :status]
|
43
|
+
add_index :say_when_job_executions, :job_id
|
44
|
+
add_index :say_when_job_executions, [:status, :start_at, :end_at]
|
43
45
|
end
|
44
46
|
|
45
47
|
def self.down
|
46
48
|
drop_table :say_when_job_executions
|
47
49
|
drop_table :say_when_jobs
|
48
50
|
end
|
49
|
-
|
50
51
|
end
|