lev 9.0.3 → 10.1.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: 7956e474a01a96f138b7dd2e926d77ecd28df3f9f9d3da82f924714c08a60a5e
4
- data.tar.gz: f43d74f9eaf88f5bb13ad669cf1e9bc8583f9f4e70708878062cb9565596ec17
3
+ metadata.gz: fb4ccab91175edafaeff83e3bab8ab84e5a650ebc88b5000bf848ff1ad171d49
4
+ data.tar.gz: ce48c8cc00ed7edfa6076b5ba91ddbf11933f0a4b9f02e65dd6548ab69fc5b6c
5
5
  SHA512:
6
- metadata.gz: c2ab5a852630a17de13e57cc038a90409e3c472013eac10206c865938df076b5b19111a0a979aace04e4d4cdb7c134c1f91945fcecd862bbccea193d72ac4341
7
- data.tar.gz: fc864a9f83b3c3c7417f8b1e508fa5288ecdef4ce8cd66d5dae6cb21088db9bf41798c2836e8506893e618e2ede1803d0487ba5ac3b4f648b993e2f0d1646553
6
+ metadata.gz: 9dc7506db7fe12a5122596ea9f6cdf6682bc2f601f6b89d6dc26c49c1733e53a3d74ff0679430877deaf94c1009ab22a2bde64432cd8c946a5790237177c9f25
7
+ data.tar.gz: 53125d7cb41f17b27539b45802d4ec1dff132434c4d4dcdddc0294128c8a973a02f2bea2df8a852d986b5ecb4e46462af3d552198846a8c2f8caf10ab255d400
@@ -13,7 +13,7 @@ module Lev
13
13
  end
14
14
 
15
15
  def perform_later(*args, &block)
16
- Lev::ActiveJob::Base.new.perform_later(routine_class, options, *args, &block)
16
+ routine_class.job_class.new.perform_later(routine_class, options, *args, &block)
17
17
  end
18
18
  end
19
19
  end
@@ -1,7 +1,9 @@
1
1
  module Lev
2
2
  class FormBuilder < ActionView::Helpers::FormBuilder
3
3
 
4
- (field_helpers - %w(label check_box radio_button fields_for file_field)).each do |selector|
4
+ (
5
+ field_helpers.map(&:to_s) - %w(label check_box radio_button fields_for file_field)
6
+ ).each do |selector|
5
7
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
6
8
  def #{selector}(method, options = {}) # def text_field(method, options = {})
7
9
  set_value_if_available(method, options) # ... verbatim ...
@@ -26,11 +28,11 @@ module Lev
26
28
  def fields_for(record_name, record_object = nil, fields_options = {}, &block)
27
29
  raise "Didn't put fields_for into LevitateFormBuilder yet"
28
30
  end
29
-
31
+
30
32
  protected
31
33
 
32
34
  def get_form_params_entry(name)
33
- @options[:params].present? ?
35
+ @options[:params].present? ?
34
36
  (@options[:params][@object_name].present? ?
35
37
  @options[:params][@object_name][name] :
36
38
  nil) :
@@ -60,4 +62,4 @@ def lev_form_for(record_or_name_or_array, *args, &proc)
60
62
  options[:params] = params
61
63
  options[:errors] = handler_errors # @errors || (@handler_outcome ? @handler_outcome.errors : [])
62
64
  form_for(record_or_name_or_array, *(args << options.merge(:builder => Lev::FormBuilder)), &proc)
63
- end
65
+ end
data/lib/lev/object.rb CHANGED
@@ -8,6 +8,7 @@ class Object
8
8
  options[:transaction] ||= Lev::TransactionIsolation.mysql_default.symbol
9
9
  @transaction_isolation = Lev::TransactionIsolation.new(options[:transaction])
10
10
 
11
+ @job_class = options[:job_class]
11
12
  @active_job_enqueue_options = options[:active_job_enqueue_options]
12
13
 
13
14
  @raise_fatal_errors = options[:raise_fatal_errors]
data/lib/lev/routine.rb CHANGED
@@ -214,23 +214,26 @@ module Lev
214
214
  Lev::ActiveJob::ConfiguredJob.new(self, options)
215
215
  end
216
216
 
