error_merger 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f6a3809f25d08b76e1b6008ffa9a0213d7cc5a4
4
- data.tar.gz: 26204505d21f20d99be522de7c1288b1dc1820f5
3
+ metadata.gz: fdfba3e2cb6c55f351c7ee4b7b0c5883cce24812
4
+ data.tar.gz: f7b4196f44499e44d289eef42c838925f1ce98db
5
5
  SHA512:
6
- metadata.gz: 799aa0809e3434a3b174edff7e1e2092f6e132dd714767c8dab553dc5da75f0fd7dbae5e187b6aa498549520f2e33be8f78201bea5038887e8d50378a60cd4ec
7
- data.tar.gz: ad3a65b86614c8d9ce6699b8c51e9b3d309a6672b94e9808069c65b2abdb63799b3e5f4f6a2dc7e83e47f62017c9f3fa65888b56319f0bd0f1b6c8b0bd26b198
6
+ metadata.gz: 5d83cd3309db5412fbde975ac1efc1d0b86b098393511a08a5361b887c688c06b5fefa9c98be4b1b7272115050ae390fc1263c3b66845e38392839c33689c439
7
+ data.tar.gz: 4dc60344e5e03b4cedce1c328e34c3c11458f95ab89a30ecb709e37d5edc9dd5870f99c668eae2eb7b20480edbc3daea484d35294836eb10692a19ca450e8cec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 thomas morgan
1
+ Copyright (c) 2014 thomas morgan
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # ErrorMerger
2
2
 
3
- Adds a .merge method to ActiveModel-compliant models.
3
+ Adds a #merge method to ActiveModel-compliant models.
4
4
 
5
5
  Allows the merging/consolidation of errors on multiple models to make it easy
6
6
  to pass into some kind of error renderer.
7
7
 
8
+ Also adds #full_sentence and #full_sentences methods, with are comparable to
9
+ \#full_message and #full_messages respectively, except they ensure each error
10
+ message always ends with a period.
11
+
8
12
  ## Installation
9
13
 
10
14
  Add this line to your application's Gemfile:
@@ -19,14 +23,20 @@ Or install it yourself as:
19
23
 
20
24
  $ gem install error_merger
21
25
 
26
+
22
27
  ## Usage
23
28
 
24
29
  ```
25
30
  @user = User.new user_params
31
+ @user.valid? # => false
26
32
  @account = Account.new account_params
33
+ @account.valid? # => false
27
34
  @account.errors.merge @user
28
35
 
29
- @account.errors.to_sentence # => will include errors for both Account and User
36
+ @account.errors.full_messages # => will include errors for both Account and User
37
+
38
+ @user.errors.full_messages # => ["Username can't be blank"]
39
+ @user.errors.full_sentences # => ["Username can't be blank."]
30
40
  ```
31
41
 
32
42
  By default merged errors are prefixed with the model name. In the above example, an error on User might look like: "User: First name must not be blank".
data/error_merger.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = ErrorMerger::VERSION
9
9
  spec.authors = ['thomas morgan']
10
10
  spec.email = ['tm@iprog.com']
11
- spec.description = %q{Enables combining error messages on ActiveModel-compliant models.}
12
- spec.summary = %q{Enables combining error messages on ActiveModel-compliant models}
11
+ spec.description = %q{Enhances the Error class on ActiveModel-compliant models with merge() and full_sentences() methods.}
12
+ spec.summary = %q{Enhances the Error class on ActiveModel-compliant models}
13
13
  spec.homepage = 'https://github.com/zarqman/error_merger'
14
14
  spec.license = 'MIT'
15
15
 
@@ -1,4 +1,5 @@
1
1
  module ErrorMerger
2
+
2
3
  # merges an association's Errors set into the current set
3
4
  # eg: @user.errors.merge @account
4
5
  # @user.errors.merge @account, "Account ##{@account.id}: "
@@ -15,6 +16,15 @@ module ErrorMerger
15
16
  end
16
17
  end
17
18
 
19
+ def full_sentences
20
+ map{ |attr, m| full_sentence(attr, m) }
21
+ end
22
+
23
+ def full_sentence(attribute, message)
24
+ m = full_message(attribute, message)
25
+ m.ends_with?('.') ? m : "#{m}."
26
+ end
27
+
18
28
  end
19
29
 
20
30
  ActiveModel::Errors.send :include, ErrorMerger
@@ -1,3 +1,3 @@
1
1
  module ErrorMerger
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
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: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-14 00:00:00.000000000 Z
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -52,7 +52,8 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Enables combining error messages on ActiveModel-compliant models.
55
+ description: Enhances the Error class on ActiveModel-compliant models with merge()
56
+ and full_sentences() methods.
56
57
  email:
57
58
  - tm@iprog.com
58
59
  executables: []
@@ -91,5 +92,5 @@ rubyforge_project:
91
92
  rubygems_version: 2.0.6
92
93
  signing_key:
93
94
  specification_version: 4
94
- summary: Enables combining error messages on ActiveModel-compliant models
95
+ summary: Enhances the Error class on ActiveModel-compliant models
95
96
  test_files: []