lev 9.0.1 → 10.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/lev/active_job/configured_job.rb +1 -1
- data/lib/lev/better_active_model_errors.rb +8 -0
- data/lib/lev/form_builder.rb +6 -4
- data/lib/lev/object.rb +1 -0
- data/lib/lev/routine.rb +15 -13
- data/lib/lev/version.rb +1 -1
- data/spec/better_active_model_errors_spec.rb +13 -2
- 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 +13 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
|
@@ -83,6 +83,14 @@ module Lev
|
|
83
83
|
@messages = ActiveSupport::OrderedHash.new
|
84
84
|
end
|
85
85
|
|
86
|
+
# copy & details are needed to match `ActiveModel::Errors` interface
|
87
|
+
def copy!(other)
|
88
|
+
initialize_dup(other)
|
89
|
+
end
|
90
|
+
def details
|
91
|
+
{}
|
92
|
+
end
|
93
|
+
|
86
94
|
def initialize_dup(other)
|
87
95
|
@types = other.types.dup
|
88
96
|
@messages = other.messages.dup
|
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,
|
@@ -298,12 +301,11 @@ module Lev
|
|
298
301
|
block.call
|
299
302
|
end
|
300
303
|
rescue Exception => e
|
301
|
-
# Let exceptions escape but make sure to note the error in the status
|
302
|
-
# if not already done
|
304
|
+
# Let exceptions escape but make sure to note the error in the status if not already done
|
303
305
|
if !e.is_a?(Lev::FatalError)
|
304
306
|
error = Error.new(code: :exception,
|
305
307
|
message: e.message,
|
306
|
-
data: e.backtrace
|
308
|
+
data: e.backtrace&.first)
|
307
309
|
status.add_error(error)
|
308
310
|
status.failed!
|
309
311
|
end
|
@@ -378,8 +380,7 @@ module Lev
|
|
378
380
|
input_mapper = new_term_mapper(options[:translations][:inputs]) ||
|
379
381
|
new_term_mapper({ scope: symbol })
|
380
382
|
|
381
|
-
output_mapper = new_term_mapper(options[:translations][:outputs])
|
382
|
-
new_term_mapper({ scope: symbol })
|
383
|
+
output_mapper = new_term_mapper(options[:translations][:outputs])
|
383
384
|
|
384
385
|
#
|
385
386
|
# Set up the ignored errors in the routine instance
|
@@ -398,7 +399,7 @@ module Lev
|
|
398
399
|
|
399
400
|
run_result.outputs.transfer_to(outputs) do |name|
|
400
401
|
output_mapper.map(name)
|
401
|
-
end
|
402
|
+
end unless output_mapper.nil?
|
402
403
|
|
403
404
|
options[:errors_are_fatal] = true if !options.has_key?(:errors_are_fatal)
|
404
405
|
transfer_errors_from(run_result.errors, input_mapper, options[:errors_are_fatal])
|
@@ -459,8 +460,9 @@ module Lev
|
|
459
460
|
end
|
460
461
|
|
461
462
|
def result
|
462
|
-
@result ||= Result.new(
|
463
|
-
|
463
|
+
@result ||= Result.new(
|
464
|
+
Outputs.new, Errors.new(status, topmost_runner.class.raise_fatal_errors?)
|
465
|
+
)
|
464
466
|
end
|
465
467
|
|
466
468
|
def reset_result!
|
data/lib/lev/version.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe '
|
4
|
-
|
3
|
+
RSpec.describe 'BetterActiveModelErrors' do
|
5
4
|
class DummyModel
|
6
5
|
def self.human_attribute_name(attr, default='')
|
7
6
|
return attr.capitalize
|
@@ -22,4 +21,16 @@ RSpec.describe 'Better active model errors' do
|
|
22
21
|
expect(errors.include?('crash')).to be true
|
23
22
|
end
|
24
23
|
|
24
|
+
it 'duplicates when copy called' do
|
25
|
+
model = OpenStruct.new
|
26
|
+
|
27
|
+
error = Lev::BetterActiveModelErrors.new(model)
|
28
|
+
error.set(:code, 'error')
|
29
|
+
expect(error.get(:code)).to eq 'error'
|
30
|
+
|
31
|
+
other = Lev::BetterActiveModelErrors.new(model)
|
32
|
+
other.set(:code, 'warning')
|
33
|
+
error.copy!(other)
|
34
|
+
expect(error.get(:code)).to eq 'warning'
|
35
|
+
end
|
25
36
|
end
|
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
|
@@ -293,29 +265,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
265
|
- !ruby/object:Gem::Version
|
294
266
|
version: '0'
|
295
267
|
requirements: []
|
296
|
-
|
297
|
-
rubygems_version: 2.4.5.1
|
268
|
+
rubygems_version: 3.0.3
|
298
269
|
signing_key:
|
299
270
|
specification_version: 4
|
300
271
|
summary: Ride the rails but don't touch them.
|
301
272
|
test_files:
|
302
273
|
- spec/active_job_routines_spec.rb
|
303
|
-
- spec/better_active_model_errors_spec.rb
|
304
|
-
- spec/create_sprocket_spec.rb
|
305
|
-
- spec/deep_merge_spec.rb
|
306
|
-
- spec/delegates_to_spec.rb
|
307
|
-
- spec/outputs_spec.rb
|
308
274
|
- spec/paramify_handler_spec.rb
|
309
|
-
- spec/routine_spec.rb
|
310
275
|
- spec/spec_helper.rb
|
311
|
-
- spec/sprocket_handler_spec.rb
|
312
276
|
- spec/sprocket_spec.rb
|
277
|
+
- spec/create_sprocket_spec.rb
|
278
|
+
- spec/outputs_spec.rb
|
279
|
+
- spec/deep_merge_spec.rb
|
280
|
+
- spec/sprocket_handler_spec.rb
|
313
281
|
- spec/statused_routines_spec.rb
|
282
|
+
- spec/better_active_model_errors_spec.rb
|
283
|
+
- spec/routine_spec.rb
|
284
|
+
- spec/support/sprocket_handler.rb
|
314
285
|
- spec/support/create_sprocket.rb
|
315
286
|
- spec/support/delegated_routine.rb
|
316
|
-
- spec/support/
|
287
|
+
- spec/support/sprocket.rb
|
317
288
|
- spec/support/paramify_handler_a.rb
|
318
289
|
- spec/support/paramify_handler_b.rb
|
319
|
-
- spec/support/
|
320
|
-
- spec/support/sprocket_handler.rb
|
290
|
+
- spec/support/delegating_routine.rb
|
321
291
|
- spec/transaction_spec.rb
|
292
|
+
- spec/delegates_to_spec.rb
|