lev 7.0.2 → 7.0.3
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/better_active_model_errors.rb +8 -4
- data/lib/lev/error.rb +20 -0
- data/lib/lev/errors.rb +6 -2
- data/lib/lev/routine.rb +4 -4
- data/lib/lev/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39058e1cbfa410f404d73fa99f6cdb4fd101bdb6
|
4
|
+
data.tar.gz: 7b9f5c3e3366f9915f3c1bb16086c6b5c0c20a41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 388f7e4f202994665ddcc1881081526859d3e059738e2f60af3ebed416f4e4615a9d75bac3d588fd84780e9f331a60d0f8b2a4c4477b11eb1caebce301177af4
|
7
|
+
data.tar.gz: 756b6ee8991ee1b3e92912c496c1d766be58122b8c9efaefff90edcbab267c610b5453ebe837ab6b46d18130e66d15bcac984d30e760bb5d63e4f2e54b49ff11
|
@@ -244,6 +244,10 @@ module Lev
|
|
244
244
|
messages.dup
|
245
245
|
end
|
246
246
|
|
247
|
+
def to_s
|
248
|
+
inspect
|
249
|
+
end
|
250
|
+
|
247
251
|
# Adds +message+ to the error messages on +attribute+. More than one error can be added to the same
|
248
252
|
# +attribute+.
|
249
253
|
# If no +message+ is supplied, <tt>:invalid</tt> is assumed.
|
@@ -311,11 +315,11 @@ module Lev
|
|
311
315
|
def self.full_message(model, attribute, message)
|
312
316
|
return message if attribute == :base
|
313
317
|
attr_name = attribute.to_s.gsub('.', '_').humanize
|
314
|
-
attr_name = model.class.human_attribute_name(attribute, :
|
318
|
+
attr_name = model.class.human_attribute_name(attribute, default: attr_name)
|
315
319
|
I18n.t(:"errors.format", {
|
316
|
-
:
|
317
|
-
:
|
318
|
-
:
|
320
|
+
default: "%{attribute} %{message}",
|
321
|
+
attribute: attr_name,
|
322
|
+
message: message
|
319
323
|
})
|
320
324
|
end
|
321
325
|
|
data/lib/lev/error.rb
CHANGED
@@ -24,6 +24,26 @@ module Lev
|
|
24
24
|
ErrorTranslator.translate(self)
|
25
25
|
end
|
26
26
|
|
27
|
+
def to_s
|
28
|
+
inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
def full_message
|
32
|
+
attribute = data[:attribute] if data.present?
|
33
|
+
return message.humanize if attribute.nil?
|
34
|
+
|
35
|
+
attr_name = attribute.to_s.gsub('.', '_').humanize
|
36
|
+
|
37
|
+
model = data[:model]
|
38
|
+
attr_name = model.class.human_attribute_name(attribute, default: attr_name) if model.present?
|
39
|
+
|
40
|
+
I18n.t(:"errors.format", {
|
41
|
+
default: "%{attribute} %{message}",
|
42
|
+
attribute: attr_name,
|
43
|
+
message: message
|
44
|
+
})
|
45
|
+
end
|
46
|
+
|
27
47
|
end
|
28
48
|
|
29
49
|
end
|
data/lib/lev/errors.rb
CHANGED
@@ -50,10 +50,14 @@ module Lev
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def raise_exception_if_any!(exception_type = StandardError)
|
53
|
-
raise exception_type,
|
53
|
+
raise exception_type, map(&:message).join('; ') if any?
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
def full_messages
|
57
|
+
map(&:full_message)
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
57
61
|
|
58
62
|
attr_reader :routine_status
|
59
63
|
attr_reader :raise_fatal_errors
|
data/lib/lev/routine.rb
CHANGED
@@ -376,19 +376,19 @@ module Lev
|
|
376
376
|
end
|
377
377
|
|
378
378
|
#
|
379
|
-
# Attach the subroutine to self, call it, transfer
|
379
|
+
# Attach the subroutine to self, call it, transfer outputs and errors
|
380
380
|
#
|
381
381
|
|
382
382
|
other_routine.runner = self
|
383
383
|
run_result = other_routine.call(*args, &block)
|
384
384
|
|
385
|
-
options[:errors_are_fatal] = true if !options.has_key?(:errors_are_fatal)
|
386
|
-
transfer_errors_from(run_result.errors, input_mapper, options[:errors_are_fatal])
|
387
|
-
|
388
385
|
run_result.outputs.transfer_to(outputs) do |name|
|
389
386
|
output_mapper.map(name)
|
390
387
|
end
|
391
388
|
|
389
|
+
options[:errors_are_fatal] = true if !options.has_key?(:errors_are_fatal)
|
390
|
+
transfer_errors_from(run_result.errors, input_mapper, options[:errors_are_fatal])
|
391
|
+
|
392
392
|
run_result
|
393
393
|
end
|
394
394
|
|
data/lib/lev/version.rb
CHANGED
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: 7.0.
|
4
|
+
version: 7.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Slavinsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -292,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
292
292
|
version: '0'
|
293
293
|
requirements: []
|
294
294
|
rubyforge_project:
|
295
|
-
rubygems_version: 2.4.
|
295
|
+
rubygems_version: 2.4.8
|
296
296
|
signing_key:
|
297
297
|
specification_version: 4
|
298
298
|
summary: Ride the rails but don't touch them.
|