error_merger 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Rakefile +30 -0
- data/error_merger.gemspec +1 -1
- data/gemfiles/Gemfile.rails52 +6 -0
- data/gemfiles/Gemfile.rails60 +6 -0
- data/gemfiles/Gemfile.rails61 +6 -0
- data/lib/error_merger/error_merger.rb +13 -2
- data/lib/error_merger/version.rb +1 -1
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04c86c83cf6f379820aa9192b42c5a957851a5ca7e115e98be6c958c53d02a37
|
4
|
+
data.tar.gz: 0c332e185ae4dfbf4a987785faa15c8c413abdbff132076d622b4f9009b0b5cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e773ba97e0b1f58f8583b1a27a21173b49e392c6c201526df2886ccf10b94fefdbefedad72634f5f8d591d6ab67ef1b949dd2e2e336f9719643cbaf93072997
|
7
|
+
data.tar.gz: d16c73f04d5753ce608c5114b0eb978df96b279ccecabc1c415269ebc53707a81dba3704a9405543837f80c142a486e2751b2c49bd525cac26ec9aefb864574c
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -9,3 +9,33 @@ Rake::TestTask.new(:test) do |t|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
task default: :test
|
12
|
+
|
13
|
+
GEMFILES = {
|
14
|
+
'2.6@gem52' => 'Gemfile.rails52',
|
15
|
+
'2.6@gem60' => 'Gemfile.rails60',
|
16
|
+
'2.6@gem61' => 'Gemfile.rails61',
|
17
|
+
}
|
18
|
+
|
19
|
+
namespace :test do
|
20
|
+
task :install_all do
|
21
|
+
GEMFILES.each do |gemset, gemfile|
|
22
|
+
puts "\n\n========== Running 'bundle install' with #{gemfile} ==========\n"
|
23
|
+
puts `rvm #{gemset} --create do bundle install --gemfile=gemfiles/#{gemfile}`
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'test against all supported versions of rails'
|
28
|
+
task :all do
|
29
|
+
err = 0
|
30
|
+
cmd = ENV['RUN'] || 'rake test'
|
31
|
+
GEMFILES.each do |gemset, gemfile|
|
32
|
+
puts "\n\n========== Running '#{cmd}' with #{gemfile} ==========\n"
|
33
|
+
puts `rvm #{gemset} do bundle exec --gemfile=gemfiles/#{gemfile} #{cmd}`
|
34
|
+
err += 1 unless $?.success?
|
35
|
+
end
|
36
|
+
if err > 0
|
37
|
+
puts "\n>>> #{err} gemfiles failed"
|
38
|
+
exit err # exit code is # of failed runs
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/error_merger.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '>= 2.3'
|
22
22
|
|
23
|
-
spec.add_dependency 'activemodel', '>= 5', '< 6.
|
23
|
+
spec.add_dependency 'activemodel', '>= 5.2', '< 6.2'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
26
|
spec.add_development_dependency 'rake'
|
@@ -5,7 +5,11 @@ module ErrorMerger
|
|
5
5
|
# @user.errors.merge @account, "Account ##{@account.id}:"
|
6
6
|
# @user.errors.merge @account, attribute: :account
|
7
7
|
def merge(assoc_or_errors, prefix=nil, attribute: :base)
|
8
|
-
|
8
|
+
if assoc_or_errors.respond_to?(:errors) && assoc_or_errors.errors.is_a?(ActiveModel::Errors)
|
9
|
+
errors = assoc_or_errors.errors
|
10
|
+
else
|
11
|
+
errors = assoc_or_errors
|
12
|
+
end
|
9
13
|
|
10
14
|
if attribute == :base && prefix.nil? && errors.instance_variable_defined?(:@base)
|
11
15
|
prefix = "#{errors.instance_variable_get(:@base).class.model_name.human}: "
|
@@ -26,7 +30,14 @@ module ErrorMerger
|
|
26
30
|
end
|
27
31
|
|
28
32
|
def full_sentences
|
29
|
-
|
33
|
+
if defined?(ActiveModel::Error)
|
34
|
+
map do |error|
|
35
|
+
m = error.full_message
|
36
|
+
m.end_with?('.') ? m : "#{m}."
|
37
|
+
end
|
38
|
+
else
|
39
|
+
map{ |attr, m| full_sentence(attr, m) }
|
40
|
+
end
|
30
41
|
end
|
31
42
|
|
32
43
|
def full_sentence(attribute, message)
|
data/lib/error_merger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: error_merger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thomas morgan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5'
|
19
|
+
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '6.
|
22
|
+
version: '6.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '5'
|
29
|
+
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '6.
|
32
|
+
version: '6.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +72,9 @@ files:
|
|
72
72
|
- README.md
|
73
73
|
- Rakefile
|
74
74
|
- error_merger.gemspec
|
75
|
+
- gemfiles/Gemfile.rails52
|
76
|
+
- gemfiles/Gemfile.rails60
|
77
|
+
- gemfiles/Gemfile.rails61
|
75
78
|
- lib/error_merger.rb
|
76
79
|
- lib/error_merger/error_merger.rb
|
77
80
|
- lib/error_merger/version.rb
|
@@ -83,7 +86,7 @@ homepage: https://github.com/zarqman/error_merger
|
|
83
86
|
licenses:
|
84
87
|
- MIT
|
85
88
|
metadata: {}
|
86
|
-
post_install_message:
|
89
|
+
post_install_message:
|
87
90
|
rdoc_options: []
|
88
91
|
require_paths:
|
89
92
|
- lib
|
@@ -98,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
101
|
- !ruby/object:Gem::Version
|
99
102
|
version: '0'
|
100
103
|
requirements: []
|
101
|
-
rubygems_version: 3.0.
|
102
|
-
signing_key:
|
104
|
+
rubygems_version: 3.0.9
|
105
|
+
signing_key:
|
103
106
|
specification_version: 4
|
104
107
|
summary: Enhances the Error class on ActiveModel-compliant models
|
105
108
|
test_files:
|