anachronic 0.43.0 → 0.44.0

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: 258ec036a2fdc3a3ef100b6e77b9db95f09b640138297cdefe8eb8120cb18bc7
4
- data.tar.gz: f71aa8121e0a373044026d82b3ea654c67f47816aaca3645a99df8cfcac6d941
3
+ metadata.gz: 1a9d5dc6fb44c62df056b23ee82749130f11331dc589918b4cbd0582274824d2
4
+ data.tar.gz: fcccffa0545173600919bd6888318a047db22c6d7d70175e6f01ae7b1e705a54
5
5
  SHA512:
6
- metadata.gz: 707d67121db58d16bfd44f504ebfd7d5ee234cab4824d1e42d71ede2cbe96649898c21404f8e21480e0d0a1a8f02a3415e214f2fffd03cde9b7ccd2ca1364e6f
7
- data.tar.gz: 461deb146099ef7e3f97b9369be8f66229bd3503acc9fc6391257decc123f7d14c9626bd4bef291529ec33403bd6d278934166b427625f3d1d365003fe041c32
6
+ metadata.gz: cffcf27a85768dcb4826d76df0850e3e7f6b363fb39f4182fadc414caecb7d17d5c550bd7c55249b5d4ec7387eeffdfd74923fbd211d868c35daae8e30d1d907
7
+ data.tar.gz: 0a94207e7181afadc8ee8fcec943678c493ca151dc22c426beed64ffde0266d35bb7175d483672bc17bcadee5e2f502318c86288e4fb2e9143750a2565ba7404
data/.gitignore CHANGED
@@ -6,6 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
9
+ *.gem
10
10
  # rspec failure tracking
11
11
  .rspec_status
data/Gemfile CHANGED
@@ -4,3 +4,9 @@ gemspec
4
4
 
5
5
  gem 'rake', '~> 12.0'
6
6
  gem 'rspec', '~> 3.0'
7
+
8
+ group :test do
9
+ gem 'rails', '~> 6.1'
10
+ gem 'resque', '~> 2.0'
11
+ gem 'sidekiq', '~> 6.0'
12
+ end
data/Gemfile.lock CHANGED
@@ -1,13 +1,140 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anachronic (0.43.0)
4
+ anachronic (0.44.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ actioncable (6.1.0)
10
+ actionpack (= 6.1.0)
11
+ activesupport (= 6.1.0)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.1.0)
15
+ actionpack (= 6.1.0)
16
+ activejob (= 6.1.0)
17
+ activerecord (= 6.1.0)
18
+ activestorage (= 6.1.0)
19
+ activesupport (= 6.1.0)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.1.0)
22
+ actionpack (= 6.1.0)
23
+ actionview (= 6.1.0)
24
+ activejob (= 6.1.0)
25
+ activesupport (= 6.1.0)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.1.0)
29
+ actionview (= 6.1.0)
30
+ activesupport (= 6.1.0)
31
+ rack (~> 2.0, >= 2.0.9)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.1.0)
36
+ actionpack (= 6.1.0)
37
+ activerecord (= 6.1.0)
38
+ activestorage (= 6.1.0)
39
+ activesupport (= 6.1.0)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.1.0)
42
+ activesupport (= 6.1.0)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.1.0)
48
+ activesupport (= 6.1.0)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.1.0)
51
+ activesupport (= 6.1.0)
52
+ activerecord (6.1.0)
53
+ activemodel (= 6.1.0)
54
+ activesupport (= 6.1.0)
55
+ activestorage (6.1.0)
56
+ actionpack (= 6.1.0)
57
+ activejob (= 6.1.0)
58
+ activerecord (= 6.1.0)
59
+ activesupport (= 6.1.0)
60
+ marcel (~> 0.3.1)
61
+ mimemagic (~> 0.3.2)
62
+ activesupport (6.1.0)
63
+ concurrent-ruby (~> 1.0, >= 1.0.2)
64
+ i18n (>= 1.6, < 2)
65
+ minitest (>= 5.1)
66
+ tzinfo (~> 2.0)
67
+ zeitwerk (~> 2.3)
68
+ builder (3.2.4)
69
+ concurrent-ruby (1.1.7)
70
+ connection_pool (2.2.3)
71
+ crass (1.0.6)
9
72
  diff-lcs (1.3)
