delayed_job_groups_plugin 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d1a906f965ab26f60407c3a5b10a9e1405b39e3c
4
- data.tar.gz: 7cf5b5a7b17135b3de0788de8da05b6852101fc3
2
+ SHA256:
3
+ metadata.gz: 8e0fcf7a3d3099755aad28122f38afb96cec8896576cb54b47c2b4f7adfd2b94
4
+ data.tar.gz: 5241cc7d7365f07179896559c1aae27df4bf1e8010a49b2e0a2323f752b9efe4
5
5
  SHA512:
6
- metadata.gz: ac0d877eeac021a5da0d2bf48185fa5507c35e89d8791fd0ccf6de52181cc961c3fde975eee83be4b8dacbb252743f566d35362072c779a59e71c4a515fb497e
7
- data.tar.gz: ded7fd3760219acbf979050767a58147c12c2f7aea7ba74523672ea41a21c413399ab64c416adeef7715047fda953aafdb0203cee7955d7e759d79248b7931dd
6
+ metadata.gz: a6e7381efe91a0aa89492a58f7820e71f3c6d6c35d1e5ddaf4dd777dd63d6707f5f268587569a7da1f57dcd404df859f9980e9bbae1acffbf54c76841f0af8f1
7
+ data.tar.gz: '029c2dd29ed387c254f869c58295c41b446bfb42f87948e5980047ab47c2f7571fe794b65e7f9aa4d73162771d61361e67d6495f7ba4e02e754da29be0ee611e'
data/.gitignore CHANGED
@@ -18,3 +18,4 @@ spec/reports
18
18
  test/tmp
19
19
  test/version_tmp
20
20
  tmp
21
+ *.gemfile.lock
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format progress
3
+ --require spec_helper
@@ -0,0 +1,8 @@
1
+ inherit_gem:
2
+ salsify_rubocop: conf/rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.3
6
+
7
+ Style/FrozenStringLiteralComment:
8
+ Enabled: true
@@ -1,34 +1,14 @@
1
1
  language: ruby
2
2
  sudo: false
3
- env:
4
- global:
5
- - JRUBY_OPTS="$JRUBY_OPTS --debug"
6
- matrix:
7
- - RAILS_VERSION="~> 3.2.22.5"
8
- - RAILS_VERSION="~> 4.0.13"
9
- - RAILS_VERSION="~> 4.1.16"
10
- - RAILS_VERSION="~> 4.2.9"
11
- - RAILS_VERSION="~> 5.0.6"
12
- - RAILS_VERSION="~> 5.1.3"
3
+ gemfile:
4
+ - gemfiles/rails_4.2.gemfile
5
+ - gemfiles/rails_5.0.gemfile
6
+ - gemfiles/rails_5.1.gemfile
7
+ - gemfiles/rails_5.2.gemfile
13
8
  rvm:
14
- - 2.1.10
15
- - 2.2.8
16
- - 2.3.5
17
- - 2.4.2
18
- - jruby-9.1.13.0
19
- matrix:
20
- exclude:
21
- - rvm: 2.1.10
22
- env: RAILS_VERSION="~> 5.0.6"
23
- - rvm: 2.4.2
24
- env: RAILS_VERSION="~> 3.2.22.5"
25
- - rvm: 2.4.2
26
- env: RAILS_VERSION="~> 4.0.13"
27
- - rvm: 2.4.2
28
- env: RAILS_VERSION="~> 4.1.16"
29
- - rvm: jruby-9.1.13.0
30
- env: RAILS_VERSION="~> 5.0.6"
31
- - rvm: 2.1.10
32
- env: RAILS_VERSION="~> 5.1.3"
33
- - rvm: jruby-9.1.13.0
34
- env: RAILS_VERSION="~> 5.1.3"
9
+ - 2.3.8
10
+ - 2.4.5
11
+ - 2.5.3
12
+ script:
13
+ - bundle exec rspec
14
+ - bundle exec rubocop
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails-4.2' do
4
+ gem 'activerecord', '4.2.10'
5
+ gem 'activesupport', '4.2.10'
6
+ end
7
+
8
+ appraise 'rails-5.0' do
9
+ gem 'activerecord', '5.0.7'
10
+ gem 'activesupport', '5.0.7'
11
+ end
12
+
13
+ appraise 'rails-5.1' do
14
+ gem 'activerecord', '5.1.6'
15
+ gem 'activesupport', '5.1.6'
16
+ end
17
+
18
+ appraise 'rails-5.2' do
19
+ gem 'activerecord', '5.2.1 '
20
+ gem 'activesupport', '5.2.1 '
21
+ end
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
- ### 0.3.0 (unreleased)
3
+ ### 0.4.1
4
+ * Bugfix for `on_completion_job` and `on_cancellation_job` YAML serialization
5
+
6
+ ### 0.4.0
7
+ * Drop support for Ruby 2.0, 2.1 and 2.2.
8
+ * Add support for Ruby 2.5.
9
+ * Drop support for Rails < 4.2.
10
+ * Add support for Rails 5.2
11
+
12
+ ### 0.3.0
4
13
  * Drop support for Ruby 1.9 and 2.0.
