nifval 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/lib/generators/nifval/install_generator.rb +9 -0
- data/lib/generators/nifval/templates/en.yml +3 -0
- data/lib/nifval.rb +8 -4
- data/lib/nifval/version.rb +1 -1
- metadata +23 -3
data/README.md
CHANGED
@@ -44,6 +44,12 @@ Simply add this gem to your Gemfile...
|
|
44
44
|
|
45
45
|
Note: It appears that if we load <b>NifVal</b> after <b>Devise</b>, <b>Nifval</b> won't work. In order to make everything work, simply add <b>Nifval</b> before <b>Devise</b> in the Gemfile.
|
46
46
|
|
47
|
+
Then run the generator in order to install the I18n template:
|
48
|
+
|
49
|
+
rails generate nifval:install
|
50
|
+
|
51
|
+
And you are done!
|
52
|
+
|
47
53
|
Documentation
|
48
54
|
-------------
|
49
55
|
|
data/lib/nifval.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# Adapted from http://compartecodigo.com/javascript/validar-nif-cif-nie-segun-ley-vigente-31.html
|
3
3
|
require "active_model"
|
4
4
|
|
5
|
-
module
|
5
|
+
module Nifval
|
6
6
|
class NifValidator < ActiveModel::EachValidator
|
7
7
|
def validate_each(record, attribute, value)
|
8
8
|
if !is_valid_nif value
|
9
|
-
record.errors.add(attribute, "
|
9
|
+
record.errors.add(attribute, t("nifval.wrong"))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -53,9 +53,13 @@ module NifVal
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def ival v
|
56
|
-
RUBY_VERSION
|
56
|
+
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new("1.9")
|
57
|
+
v.to_i
|
58
|
+
else
|
59
|
+
v-48
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
|
-
ActiveModel::Validations.send(:include,
|
65
|
+
ActiveModel::Validations.send(:include, Nifval)
|
data/lib/nifval/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Albert Bellonch
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-21 00:00:00 +02:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +26,10 @@ dependencies:
|
|
21
26
|
requirements:
|
22
27
|
- - ~>
|
23
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 9
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 5
|
24
33
|
version: "2.5"
|
25
34
|
type: :development
|
26
35
|
version_requirements: *id001
|
@@ -32,6 +41,9 @@ dependencies:
|
|
32
41
|
requirements:
|
33
42
|
- - ">="
|
34
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
35
47
|
version: "0"
|
36
48
|
type: :runtime
|
37
49
|
version_requirements: *id002
|
@@ -50,6 +62,8 @@ files:
|
|
50
62
|
- Gemfile.lock
|
51
63
|
- README.md
|
52
64
|
- Rakefile
|
65
|
+
- lib/generators/nifval/install_generator.rb
|
66
|
+
- lib/generators/nifval/templates/en.yml
|
53
67
|
- lib/nifval.rb
|
54
68
|
- lib/nifval/version.rb
|
55
69
|
- nifval.gemspec
|
@@ -69,17 +83,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
83
|
requirements:
|
70
84
|
- - ">="
|
71
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
72
89
|
version: "0"
|
73
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
91
|
none: false
|
75
92
|
requirements:
|
76
93
|
- - ">="
|
77
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
78
98
|
version: "0"
|
79
99
|
requirements: []
|
80
100
|
|
81
101
|
rubyforge_project: nifval
|
82
|
-
rubygems_version: 1.
|
102
|
+
rubygems_version: 1.5.2
|
83
103
|
signing_key:
|
84
104
|
specification_version: 3
|
85
105
|
summary: Validates a Spanish NIF/CIF/NIE
|