73
+ erubi (1.10.0)
74
+ globalid (0.4.2)
75
+ activesupport (>= 4.2.0)
76
+ i18n (1.8.5)
77
+ concurrent-ruby (~> 1.0)
78
+ loofah (2.8.0)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.1)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (0.3.3)
84
+ mimemagic (~> 0.3.2)
85
+ method_source (1.0.0)
86
+ mimemagic (0.3.5)
87
+ mini_mime (1.0.2)
88
+ mini_portile2 (2.4.0)
89
+ minitest (5.14.2)
90
+ mono_logger (1.1.0)
91
+ multi_json (1.15.0)
92
+ mustermann (1.1.1)
93
+ ruby2_keywords (~> 0.0.1)
94
+ nio4r (2.5.4)
95
+ nokogiri (1.10.10)
96
+ mini_portile2 (~> 2.4.0)
97
+ rack (2.2.3)
98
+ rack-protection (2.1.0)
99
+ rack
100
+ rack-test (1.1.0)
101
+ rack (>= 1.0, < 3)
102
+ rails (6.1.0)
103
+ actioncable (= 6.1.0)
104
+ actionmailbox (= 6.1.0)
105
+ actionmailer (= 6.1.0)
106
+ actionpack (= 6.1.0)
107
+ actiontext (= 6.1.0)
108
+ actionview (= 6.1.0)
109
+ activejob (= 6.1.0)
110
+ activemodel (= 6.1.0)
111
+ activerecord (= 6.1.0)
112
+ activestorage (= 6.1.0)
113
+ activesupport (= 6.1.0)
114
+ bundler (>= 1.15.0)
115
+ railties (= 6.1.0)
116
+ sprockets-rails (>= 2.0.0)
117
+ rails-dom-testing (2.0.3)
118
+ activesupport (>= 4.2.0)
119
+ nokogiri (>= 1.6)
120
+ rails-html-sanitizer (1.3.0)
121
+ loofah (~> 2.3)
122
+ railties (6.1.0)
123
+ actionpack (= 6.1.0)
124
+ activesupport (= 6.1.0)
125
+ method_source
126
+ rake (>= 0.8.7)
127
+ thor (~> 1.0)
10
128
  rake (12.3.3)
129
+ redis (4.2.5)
130
+ redis-namespace (1.8.0)
131
+ redis (>= 3.0.4)
132
+ resque (2.0.0)
133
+ mono_logger (~> 1.0)
134
+ multi_json (~> 1.0)
135
+ redis-namespace (~> 1.6)
136
+ sinatra (>= 0.9.2)
137
+ vegas (~> 0.1.2)
11
138
  rspec (3.8.0)
12
139
  rspec-core (~> 3.8.0)
13
140
  rspec-expectations (~> 3.8.0)
@@ -21,14 +148,44 @@ GEM
21
148
  diff-lcs (>= 1.2.0, < 2.0)
22
149
  rspec-support (~> 3.8.0)
23
150
  rspec-support (3.8.0)
151
+ ruby2_keywords (0.0.2)
152
+ sidekiq (6.1.2)
153
+ connection_pool (>= 2.2.2)
154
+ rack (~> 2.0)
155
+ redis (>= 4.2.0)
156
+ sinatra (2.1.0)
157
+ mustermann (~> 1.0)
158
+ rack (~> 2.2)
159
+ rack-protection (= 2.1.0)
160
+ tilt (~> 2.0)
161
+ sprockets (4.0.2)
162
+ concurrent-ruby (~> 1.0)
163
+ rack (> 1, < 3)
164
+ sprockets-rails (3.2.2)
165
+ actionpack (>= 4.0)
166
+ activesupport (>= 4.0)
167
+ sprockets (>= 3.0.0)
168
+ thor (1.0.1)
169
+ tilt (2.0.10)
170
+ tzinfo (2.0.4)
171
+ concurrent-ruby (~> 1.0)
172
+ vegas (0.1.11)
173
+ rack (>= 1.0.0)
174
+ websocket-driver (0.7.3)
175
+ websocket-extensions (>= 0.1.0)
176
+ websocket-extensions (0.1.5)
177
+ zeitwerk (2.4.2)
24
178
 
25
179
  PLATFORMS
26
180
  ruby
27
181
 
28
182
  DEPENDENCIES
29
183
  anachronic!
184
+ rails (~> 6.1)
30
185
  rake (~> 12.0)
186
+ resque (~> 2.0)
31
187
  rspec (~> 3.0)