5
14
 
6
15
  ### 0.2.0
@@ -13,5 +22,5 @@
13
22
  ### 0.1.2
14
23
  * Add configuration option to allow failed jobs not to cancel a group.
15
24
 
16
- ### 0.1.1
25
+ ### 0.1.1
17
26
  * Update the run_at for all jobs in a JobGroup when it's unblocked.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -107,8 +107,8 @@ job_group = Delayed::JobGroups::JobGroup.create!(failure_cancels_group: false)
107
107
  ## Supported Platforms
108
108
 
109
109
  * Only the Delayed Job Active Record backend is supported.
110
- * Tested with Rails 3.2 and 4.0.
111
- * Tested with MRI 1.9.3, 2.0.0, 2.1.0 and JRuby in 1.9 mode.
110
+ * Tested with Rails 4.2 through 5.2.
111
+ * Tested with MRI 2.3 through 2.5.
112
112
 
113
113
  ## Contributing
114
114
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  Bundler::GemHelper.install_tasks
3
5
 
@@ -1,4 +1,6 @@
1
- # encoding: UTF-8
1
+
2
+ # frozen_string_literal: true
3
+
2
4
  lib = File.expand_path('../lib', __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'delayed/job_groups/version'
@@ -8,37 +10,32 @@ Gem::Specification.new do |spec|
8
10
  spec.version = Delayed::JobGroups::VERSION
9
11
  spec.authors = ['Joel Turkel', 'Randy Burkes']
10
12
  spec.email = ['jturkel@salsify.com', 'rlburkes@gmail.com']
11
- spec.description = %q{Aggregates Delayed::Job jobs into groups with group level management and lifecycle callbacks}
12
- spec.summary = %q{Delayed::Job job groups plugin}
13
+ spec.description = 'Aggregates Delayed::Job jobs into groups with group level management and lifecycle callbacks'
14
+ spec.summary = 'Delayed::Job job groups plugin'
13
15
  spec.homepage = 'https://github.com/salsify/delayed_job_groups_plugin'
14
16
  spec.license = 'MIT'
15
17
 
16
- spec.files = `git ls-files`.split($/)
18
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
19
  spec.test_files = Dir.glob('spec/**/*')
18
20
  spec.require_paths = ['lib']
19
21
 
20
- spec.required_ruby_version = '>= 2.1'
22
+ spec.required_ruby_version = '>= 2.3'
21
23
 
22
24
  spec.add_dependency 'delayed_job', '>= 4.1'
23
- spec.add_dependency 'delayed_job_active_record', '>= 0.4'
25
+ spec.add_dependency 'delayed_job_active_record', '>= 4.1'
24
26
 
25
27
  spec.post_install_message = 'See https://github.com/salsify/delayed_job_groups_plugin#installation for upgrade/installation notes.'
26
28
 
27
- spec.add_development_dependency 'activerecord', ENV.fetch('RAILS_VERSION', ['>= 3.2', '< 5.2'])
29
+ spec.add_development_dependency 'appraisal'
30
+ spec.add_dependency 'activerecord', '>= 4.2', '< 5.3'
28
31
  spec.add_development_dependency 'coveralls'
29
32
  spec.add_development_dependency 'database_cleaner', '>= 1.2'
30
- # rspec < 3.5 requires rake < 11.0
31
- spec.add_development_dependency 'rake', '< 11.0'
32
- spec.add_development_dependency 'rspec', '>= 2.14', '< 2.99'
33
- spec.add_development_dependency 'simplecov', '~> 0.7.1'
33
+ spec.add_development_dependency 'mime-types'
34
+ spec.add_development_dependency 'rake'
35
+ spec.add_development_dependency 'rspec', '~> 3'
36
+ spec.add_development_dependency 'rspec-its'
37
+ spec.add_development_dependency 'salsify_rubocop', '0.52.1.1'
38
+ spec.add_development_dependency 'simplecov'
39
+ spec.add_development_dependency 'sqlite3'
34
40
  spec.add_development_dependency 'timecop'
35
- spec.add_development_dependency 'mime-types', '~> 2'
36
-
37
- if RUBY_PLATFORM == 'java'
38
- spec.add_development_dependency 'jdbc-sqlite3'
39
- spec.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
40
- else
41
- spec.add_development_dependency 'sqlite3'
42
- end
43
-
44
41
  end
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "4.2.10"
6
+ gem "activesupport", "4.2.10"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "5.0.7"
6
+ gem "activesupport", "5.0.7"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "5.1.6"
6
+ gem "activesupport", "5.1.6"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "5.2.1 "
6
+ gem "activesupport", "5.2.1 "
7
+
8
+ gemspec path: "../"
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/version'
4
4
  require 'active_record/version'
@@ -8,7 +8,7 @@ module Delayed
8
8
  module Compatibility
9
9
 
10
10
  def self.mass_assignment_security_enabled?
11
- ::ActiveRecord::VERSION::MAJOR < 4 || defined?(::ActiveRecord::MassAssignmentSecurity)
11
+ defined?(::ActiveRecord::MassAssignmentSecurity)
12
12
  end
13
13
 
14
14
  end
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Delayed
4
4
  module JobGroups
@@ -1,4 +1,6 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'yaml_loader'
2
4
 
3
5
  module Delayed
4
6
  module JobGroups
@@ -11,29 +13,19 @@ module Delayed
11
13
  :on_cancellation_job_options, :failure_cancels_group
12
14
  end
13
15
 
14
- serialize :on_completion_job
16
+ serialize :on_completion_job, Delayed::JobGroups::YamlLoader
15
17
  serialize :on_completion_job_options, Hash
16
- serialize :on_cancellation_job
18
+ serialize :on_cancellation_job, Delayed::JobGroups::YamlLoader
17
19
  serialize :on_cancellation_job_options, Hash
18
20
 
19
21
  validates :queueing_complete, :blocked, :failure_cancels_group, inclusion: [true, false]
20
22
 
21
- if ActiveRecord::VERSION::MAJOR >= 4
22
- has_many :active_jobs, -> { where(failed_at: nil) }, class_name: '::Delayed::Job'
23
- else
24
- has_many :active_jobs, class_name: Job, conditions: {failed_at: nil}
25
- end
26
-
23
+ has_many :active_jobs, -> { where(failed_at: nil) }, class_name: '::Delayed::Job'
27
24
 
28
25
  # Only delete dependent jobs that are unlocked so we can determine if there are in-flight jobs
29
26
  # for canceled job groups
30
- if ActiveRecord::VERSION::MAJOR >= 4
31
- has_many :queued_jobs, -> { where(failed_at: nil, locked_by: nil) }, class_name: '::Delayed::Job',
32
- dependent: :delete_all
33
- else
34
- has_many :queued_jobs, class_name: Job, conditions: {failed_at: nil, locked_by: nil},
35
- dependent: :delete_all
36
- end
27
+ has_many :queued_jobs, -> { where(failed_at: nil, locked_by: nil) }, class_name: '::Delayed::Job',
28
+ dependent: :delete_all
37
29
 
38
30
  def mark_queueing_complete
39
31
  with_lock do
@@ -78,7 +70,7 @@ module Delayed
78
70
  end
79
71
  end
80
72
 
81
- def self.has_pending_jobs?(job_group_ids)
73
+ def self.has_pending_jobs?(job_group_ids) # rubocop:disable Naming/PredicateName
82
74
  job_group_ids = Array(job_group_ids)
83
75
  return false if job_group_ids.empty?
84
76
  Delayed::Job.where(job_group_id: job_group_ids, failed_at: nil).exists?
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'delayed_job'
4
4
  require 'set'
@@ -8,7 +8,7 @@ module Delayed
8
8
  class Plugin < Delayed::Plugin
9
9
 
10
10
  callbacks do |lifecycle|
11
- lifecycle.before(:error) do |worker, job|
11
+ lifecycle.before(:error) do |_worker, job|
12
12
  # If the job group has been cancelled then don't let the job be retried
13
13
  if job.in_job_group? && job_group_cancelled?(job.job_group_id)
14
14
  def job.max_attempts
@@ -17,7 +17,7 @@ module Delayed
17
17
  end
18
18
  end
19
19
 
20
- lifecycle.before(:failure) do |worker, job|
20
+ lifecycle.before(:failure) do |_worker, job|
21
21
  # If a job in the job group fails, then cancel the whole job group.
22
22
  # Need to check that the job group is present since another
23
23
  # job may have concurrently cancelled it.
@@ -26,7 +26,7 @@ module Delayed
26
26
  end
27
27
  end
28
28
 
29
- lifecycle.after(:perform) do |worker, job|
29
+ lifecycle.after(:perform) do |_worker, job|
30
30
  # Make sure we only check to see if the job group is complete
31
31
  # if the job succeeded
32
32
  if job.in_job_group? && job_completed?(job)
@@ -35,8 +35,6 @@ module Delayed
35
35
  end
36
36
  end
37
37
 
38
- private
39
-
40
38
  def self.job_group_cancelled?(job_group_id)
41
39
  !JobGroup.exists?(job_group_id)
42
40
  end
@@ -49,4 +47,3 @@ module Delayed
49
47
  end
50
48
  end
51
49
  end
52
-
@@ -1,7 +1,7 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Delayed
4
4
  module JobGroups
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.1'
6
6
  end
7
7
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Delayed
4
+ module JobGroups
5
+ module YamlLoader
6
+ def self.load(yaml)
7
+ return yaml unless yaml.is_a?(String) && /^---/.match(yaml)
8
+ YAML.load_dj(yaml)
9
+ end
10
+
11
+ def self.dump(object)
12
+ return if object.nil?
13
+ YAML.dump(object)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'active_support'
4
4
  require 'active_record'
@@ -8,6 +8,7 @@ require 'delayed/job_groups/compatibility'
8
8
  require 'delayed/job_groups/job_extensions'
9
9
  require 'delayed/job_groups/job_group'
10
10
  require 'delayed/job_groups/plugin'
11
+ require 'delayed/job_groups/yaml_loader'
11
12
  require 'delayed/job_groups/version'
12
13
 
13
14
  Delayed::Backend::ActiveRecord::Job.send(:include, Delayed::JobGroups::JobExtensions)
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'rails/generators'
4
4
  require 'rails/generators/migration'
@@ -8,7 +8,7 @@ module DelayedJobGroupsPlugin
8
8
  class InstallGenerator < Rails::Generators::Base
9
9
  include Rails::Generators::Migration
10
10
 
11
- self.source_paths << File.join(File.dirname(__FILE__), 'templates')
11
+ source_paths << File.join(File.dirname(__FILE__), 'templates')
12
12
 
13
13
  def create_migration_file
14
14
  migration_template('migration.rb', 'db/migrate/create_delayed_job_groups.rb')
@@ -1,4 +1,4 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  class CreateDelayedJobGroups < ActiveRecord::Migration
4
4
 
@@ -1,6 +1,6 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
2
 
3
- ActiveRecord::Schema.define(:version => 0) do
3
+ ActiveRecord::Schema.define(version: 0) do
4
4
 
5
5
  create_table(:delayed_jobs, force: true) do |t|
6
6
  t.integer :priority, default: 0