sidekiq-tasks 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66094bc7c16bfcdf4a54af810f3cc6b277ec26f16c45644bd87d234fcf5108fa
4
- data.tar.gz: 5f7858178970a54368b222deabeb83221015bd2a7ff7d591d0368f4cda4366cb
3
+ metadata.gz: b815ea42b8cc57ba73f3711e735fda709755b75c282e200dc18ab5287eadfdd6
4
+ data.tar.gz: 3e3e652e28ae9ee632452e89bab64bf34db9d4961a6b1eb7e5ff05914cfca3e3
5
5
  SHA512:
6
- metadata.gz: 248e0b836f29e9145fd146907cb59c53d59d54ea3dcca8359368d93e9841d94108b418b7f2af23127f2ee5e9d4679c700ecab8a962b90d4fe7261d1178333912
7
- data.tar.gz: 0024c156a0b2c334dc7c1dbd0fc235a1a98e33ccb838f1f28a118c13644f9feb00b6693941137ad746cb7ad7c98b419d972dcb8a54a50320e9395f8c5b7f4ff7
6
+ metadata.gz: 53cb0abf54140641134acaf350bf51bf989f3b8d454359fe2b3f32a9ad1937d6257b06de3a000e602f3a63a217e475c4229c23712a88987731a27cab73485d29
7
+ data.tar.gz: 854ef40802df6e3d3cd6eda1eae39df3aff31efc8d1e82c69ae201b1ca3576060fcd9dd3bb71e7bfc6b1c8275f6db7169c61fcaabd84da18be121b3a9c0e55d6
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.1
2
+ TargetRubyVersion: 3.0
3
3
  NewCops: disable
4
4
  SuggestExtensions: false
5
5
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## Changelog
2
2
 
3
+ ### [0.1.3] - 2025-03-22
4
+
5
+ - Change required Ruby version to 3.0.0.
6
+ - Add `DisableWithComment` rule to disable a specific task with a magic comment.
7
+
3
8
  ### [0.1.2] - 2025-03-22
4
9
 
5
10
  - Update plugin registration for Sidekiq 7.3+ compatibility.
data/README.md CHANGED
@@ -56,10 +56,20 @@ task :my_task do
56
56
  end
57
57
  ```
58
58
 
59
+ You can also use `DisableWithComment` rule to selectively **exclude** tasks. (see [strategies configuration](#strategies-configuration))
60
+ It works similarly to `EnableWithComment`, but with inverted logic. Example of a disabled task:
61
+
62
+ ```ruby
63
+ # sidekiq-tasks:disable
64
+ task :my_task do
65
+ puts "my_task"
66
+ end
67
+ ```
68
+
59
69
  ## Strategies configuration
60
70
 
61
71
  Strategies can be configured through the `config.strategies` option.
62
- For example if you want to remove the `EnableWithComment` rule from the default strategy and enable all tasks from the `lib` folder:
72
+ For example if you want to enable all tasks in the lib folder and disable a few specific ones manually:
63
73
 
64
74
  ```ruby
65
75
  Sidekiq::Tasks.configure do |config|
@@ -67,6 +77,7 @@ Sidekiq::Tasks.configure do |config|
67
77
  Sidekiq::Tasks::Strategies::RakeTask.new(
68
78
  rules: [
69
79
  Sidekiq::Tasks::Strategies::Rules::TaskFromLib.new,
80
+ Sidekiq::Tasks::Strategies::Rules::DisableWithComment.new,
70
81
  ]
71
82
  )
72
83
  ]
@@ -0,0 +1,19 @@
1
+ module Sidekiq
2
+ module Tasks
3
+ module Strategies
4
+ module Rules
5
+ class DisableWithComment < EnableWithComment
6
+ def respected?(task)
7
+ !super
8
+ end
9
+
10
+ protected
11
+
12
+ def magic_comment_regex
13
+ /sidekiq-tasks:disable/
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,24 +3,28 @@ module Sidekiq
3
3
  module Strategies
4
4
  module Rules
5
5
  class EnableWithComment < Base
6
- MAGIC_COMMENT_REGEX = /sidekiq-tasks:enable/
7
-
8
6
  def respected?(task)
9
- file, start_line = task.locations.first.split(":")
10
- start_line_counting_desc = start_line.to_i > 2 ? start_line.to_i - 3 : 0
11
- lines = File.read(file).split("\n")[start_line_counting_desc..start_line_counting_desc + 1].reverse
7
+ lines = relevant_lines(task)
12
8
 
13
- valid_magic_comment_line?(lines)
14
- rescue Errno::ENOENT
15
- raise ArgumentError, "File '#{file}' not found"
9
+ return false if lines.first.match?(/namespace/)
10
+
11
+ lines.any? { |line| line.strip.match?(magic_comment_regex) }
16
12
  end
17
13
 
18
- private
14
+ protected
19
15
 
20
- def valid_magic_comment_line?(lines)
21
- return false if lines.first.match?(/namespace/)
16
+ def magic_comment_regex
17
+ /sidekiq-tasks:enable/
18
+ end
19
+
20
+ private
22
21
 
23
- lines.any? { |line| line.strip.match?(MAGIC_COMMENT_REGEX) }
22
+ def relevant_lines(task)
23
+ file, start_line = task.locations.first.split(":")
24
+ start_line_counting_desc = start_line.to_i > 2 ? start_line.to_i - 3 : 0
25
+ File.read(file).split("\n")[start_line_counting_desc..start_line_counting_desc + 1].reverse
26
+ rescue Errno::ENOENT
27
+ raise ArgumentError, "File '#{file}' not found"
24
28
  end
25
29
  end
26
30
  end
@@ -5,6 +5,7 @@ module Sidekiq
5
5
  autoload :Base, "sidekiq/tasks/strategies/rules/base"
6
6
  autoload :TaskFromLib, "sidekiq/tasks/strategies/rules/task_from_lib"
7
7
  autoload :EnableWithComment, "sidekiq/tasks/strategies/rules/enable_with_comment"
8
+ autoload :DisableWithComment, "sidekiq/tasks/strategies/rules/disable_with_comment"
8
9
  end
9
10
  end
10
11
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Tasks
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor
@@ -250,6 +250,7 @@ files:
250
250
  - lib/sidekiq/tasks/strategies/rake_task.rb
251
251
  - lib/sidekiq/tasks/strategies/rules.rb
252
252
  - lib/sidekiq/tasks/strategies/rules/base.rb
253
+ - lib/sidekiq/tasks/strategies/rules/disable_with_comment.rb
253
254
  - lib/sidekiq/tasks/strategies/rules/enable_with_comment.rb
254
255
  - lib/sidekiq/tasks/strategies/rules/task_from_lib.rb
255
256
  - lib/sidekiq/tasks/task.rb
@@ -293,7 +294,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
294
  requirements:
294
295
  - - ">="
295
296
  - !ruby/object:Gem::Version
296
- version: 3.1.0
297
+ version: '3.0'
297
298
  required_rubygems_version: !ruby/object:Gem::Requirement
298
299
  requirements:
299
300
  - - ">="