mandate-rails 0.1.0 → 0.3.0

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
2
  SHA256:
3
- metadata.gz: 555c90a9d4bb24a987ce7c525393d171291945e96469c26b10b6bc506ea83029
4
- data.tar.gz: 07f8b6e0c6d04e19a4ecc9b0e7997ed1c290af31204e229887092513c4a2ff54
3
+ metadata.gz: 1c5944085c2064c68507785aa26a9e05576522a8b9795df76027af984c689255
4
+ data.tar.gz: f36146618848433239b9c32890a4618f532e9908f1b11446b7dec896920817aa
5
5
  SHA512:
6
- metadata.gz: 2a69a1a821353a7da03b26d442e5e060719785c1098c221795e4d3bbd4996c382d9491800443a58dff40769531422c2f84b6ebd190d440521b3e5d1cdd1cce84
7
- data.tar.gz: 071f3b01a9d8f80e5ddb1a737f650bcf8259abfe395fb1c6bb075623a3e6cbc18b47d3ed690f3ddc8c4e583f5861f725ba3755b94c80b796e31870cfc4266f92
6
+ metadata.gz: 1e558be3adabd0ee0c2f5e286c1b9c149056d689d02bc4da80878730d294088a30471c5e25cce0650847e7c363497031e0a55152d4bb918ad5319a59b4a282f6
7
+ data.tar.gz: 64568ac4c34d30f141b381310b1db7ea2d96befd19761ce00bad1d0afe728db69724278994403092470af3055c5bfe086985b8f60a47206119bb7ac3da0ea387
@@ -0,0 +1,46 @@
1
+ require_relative "./mandate_job"
2
+
3
+ module Mandate
4
+ module ActiveJobQueuer
5
+ def self.extended(base)
6
+ class << base
7
+ def queue_as(queue)
8
+ @active_job_queue = queue
9
+ end
10
+
11
+ def active_job_queue
12
+ @active_job_queue || :default
13
+ end
14
+ end
15
+ end
16
+
17
+ def defer(*args, wait: nil, **kwargs)
18
+ # We need to convert the jobs to a hash before we serialize as there's no serialization
19
+ # format for a job. We do this here to avoid cluttering the codebase with this logic.
20
+ if (prereqs = kwargs.delete(:prereq_jobs))
21
+ prereqs.map! do |job|
22
+ {
23
+ job_id: job.provider_job_id,
24
+ queue_name: job.queue_name
25
+ }
26
+ end
27
+ kwargs[:prereq_jobs] = prereqs if prereqs.present?
28
+ end
29
+
30
+ MandateJob.set(
31
+ queue: active_job_queue,
32
+ wait:
33
+ ).perform_later(self.name, *args, **kwargs)
34
+ end
35
+ end
36
+
37
+ def self.included(base)
38
+ # Upstream
39
+ base.extend(Memoize)
40
+ base.extend(CallInjector)
41
+ base.extend(InitializerInjector)
42
+
43
+ # New
44
+ base.extend(ActiveJobQueuer)
45
+ end
46
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MandateRails
4
+ VERSION = "0.3.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ require "mandate"
2
+
3
+ module MandateRails
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
7
+
8
+ require_relative "./mandate-rails/railtie" if defined?(Rails::Railtie)
@@ -1,10 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/mandate/rails/version"
1
+ require_relative "lib/mandate-rails/version"
4
2
 
5
3
  Gem::Specification.new do |spec|
6
4
  spec.name = "mandate-rails"
7
- spec.version = Mandate::Rails::VERSION
5
+ spec.version = MandateRails::VERSION
8
6
  spec.authors = ["Jeremy Walker"]
9
7
  spec.email = ["jez.walker@gmail.com"]
10
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandate-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-01 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -21,13 +21,12 @@ files:
21
21
  - LICENSE.txt
22
22
  - README.md
23
23
  - Rakefile
24
- - lib/mandate/rails.rb
25
- - lib/mandate/rails/active_job_queuer.rb
26
- - lib/mandate/rails/mandate_job.rb
27
- - lib/mandate/rails/railtie.rb
28
- - lib/mandate/rails/version.rb
24
+ - lib/mandate-rails/active_job_queuer.rb
25
+ - lib/mandate-rails/mandate_job.rb
26
+ - lib/mandate-rails/railtie.rb
27
+ - lib/mandate-rails/version.rb
28
+ - lib/mandate_rails.rb
29
29
  - mandate-rails.gemspec
30
- - sig/mandate/rails.rbs
31
30
  homepage:
32
31
  licenses:
33
32
  - MIT
@@ -1,45 +0,0 @@
1
- require_relative "./mandate_job"
2
- module Mandate
3
- module ActiveJobQueuer
4
- def self.extended(base)
5
- class << base
6
- def queue_as(queue)
7
- @active_job_queue = queue
8
- end
9
-
10
- def active_job_queue
11
- @active_job_queue || :default
12
- end
13
- end
14
- end
15
-
16
- def defer(*args, wait: nil, **kwargs)
17
- # We need to convert the jobs to a hash before we serialize as there's no serialization
18
- # format for a job. We do this here to avoid cluttering the codebase with this logic.
19
- if (prereqs = kwargs.delete(:prereq_jobs))
20
- prereqs.map! do |job|
21
- {
22
- job_id: job.provider_job_id,
23
- queue_name: job.queue_name
24
- }
25
- end
26
- kwargs[:prereq_jobs] = prereqs if prereqs.present?
27
- end
28
-
29
- MandateJob.set(
30
- queue: active_job_queue,
31
- wait:
32
- ).perform_later(self.name, *args, **kwargs)
33
- end
34
- end
35
-
36
- def self.included(base)
37
- # Upstream
38
- base.extend(Memoize)
39
- base.extend(CallInjector)
40
- base.extend(InitializerInjector)
41
-
42
- # New
43
- base.extend(ActiveJobQueuer)
44
- end
45
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mandate
4
- module Rails
5
- VERSION = "0.1.0"
6
- end
7
- end
data/lib/mandate/rails.rb DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "mandate"
4
- require_relative "rails/version"
5
-
6
- module Mandate
7
- module Rails
8
- class Error < StandardError; end
9
- # Your code goes here...
10
- end
11
- end
12
-
13
- require_relative "./rails/railtie" if defined?(Rails::Railtie)
@@ -1,6 +0,0 @@
1
- module Mandate
2
- module Rails
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
- end
6
- end
File without changes