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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87170e6fd3bc27364650b6f827e45f66f9d0d3c5396510db4818bb617db82c55
4
- data.tar.gz: fa46155a9ce06b76259446361a70c8551691307bc39f818ad45c8da8517cd9fb
3
+ metadata.gz: 04c86c83cf6f379820aa9192b42c5a957851a5ca7e115e98be6c958c53d02a37
4
+ data.tar.gz: 0c332e185ae4dfbf4a987785faa15c8c413abdbff132076d622b4f9009b0b5cb
5
5
  SHA512:
6
- metadata.gz: cb16d0e6e035dd9a178484caee3b2c4ad89f549190d97bc9df76288d1c47c2e8579c6dca8844f26286f08323c5d578d224bd809101b75996fc57e48a6a7d0dd2
7
- data.tar.gz: 244ec7c85feca9165e8293a09742a95d3003cafa85551fcabab2167d032f7d9ef7eaa81236fa2a8738e29b877e0bf8efd8353881b1f9ba559d96e42f7bb94290
6
+ metadata.gz: 8e773ba97e0b1f58f8583b1a27a21173b49e392c6c201526df2886ccf10b94fefdbefedad72634f5f8d591d6ab67ef1b949dd2e2e336f9719643cbaf93072997
7
+ data.tar.gz: d16c73f04d5753ce608c5114b0eb978df96b279ccecabc1c415269ebc53707a81dba3704a9405543837f80c142a486e2751b2c49bd525cac26ec9aefb864574c
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  .yardoc
6
6
  Gemfile.lock
7
+ Gemfile.*.lock
7
8
  InstalledFiles
8
9
  _yardoc
9
10
  coverage
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
@@ -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.1'
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'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activemodel', '~> 5.2.0'
4
+
5
+ # Specify your gem's dependencies in error_merger.gemspec
6
+ gemspec path: '..'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activemodel', '~> 6.0.0'
4
+
5
+ # Specify your gem's dependencies in error_merger.gemspec
6
+ gemspec path: '..'
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activemodel', '~> 6.1.0'
4
+
5
+ # Specify your gem's dependencies in error_merger.gemspec
6
+ gemspec path: '..'
@@ -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
- errors = assoc_or_errors.respond_to?(:errors) ? assoc_or_errors.errors : assoc_or_errors
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
- map{ |attr, m| full_sentence(attr, m) }
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)
@@ -1,3 +1,3 @@
1
1
  module ErrorMerger
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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.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: 2019-04-12 00:00:00.000000000 Z
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.1'
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.1'
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.2
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: