isbn_validation 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.md +2 -9
- data/lib/isbn_validation/version.rb +1 -1
- data/lib/isbn_validation.rb +6 -9
- metadata +3 -9
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ To use it, add it to your Gemfile:
|
|
15
15
|
|
16
16
|
gem 'isbn_validation'
|
17
17
|
|
18
|
-
The current version of isbn_validation only supports Rails 3
|
18
|
+
The current version of isbn_validation only supports Rails 3+. For Rails 2.x
|
19
19
|
support, please use v0.1.2.
|
20
20
|
|
21
21
|
## Example
|
@@ -26,11 +26,4 @@ support, please use v0.1.2.
|
|
26
26
|
validates :isbn13, :isbn_format => { :with => :isbn13 }
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
## Contributors
|
32
|
-
|
33
|
-
* Nick Plante
|
34
|
-
* Omer Jakobinsky - Rails 3.0 compatibility
|
35
|
-
|
36
|
-
Copyright © 2013 Nick Plante, released under the MIT license
|
29
|
+
Copyright © 2014 Nick Plante, released under the MIT license
|
data/lib/isbn_validation.rb
CHANGED
@@ -6,9 +6,9 @@ require "isbn_validation/version"
|
|
6
6
|
# but this behavior can be modified using configuration options (as shown below).
|
7
7
|
#
|
8
8
|
# class Book < ActiveRecord::Base
|
9
|
-
# validates :isbn, :
|
10
|
-
# #
|
11
|
-
# #
|
9
|
+
# validates :isbn, isbn_format: true
|
10
|
+
# # validates :isbn10, isbn_format: { with: :isbn10 }
|
11
|
+
# # validates :isbn13, isbn_format: { with: :isbn13 }
|
12
12
|
# end
|
13
13
|
#
|
14
14
|
# Configuration options:
|
@@ -28,10 +28,6 @@ module ValidationExtensions
|
|
28
28
|
ISBN10_REGEX = /^(?:\d[\ |-]?){9}[\d|X]$/i
|
29
29
|
ISBN13_REGEX = /^(?:\d[\ |-]?){13}$/i
|
30
30
|
|
31
|
-
def self.included(base)
|
32
|
-
base.extend(ClassMethods)
|
33
|
-
end
|
34
|
-
|
35
31
|
class IsbnFormatValidator < ActiveModel::EachValidator
|
36
32
|
def initialize(options)
|
37
33
|
options[:message] ||= "is not a valid ISBN code"
|
@@ -95,7 +91,7 @@ module ValidationExtensions
|
|
95
91
|
end
|
96
92
|
end
|
97
93
|
|
98
|
-
module
|
94
|
+
module HelperMethods
|
99
95
|
def validates_isbn(*attr_names)
|
100
96
|
validates_with IsbnFormatValidator, _merge_attributes(attr_names)
|
101
97
|
end
|
@@ -103,4 +99,5 @@ module ValidationExtensions
|
|
103
99
|
end
|
104
100
|
end
|
105
101
|
|
106
|
-
|
102
|
+
ActiveModel::Validations::HelperMethods.send(:include, ValidationExtensions::IsbnValidation::HelperMethods)
|
103
|
+
ActiveModel::Validations::IsbnFormatValidator = ValidationExtensions::IsbnValidation::IsbnFormatValidator
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isbn_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -68,21 +68,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
68
|
- - ! '>='
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
hash: -239021533232196791
|
74
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
72
|
none: false
|
76
73
|
requirements:
|
77
74
|
- - ! '>='
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: '0'
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
hash: -239021533232196791
|
83
77
|
requirements: []
|
84
78
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.23
|
86
80
|
signing_key:
|
87
81
|
specification_version: 3
|
88
82
|
summary: isbn_validation adds an isbn validation routine to active record models.
|