sidekiq_adhoc_job 2.2.0 → 2.2.2

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: e0eb1cd817107c67f9c597017c3fd7e0fc8e79cd783b934d3b6ebc0fb69f5224
4
- data.tar.gz: deaae8c8f3de455976885dddd699fd29295cdcd0ae26a013bac38190d5d5e9a1
3
+ metadata.gz: 660ad86dfb526fe0eb9b473d1a86799c5f20d0f76934740e87365da5cb9bb287
4
+ data.tar.gz: 1237cc51e7ca8b2f52ca89e35969f153de5c97e72196c9134a6c1764e16c5565
5
5
  SHA512:
6
- metadata.gz: a5955dc23c535cfe30380fb24dabfecaa95dfb8b1bdb251d9def1ddc47bd263f0dda19cca2a2dcbaa45edcf2c974d2bebd2a2fdd371e10e19d263be757478261
7
- data.tar.gz: fdb6a47dc6c58d2054f6d6d21b6c10e67a9d38efe5bd76de5dca355df28125f569b6db1ddd4ca5c648faa948cfba2b8293541e1baa7685be6ec68b9984383843
6
+ metadata.gz: 3358428e19855f80d3f3b6ea468f10f4f634c3d15fd7d36e5843d1f2211af7d1dde8810e7b7e73799f6fecc47fb79532cc98f6aa9423837c752c8b9161a9b7a4
7
+ data.tar.gz: 87493129755ea165c769362b0723756155133cebcfbe53e8bfd597dfef572f23ba22313ab3946c62d347e505dcbf0d0c701f264210ab23e811c1be517a3a5f73
@@ -1,3 +1,3 @@
1
1
  module SidekiqAdhocJob
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.2'.freeze
3
3
  end
@@ -12,7 +12,8 @@ module SidekiqAdhocJob
12
12
  :required_kw_args,
13
13
  :optional_kw_args,
14
14
  :has_rest_args,
15
- :require_confirm
15
+ :require_confirm,
16
+ :confirm_prompt_message
16
17
 
17
18
  StringUtil ||= ::SidekiqAdhocJob::Utils::String
18
19
 
@@ -27,6 +28,7 @@ module SidekiqAdhocJob
27
28
  @optional_kw_args = args[:key] || []
28
29
  @has_rest_args = !!args[:rest]
29
30
  @require_confirm = require_confirm
31
+ @confirm_prompt_message = SidekiqAdhocJob.config.require_confirm_prompt_message
30
32
  end
31
33
 
32
34
  # Builds the presenter instances for the schedule hash
@@ -59,8 +59,14 @@
59
59
  <% if @presented_job.require_confirm %>
60
60
  <script>
61
61
  document.getElementById('adhoc-jobs-submit-form').addEventListener('submit', (event) => {
62
- if (!confirm('Are you sure?'))
62
+ const confirmPrompt = "<%= @presented_job.confirm_prompt_message %>";
63
+ const input = prompt(`Please enter "${confirmPrompt}" to confirm`);
64
+ if (input !== confirmPrompt) {
63
65
  event.preventDefault();
66
+ if (input !== null) {
67
+ alert('Your confirmation input is incorrect, try again.');
68
+ }
69
+ }
64
70
  })
65
71
  </script>
66
72
  <% end %>
@@ -46,22 +46,38 @@ module SidekiqAdhocJob
46
46
  :strategy_name,
47
47
  :require_confirm_worker_names
48
48
 
49
+ attr_reader :require_confirm_prompt_message
50
+
49
51
  def initialize
50
52
  @load_paths = []
51
53
  @module_names = []
52
54
  @strategy_name = :default
55
+ @require_confirm_prompt_message = 'confirm'
53
56
  end
54
57
 
55
58
  def module_names
56
59
  Array(@module_names).map(&:to_s)
57
60
  end
58
61
 
59
- def require_confirm
60
- @require_confirm ||= Array(@require_confirm_worker_names).map(&:to_s)
62
+ def require_confirm_proc
63
+ @require_confirm_proc ||= \
64
+ if @require_confirm_worker_names.respond_to?(:call)
65
+ @require_confirm_worker_names
66
+ else
67
+ shortlisted_workers = Array(@require_confirm_worker_names).map(&:to_s)
68
+
69
+ ->(worker_name) { shortlisted_workers.include?(worker_name) }
70
+ end
71
+ end
72
+
73
+ def require_confirm_prompt_message=(message)
74
+ raise 'require_confirm_prompt_message must be string' unless message.is_a? String
75
+
76
+ @require_confirm_prompt_message = message
61
77
  end
62
78
 
63
79
  def require_confirmation?(worker_name)
64
- require_confirm.include?(worker_name)
80
+ require_confirm_proc.call(worker_name)
65
81
  end
66
82
 
67
83
  def strategy
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_adhoc_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Goh Khoon Hiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-15 00:00:00.000000000 Z
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry