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 +4 -4
- data/lib/lev/active_job/configured_job.rb +1 -1
- data/lib/lev/form_builder.rb +6 -4
- data/lib/lev/object.rb +1 -0
- data/lib/lev/routine.rb +13 -10
- data/lib/lev/version.rb +1 -1
- data/spec/create_sprocket_spec.rb +2 -2
- data/spec/deep_merge_spec.rb +2 -2
- data/spec/delegates_to_spec.rb +1 -1
- data/spec/outputs_spec.rb +4 -4
- data/spec/paramify_handler_spec.rb +2 -2
- data/spec/routine_spec.rb +1 -1
- data/spec/sprocket_handler_spec.rb +1 -1
- data/spec/sprocket_spec.rb +2 -2
- metadata +15 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb4ccab91175edafaeff83e3bab8ab84e5a650ebc88b5000bf848ff1ad171d49
|
4
|
+
data.tar.gz: ce48c8cc00ed7edfa6076b5ba91ddbf11933f0a4b9f02e65dd6548ab69fc5b6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc7506db7fe12a5122596ea9f6cdf6682bc2f601f6b89d6dc26c49c1733e53a3d74ff0679430877deaf94c1009ab22a2bde64432cd8c946a5790237177c9f25
|
7
|
+
data.tar.gz: 53125d7cb41f17b27539b45802d4ec1dff132434c4d4dcdddc0294128c8a973a02f2bea2df8a852d986b5ecb4e46462af3d552198846a8c2f8caf10ab255d400
|
data/lib/lev/form_builder.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module Lev
|
2
2
|
class FormBuilder < ActionView::Helpers::FormBuilder
|
3
3
|
|
4
|
-
(
|
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
|
218
|
-
|
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
|
-
|
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(
|
462
|
-
|
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
data/spec/deep_merge_spec.rb
CHANGED
data/spec/delegates_to_spec.rb
CHANGED
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
data/spec/sprocket_spec.rb
CHANGED
@@ -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:
|
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:
|
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/
|
273
|
+
- spec/active_job_routines_spec.rb
|
302
274
|
- spec/paramify_handler_spec.rb
|
303
|
-
- spec/
|
275
|
+
- spec/spec_helper.rb
|
276
|
+
- spec/sprocket_spec.rb
|
304
277
|
- spec/create_sprocket_spec.rb
|
305
|
-
- spec/
|
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/
|
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/
|
317
|
-
- spec/
|
318
|
-
- spec/
|
319
|
-
- spec/
|
320
|
-
- spec/
|
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
|