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.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +13 -4
  3. data/Gemfile +1 -9
  4. data/LICENSE +21 -0
  5. data/README.md +31 -0
  6. data/Rakefile +6 -6
  7. data/lib/generators/say_when/migration/migration_generator.rb +8 -5
  8. data/lib/generators/say_when/migration/templates/migration.rb +8 -7
  9. data/lib/say_when/base_job.rb +2 -0
  10. data/lib/say_when/cron_expression.rb +129 -191
  11. data/lib/say_when/processor/active_messaging.rb +7 -8
  12. data/lib/say_when/processor/base.rb +5 -3
  13. data/lib/say_when/processor/shoryuken.rb +14 -0
  14. data/lib/say_when/processor/simple.rb +2 -0
  15. data/lib/say_when/railtie.rb +9 -0
  16. data/lib/say_when/scheduler.rb +49 -90
  17. data/lib/say_when/storage/active_record/acts.rb +16 -16
  18. data/lib/say_when/storage/active_record/job.rb +17 -24
  19. data/lib/say_when/storage/active_record/job_execution.rb +5 -8
  20. data/lib/say_when/storage/memory/base.rb +3 -1
  21. data/lib/say_when/storage/memory/job.rb +14 -42
  22. data/lib/say_when/tasks.rb +4 -4
  23. data/lib/say_when/triggers/base.rb +4 -3
  24. data/lib/say_when/triggers/cron_strategy.rb +4 -3
  25. data/lib/say_when/triggers/instance_strategy.rb +4 -3
  26. data/lib/say_when/triggers/once_strategy.rb +3 -2
  27. data/lib/say_when/version.rb +3 -1
  28. data/lib/say_when.rb +8 -7
  29. data/lib/tasks/say_when.rake +3 -1
  30. data/say_when.gemspec +26 -19
  31. data/test/active_record_helper.rb +13 -0
  32. data/{spec → test}/db/schema.rb +4 -4
  33. data/{spec/spec_helper.rb → test/minitest_helper.rb} +9 -19
  34. data/test/say_when/cron_expression_spec.rb +74 -0
  35. data/{spec/say_when/processor/active_messaging_spec.rb → test/say_when/processor/active_messaging_test.rb} +17 -13
  36. data/test/say_when/scheduler_test.rb +75 -0
  37. data/test/say_when/storage/active_record/job_test.rb +90 -0
  38. data/test/say_when/storage/memory/job_test.rb +32 -0
  39. data/test/say_when/storage/memory/trigger_test.rb +54 -0
  40. data/test/say_when/triggers/once_strategy_test.rb +23 -0
  41. data/{spec → test}/support/models.rb +5 -3
  42. metadata +97 -54
  43. data/.travis.yml +0 -4
  44. data/generators/say_when_migration/say_when_migration_generator.rb +0 -11
  45. data/generators/say_when_migration/templates/migration.rb +0 -48
  46. data/spec/active_record_spec_helper.rb +0 -9
  47. data/spec/say_when/cron_expression_spec.rb +0 -72
  48. data/spec/say_when/scheduler_spec.rb +0 -126
  49. data/spec/say_when/storage/active_record/job_spec.rb +0 -97
  50. data/spec/say_when/storage/memory/job_spec.rb +0 -45
  51. data/spec/say_when/storage/memory/trigger_spec.rb +0 -54
  52. data/spec/say_when/triggers/once_strategy_spec.rb +0 -22
  53. data/spec/spec.opts +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 39f0c8806fd8c11484d52818cb71a42e71e60b62c8cf19af670f8db7e06d3c17
4
- data.tar.gz: 2e22ba68d95307e93f019381399ed46b257d5170dc45f5d99fb06d8cb7832b48
2
+ SHA1:
3
+ metadata.gz: 5f6591f3f5206b517960a08efa500fbf3334ff56
4
+ data.tar.gz: 4daa2a598bf163817da9b7987938cc7216ed1f58
5
5
  SHA512:
6
- metadata.gz: 9c11c37dea5355c17ac03ebfd589d769cd5526d11d34864b7890185e89aae593dfa92e58616dfa0305686c8885ac6eaaa65f955bf03d479c49151abe2385286a
7
- data.tar.gz: 86790a64921d0f8cbbb92a11968bf036a76180c3d9fc40acec3cfd19a5e00e21c5a81f5e7029e3c23f0efbc8febc7bb8c2237f065b83e2788ac20f835e464c83
6
+ metadata.gz: 236e345d76fb90f946e90a6d7ed8581bf670823b36965da9110e680f39847656c309e00ecc77d931e113a27648bc29bc37f72223f9a32c94f45a240c64fbff47
7
+ data.tar.gz: 3eb871a517e9e1c7246d7b52957b423c56fc58d47127f1523d2383a6f605314901684ad2a21c70bc3bd620964f6346403d3bf9e10ec70a79a9192a6cb55fda13
data/.gitignore CHANGED
@@ -1,7 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
1
13
  *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
14
  *.DS_Store
6
- spec/db/test.db
7
15
  .ruby-version
16
+ test/db/test.db
data/Gemfile CHANGED
@@ -1,12 +1,4 @@
1
- source "http://rubygems.org"
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 "bundler/gem_tasks"
2
- require 'spec/rake/spectask'
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
- desc "Run all tests"
5
- Spec::Rake::SpecTask.new('test') do |t|
6
- t.spec_files = FileList['spec/**/*_spec.rb']
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.pattern = 'test/**/*_test.rb'
7
7
  end
8
8
 
9
- task :default => :test
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/migration'
5
+ require 'rails/generators/active_record'
4
6
 
5
7
  module SayWhen
6
- class MigrationGenerator < Rails::Generators::Base
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
- def manifest
14
- migration_template 'migration.rb', 'db/migrate/create_say_when_tables'
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 :say_when_jobs, :status
40
- add_index :say_when_jobs, :next_fire_at
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
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module SayWhen
2
4
  module BaseJob
3
5