lev 8.1.0 → 9.0.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
  SHA1:
3
- metadata.gz: 10396668754e61bf873103c7b939507c6797ada7
4
- data.tar.gz: 4c3d23e16f566c7f8f10acc9c2c53f692ddda0b0
3
+ metadata.gz: 282065bb04397e2bd972a0fed407f6a459f99457
4
+ data.tar.gz: a3f906162864f35c4795c2dac565db236755f454
5
5
  SHA512:
6
- metadata.gz: d44e4de024146fdaae53a3524177d17968836337ba6db82abe53ddcc9a0ec939d89585d902232d410cc123d746a085ac5a144e68aaafb9a53463c405d0279856
7
- data.tar.gz: a24eefc3365c7181178b8bd04218335fd2d84f17087a01fd3d825c6b99e6c73e4acfa4c1e70e6cca6842db65fe1310c65608abc3a7a025574ccd5a72a950ba11
6
+ metadata.gz: 406b49f5cfc26b5b7af0a17415ecaa51ddea921496608571879292ea537b316d82c81225cfc8c9253cf22515b0a53e99674b73aee4116cf16001b91dad471e90
7
+ data.tar.gz: 9f95deafac942d65ae90b9c7ed6e543b42fb5a8749ee3a7760e49998f3881e4e8de1487aae9dd93703c26e8f36f2777b565bfe7c5efa9f38570e06b049751925
data/README.md CHANGED
@@ -449,9 +449,11 @@ Routine status objects also have query methods to check if a status is in a give
449
449
  For plain vanilla routines not run as an active job, the status calls are no-ops. When a routine is invoked with `perform_later`, the status object is created/found using two configuration options that must be set (if you care about the status):
450
450
 
451
451
  ```ruby
452
- Lev.configure do |config|
453
- config.create_status_proc = ->(*) { Jobba::Status.create! }
454
- config.find_status_proc = ->(id) { Jobba::Status.find!(id) }
452
+ class SomeRoutine
453
+ lev_routine use_jobba: true
454
+ # This is the same as:
455
+ # self.create_status_proc = ->(*) { Jobba::Status.create! }
456
+ # self.find_status_proc = ->(id) { Jobba::Status.find!(id) }
455
457
  end
456
458
  ```
457
459
 
data/lib/lev.rb CHANGED
@@ -31,14 +31,6 @@ require 'lev/null_status'
31
31
  module Lev
32
32
  class << self
33
33
 
34
- def create_status
35
- configuration.create_status_proc.call
36
- end
37
-
38
- def find_status(id)
39
- configuration.find_status_proc.call(id)
40
- end
41
-
42
34
  ###########################################################################
43
35
  #
44
36
  # Configuration machinery.
@@ -71,8 +63,6 @@ module Lev
71
63
  attr_accessor :security_transgression_error
72
64
  attr_accessor :illegal_argument_error
73
65
  attr_accessor :raise_fatal_errors
74
- attr_accessor :create_status_proc
75
- attr_accessor :find_status_proc
76
66
  attr_accessor :job_class
77
67
 
78
68
  def initialize
@@ -80,8 +70,6 @@ module Lev
80
70
  @security_transgression_error = Lev::SecurityTransgression
81
71
  @illegal_argument_error = Lev::IllegalArgument
82
72
  @raise_fatal_errors = false
83
- @create_status_proc = ->(*) { NullStatus.new }
84
- @find_status_proc = ->(*) { NullStatus.new }
85
73
  @job_class = ::ActiveJob::Base
86
74
  super
87
75
  end
@@ -89,3 +77,5 @@ module Lev
89
77
 
90
78
  end
91
79
  end
80
+
81
+ require "lev/active_job"
@@ -5,7 +5,7 @@ module Lev
5
5
 
6
6
  def perform_later(routine_class, options, *args, &block)
7
7
  # Create a new status object
8
- status = Lev::create_status
8
+ status = routine_class.create_status
9
9
 
10
10
  # Push the routine class name on to the arguments
11
11
  # so that we can run the correct routine in `perform`
@@ -40,7 +40,7 @@ module Lev
40
40
  id = args.pop
41
41
  routine_class = Kernel.const_get(args.pop)
42
42
 
43
- routine_instance = routine_class.new(Lev::find_status(id))
43
+ routine_instance = routine_class.new(routine_class.find_status(id))
44
44
 
45
45
  routine_instance.call(*args, &block)
46
46
  end
@@ -25,6 +25,11 @@ class Object
25
25
 
26
26
  # Set this after dealing with "delegates_to" in case it set a value
27
27
  @express_output ||= options[:express_output] || self.name.demodulize.underscore