217
- def perform_later(*args, &block)
218
- # Delegate to a subclass of Lev::Routine::ActiveJob::Base
219
- Lev::ActiveJob::Base.new.perform_later(self, active_job_enqueue_options, *args, &block)
217
+ def job_class
218
+ @job_class || Lev::ActiveJob::Base
220
219
  end
221
220
 
222
221
  def active_job_enqueue_options
223
222
  @active_job_enqueue_options || { queue: :default }
224
223
  end
225
224
 
225
+ def perform_later(*args, &block)
226
+ # Delegate to a subclass of Lev::Routine::ActiveJob::Base
227
+ job_class.new.perform_later(self, active_job_enqueue_options, *args, &block)
228
+ end
229
+
226
230
  # Called at a routine's class level to foretell which other routines will
227
231
  # be used when this routine executes. Helpful for figuring out ahead of
228
232
  # time what kind of transaction isolation level should be used.
229
233
  def uses_routine(routine_class, options={})
230
234
  symbol = options[:as] || class_to_symbol(routine_class)
231
235
 
232
- raise Lev.configuration.illegal_argument_error, "Routine #{routine_class} has already been registered" \
233
- if nested_routines[symbol]
236
+ warn("Routine #{routine_class} has already been registered") if nested_routines[symbol]
234
237
 