188
+ sidekiq (~> 6.0)
32
189
 
33
190
  BUNDLED WITH
34
- 2.1.4
191
+ 2.2.15
data/README.md CHANGED
@@ -61,8 +61,8 @@ end
61
61
  ```
62
62
 
63
63
  In case no `default_exeucutor` is configured, the gem will use the first one that is available (defined) from the list:
64
- - ApplicationJob
65
64
  - Sidekiq
65
+ - ApplicationJob
66
66
  - Resque
67
67
 
68
68
 
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './error.rb'
3
+ require 'anachronic/error'
4
+ require 'anachronic/executors/sidekiq'
5
+ require 'anachronic/executors/application_job'
6
+ require 'anachronic/executors/resque'
4
7
 
5
8
  module Anachronic
6
9
  # Class for deciding a background execution backend
@@ -16,18 +19,18 @@ module Anachronic
16
19
 
17
20
  def executor
18
21
  @executor ||= begin
19
- return Executors::ApplicationJob if default_or_defined?(ApplicationJob)
20
- return Executors::Sidekiq if default_or_defined?(Sidekiq)
21
- return Executors::Resque if default_or_defined?(Resque)
22
+ return Anachronic::Executors::Sidekiq if defined?('Sidekiq')
23
+ return Anachronic::Executors::ApplicationJob if defined?('ApplicationJob')
24
+ return Anachronic::Executors::Resque if defined?('Resque')
22
25
  end
23
26
  end
24
27
 
25
28
  def default_or_defined?(name)
26
- defined?(name) || config.default_executor == name
29
+ defined?(name.constantize) || config.default_executor.name == name
27
30
  end
28
31
 
29
32
  def no_executor
30
- raise Anachronic::Error('No background executor found')
33
+ raise Error('No background executor found')
31
34
  end
32
35
  end
33
36
  end
@@ -6,11 +6,13 @@ module Anachronic
6
6
  class ApplicationJob
7
7
  class << self
8
8
  def call(instance, method, *args)
9
- default_executor.perform_later(instance, method, *args)
9
+ executor.perform_later(instance, method, *args)
10
10
  end
11
11
 
12
- def default_executor
13
- @default_executor ||= begin
12
+ def executor
13
+ @executor ||= begin
14
+ return unless defined? Applicationjob
15
+
14
16
  Class.new(ApplicationJob) do
15
17
  def perform_later(instance, method, *args)
16
18
  instance.public_send(method, *args)
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anachronic
4
+ module Executors
5
+ # Default executor for Resque backend
6
+ class Resque
7
+ class << self
8
+ def call(instance, method, *args)
9
+ executor.perform(instance, method, *args)
10
+ end
11
+
12
+ def executor
13
+ @executor ||= begin
14
+ return unless defined? Resque
15
+
16
+ Class.new(Resque) do
17
+ def self.perform(instance, method, *args)
18
+ instance.public_send(method, *args)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anachronic
4
+ module Executors
5
+ # Default executor for Sidekiq backend
6
+ class Sidekiq
7
+ class << self
8
+ def call(instance, method, *args)
9
+ executor.perform_async(instance, method, *args)
10
+ end
11
+
12
+ def executor
13
+ @executor ||= begin
14
+ Class.new(Sidekiq) do
15
+ include ::Sidekiq::Worker
16
+
17
+ def perform_async(instance, method, *args)
18
+ instance.public_send(method, *args)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Anachronic
4
- VERSION = '0.43.0'
4
+ VERSION = '0.44.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anachronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danielius Visockas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-27 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Removing boilerplate from async code
14
14
  email:
@@ -35,6 +35,8 @@ files:
35
35
  - lib/anachronic/configuration.rb
36
36
  - lib/anachronic/error.rb
37
37
  - lib/anachronic/executors/application_job.rb
38
+ - lib/anachronic/executors/resque.rb
39
+ - lib/anachronic/executors/sidekiq.rb
38
40
  - lib/anachronic/override.rb
39
41
  - lib/anachronic/version.rb
40
42
  homepage: https://github.com/dvisockas/anachronic
@@ -60,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
62
  - !ruby/object:Gem::Version
61
63
  version: '0'
62
64
  requirements: []
63
- rubygems_version: 3.1.4
65
+ rubygems_version: 3.2.15
64
66
  signing_key:
65
67
  specification_version: 4
66
68
  summary: Moving your method execution to the world of asynchronity