28
+
29
+ if options[:use_jobba]
30
+ self.create_status_proc = ->(*) { Jobba::Status.create! }
31
+ self.find_status_proc = ->(id) { Jobba::Status.find!(id) }
32
+ end
28
33
  end
29
34
  end
30
35
 
@@ -182,8 +182,7 @@ module Lev
182
182
  module Routine
183
183
 
184
184
  class Result
185
- attr_reader :outputs
186
- attr_reader :errors
185
+ attr_reader :outputs, :errors
187
186
 
188
187
  def initialize(outputs, errors)
189
188
  @outputs = outputs
@@ -195,6 +194,9 @@ module Lev
195
194
 
196
195
  def self.included(base)
197
196
  base.extend(ClassMethods)
197
+ base.class_attribute :create_status_proc, :find_status_proc
198
+ base.create_status_proc = ->(*) { NullStatus.new }
199
+ base.find_status_proc = ->(*) { NullStatus.new }
198
200
  end
199
201
 
200
202
  module ClassMethods
@@ -262,6 +264,14 @@ module Lev
262
264
  def class_to_symbol(klass)
263
265
  klass.name.underscore.gsub('/','_').to_sym
264
266
  end
267
+
268
+ def create_status
269
+ create_status_proc.call
270
+ end
271
+
272
+ def find_status(id)
273
+ find_status_proc.call(id)
274
+ end
265
275
  end
266
276
 
267
277
  attr_reader :runner
@@ -1,3 +1,3 @@
1
1
  module Lev
2
- VERSION = "8.1.0"
2
+ VERSION = "9.0.0"
3
3
  end
@@ -2,11 +2,9 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe 'ActiveJob routines' do
4
4
 
5
- before { Lev::Jobba.use_jobba }
6
-
7
5
  context 'default configuration' do
8
6
  class LaterRoutine
9
- lev_routine active_job_enqueue_options: { queue: :something_else }
7
+ lev_routine active_job_enqueue_options: { queue: :something_else }, use_jobba: true
10
8
 
11
9
  protected
12
10
  def exec; end
@@ -44,7 +42,7 @@ RSpec.describe 'ActiveJob routines' do
44
42
  after { ::ActiveJob::Base.queue_adapter = :test }
45
43
 
46
44
  class ExceptionalRoutine
47
- lev_routine
45
+ lev_routine use_jobba: true
48
46
 
49
47
  protected
50
48
  def exec
@@ -7,6 +7,7 @@
7
7
  require 'bundler'
8
8
  Bundler.require('default')
9
9
  require 'active_job'
10
+ require 'jobba'
10
11
 
11
12
  ActiveJob::Base.queue_adapter = :test
12
13
  ActiveJob::Base.logger = ::Logger.new(nil)
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class StatusedRoutine
4
- lev_routine
4
+ lev_routine use_jobba: true
5
5
 
6
6
  protected
7
7
 
@@ -14,8 +14,6 @@ end
14
14
 
15
15
  RSpec.describe 'Statused Routines' do
16
16
 
17
- before { Lev::Jobba.use_jobba }
18
-
19
17
  let(:routine_class) { StatusedRoutine }
20
18
  let(:args) { ['some arg'] }
21
19
  let(:status_id) { routine_class.perform_later(*args) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lev
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-13 00:00:00.000000000 Z
11
+ date: 2018-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -268,7 +268,6 @@ files:
268
268
  - spec/support/create_sprocket.rb
269
269
  - spec/support/delegated_routine.rb
270
270
  - spec/support/delegating_routine.rb
271
- - spec/support/jobba.rb
272
271
  - spec/support/paramify_handler_a.rb
273
272
  - spec/support/paramify_handler_b.rb
274
273
  - spec/support/sprocket.rb
@@ -308,7 +307,6 @@ test_files:
308
307
  - spec/deep_merge_spec.rb
309
308
  - spec/support/paramify_handler_b.rb
310
309
  - spec/support/sprocket_handler.rb
311
- - spec/support/jobba.rb
312
310
  - spec/support/paramify_handler_a.rb
313
311
  - spec/support/delegating_routine.rb
314
312
  - spec/support/create_sprocket.rb
@@ -1,13 +0,0 @@
1
- require 'jobba'
2
-
3
- module Lev::Jobba
4
-
5
- def self.use_jobba
6
- Lev.configure do |config|
7
- config.create_status_proc = ->(*) { Jobba::Status.create! }
8
- config.find_status_proc = ->(id) { Jobba::Status.find!(id) }
9
- end
10
- true
11
- end
12
-
13
- end