235
238
  nested_routines[symbol] = {
236
239
  routine_class: routine_class,
@@ -377,8 +380,7 @@ module Lev
377
380
  input_mapper = new_term_mapper(options[:translations][:inputs]) ||
378
381
  new_term_mapper({ scope: symbol })
379
382
 
380
- output_mapper = new_term_mapper(options[:translations][:outputs]) ||
381
- new_term_mapper({ scope: symbol })
383
+ output_mapper = new_term_mapper(options[:translations][:outputs])
382
384
 
383
385
  #
384
386
  # Set up the ignored errors in the routine instance
@@ -397,7 +399,7 @@ module Lev
397
399
 
398
400
  run_result.outputs.transfer_to(outputs) do |name|
399
401
  output_mapper.map(name)
400
- end
402
+ end unless output_mapper.nil?
401
403
 
402
404
  options[:errors_are_fatal] = true if !options.has_key?(:errors_are_fatal)
403
405
  transfer_errors_from(run_result.errors, input_mapper, options[:errors_are_fatal])
@@ -458,8 +460,9 @@ module Lev
458
460
  end
459
461
 
460
462
  def result
461
- @result ||= Result.new(Outputs.new,
462
- Errors.new(status, topmost_runner.class.raise_fatal_errors?))
463
+ @result ||= Result.new(
464
+ Outputs.new, Errors.new(status, topmost_runner.class.raise_fatal_errors?)
465
+ )
463
466
  end
464
467
 
465
468
  def reset_result!
data/lib/lev/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lev
2
- VERSION = "9.0.3"
2
+ VERSION = '10.1.0'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe CreateSprocket do
4
-
3
+ RSpec.describe CreateSprocket do
4
+
5
5
  it "should transfer errors appropriately" do
6
6
  result = CreateSprocket.call(1,"42")
7
7
  errors = result.errors.collect { |error| error.translate }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Lev::Utilities do
3
+ RSpec.describe Lev::Utilities do
4
4
 
5
5
  it "should merge properly" do
6
6
  default_options = {
@@ -38,4 +38,4 @@ describe Lev::Utilities do
38
38
  expect(merged).to eq expected
39
39
  end
40
40
 
41
- end
41
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe DelegatingRoutine do
3
+ RSpec.describe DelegatingRoutine do
4
4
 
5
5
  it "should delegate" do
6
6
  result = DelegatingRoutine.call(1,8)
data/spec/outputs_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Lev::Outputs do
3
+ RSpec.describe Lev::Outputs do
4
4
 
5
5
  let(:outputs) { Lev::Outputs.new }
6
6
 
@@ -60,7 +60,7 @@ describe Lev::Outputs do
60
60
  :y
61
61
  end
62
62
 
63
- other_outputs.add(:y, 6)
63
+ other_outputs.add(:y, 6)
64
64
  expect(other_outputs.y).to eq [4,5,6]
65
65
  end
66
66
 
@@ -72,9 +72,9 @@ describe Lev::Outputs do
72
72
 
73
73
  outputs.transfer_to(other_outputs)
74
74
 
75
- other_outputs.add(:y, 6)
75
+ other_outputs.add(:y, 6)
76
76
  expect(other_outputs.x).to eq [4,5]
77
77
  expect(other_outputs.y).to eq 6
78
78
  end
79
79
 
80
- end
80
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ParamifyHandlerA do
3
+ RSpec.describe ParamifyHandlerA do
4
4
  it 'should error out on badly formatted params' do
5
5
  result = ParamifyHandlerA.handle(params: {terms: {type: 'blah'}})
6
6
  errors = result.errors.collect { |error| error.translate }
@@ -8,7 +8,7 @@ describe ParamifyHandlerA do
8
8
  end
9
9
  end
10
10
 
11
- describe ParamifyHandlerB do
11
+ RSpec.describe ParamifyHandlerB do
12
12
  it 'should error out on badly formatted ungrouped params' do
13
13
  result = ParamifyHandlerB.handle(params: {type: 'blah'})
14
14
  errors = result.errors.collect { |error| error.translate }
data/spec/routine_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Lev::Routine do
3
+ RSpec.describe Lev::Routine do
4
4
 
5
5
  before do
6
6
  stub_const 'RaiseRuntimeError', Class.new
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SprocketHandler do
3
+ RSpec.describe SprocketHandler do
4
4
  it 'should return fatal error messages' do
5
5
  allow_any_instance_of(SprocketHandler).to(
6
6
  receive(:params).and_return({
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper.rb'
2
2
 
3
- describe Sprocket do
3
+ RSpec.describe Sprocket do
4
4
 
5
5
  it "should not be valid with bad inputs" do
6
6
  sprocket = Sprocket.new(integer_gt_2: 1, text_only_letters: 'abcd4')
@@ -8,4 +8,4 @@ describe Sprocket do
8
8
  expect(sprocket.errors.count).to eq 2
9
9
  end
10
10
 
11
- end
11
+ end
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: 9.0.3
4
+ version: 10.1.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: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2020-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -178,20 +178,6 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: byebug
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: jobba
197
183
  requirement: !ruby/object:Gem::Requirement
@@ -206,20 +192,6 @@ dependencies:
206
192
  - - ">="
207
193
  - !ruby/object:Gem::Version
208
194
  version: '1.5'
209
- - !ruby/object:Gem::Dependency
210
- name: rails
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: '0'
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - ">="
221
- - !ruby/object:Gem::Version
222
- version: '0'
223
195
  description: Ride the rails but don't touch them.
224
196
  email:
225
197
  - jps@kindlinglabs.com
@@ -298,23 +270,23 @@ signing_key:
298
270
  specification_version: 4
299
271
  summary: Ride the rails but don't touch them.
300
272
  test_files:
301
- - spec/spec_helper.rb
273
+ - spec/active_job_routines_spec.rb
302
274
  - spec/paramify_handler_spec.rb
303
- - spec/sprocket_handler_spec.rb
275
+ - spec/spec_helper.rb
276
+ - spec/sprocket_spec.rb
304
277
  - spec/create_sprocket_spec.rb
305
- - spec/delegates_to_spec.rb
306
- - spec/better_active_model_errors_spec.rb
307
- - spec/transaction_spec.rb
278
+ - spec/outputs_spec.rb
308
279
  - spec/deep_merge_spec.rb
309
- - spec/support/paramify_handler_b.rb
280
+ - spec/sprocket_handler_spec.rb
281
+ - spec/statused_routines_spec.rb
282
+ - spec/better_active_model_errors_spec.rb
283
+ - spec/routine_spec.rb
310
284
  - spec/support/sprocket_handler.rb
311
- - spec/support/paramify_handler_a.rb
312
- - spec/support/delegating_routine.rb
313
285
  - spec/support/create_sprocket.rb
314
286
  - spec/support/delegated_routine.rb
315
287
  - spec/support/sprocket.rb
316
- - spec/sprocket_spec.rb
317
- - spec/outputs_spec.rb
318
- - spec/routine_spec.rb
319
- - spec/active_job_routines_spec.rb
320
- - spec/statused_routines_spec.rb
288
+ - spec/support/paramify_handler_a.rb
289
+ - spec/support/paramify_handler_b.rb
290
+ - spec/support/delegating_routine.rb
291
+ - spec/transaction_spec.rb
292
+ - spec/delegates_to_spec.rb