validates_and_formats_phones 0.0.6 → 0.0.7
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.
- data/README +35 -0
- data/README.rdoc +5 -1
- data/Rakefile +1 -1
- data/lib/validates_and_formats_phones/phone_formatter.rb +3 -3
- data/rails/init.rb +2 -1
- metadata +4 -7
- data/init.rb +0 -2
- data/install.rb +0 -1
- data/uninstall.rb +0 -1
data/README
CHANGED
@@ -41,6 +41,7 @@ validation and formatting for the field :phone like so:
|
|
41
41
|
> person.save
|
42
42
|
> => false
|
43
43
|
|
44
|
+
|
44
45
|
You can pass your own fields like so:
|
45
46
|
|
46
47
|
class Person
|
@@ -65,4 +66,38 @@ You can also format and specify fields, like so:
|
|
65
66
|
validates_and_formats_phones :fax, mobile, '####-####'
|
66
67
|
end
|
67
68
|
|
69
|
+
|
70
|
+
== Configuration options
|
71
|
+
|
72
|
+
As of version 0.0.6 all configuration options available
|
73
|
+
to validates_each are also available to the phone validator.
|
74
|
+
For example:
|
75
|
+
|
76
|
+
class Person
|
77
|
+
validates_and_formats_phones :fax, '###-###-####', :if => :some_function_name
|
78
|
+
end
|
79
|
+
|
80
|
+
Here's a quick link to the validates_each documentation at the time of writing:
|
81
|
+
|
82
|
+
http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M002161
|
83
|
+
|
84
|
+
|
85
|
+
== Tiny string extension
|
86
|
+
|
87
|
+
As a tiny added benefit, String is extended with a to_phone method.
|
88
|
+
|
89
|
+
> '123 456 7890'.to_phone
|
90
|
+
> => '(123) 456-7890'
|
91
|
+
>
|
92
|
+
> '12345678'.to_phone('####-####')
|
93
|
+
> => '1234-5678'
|
94
|
+
|
95
|
+
=Change Log
|
96
|
+
0.0.7
|
97
|
+
1. Bug fix for ...yes... Ruby 1.8.5...That's dedication right there.
|
98
|
+
0.0.6
|
99
|
+
1. Add configuration options available in validates_each method.
|
100
|
+
If you find any bugs, please report them at our github page:
|
101
|
+
|
102
|
+
http://github.com/btelles-validates_and_formats_phones
|
68
103
|
Copyright (c) 2010 [Bernie Telles], released under the MIT license
|
data/README.rdoc
CHANGED
@@ -67,7 +67,7 @@ You can also format and specify fields, like so:
|
|
67
67
|
end
|
68
68
|
|
69
69
|
|
70
|
-
|
70
|
+
== Configuration options
|
71
71
|
|
72
72
|
As of version 0.0.6 all configuration options available
|
73
73
|
to validates_each are also available to the phone validator.
|
@@ -82,6 +82,8 @@ Here's a quick link to the validates_each documentation at the time of writing:
|
|
82
82
|
http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M002161
|
83
83
|
|
84
84
|
|
85
|
+
== Tiny string extension
|
86
|
+
|
85
87
|
As a tiny added benefit, String is extended with a to_phone method.
|
86
88
|
|
87
89
|
> '123 456 7890'.to_phone
|
@@ -91,6 +93,8 @@ As a tiny added benefit, String is extended with a to_phone method.
|
|
91
93
|
> => '1234-5678'
|
92
94
|
|
93
95
|
=Change Log
|
96
|
+
0.0.7
|
97
|
+
1. Bug fix for ...yes... Ruby 1.8.5...That's dedication right there.
|
94
98
|
0.0.6
|
95
99
|
1. Add configuration options available in validates_each method.
|
96
100
|
If you find any bugs, please report them at our github page:
|
data/Rakefile
CHANGED
@@ -16,11 +16,11 @@ String.class_eval do
|
|
16
16
|
digits = scan(/\d/)
|
17
17
|
total_digits = digits.size
|
18
18
|
if formats[total_digits]
|
19
|
-
|
19
|
+
result = ''
|
20
|
+
formats[total_digits].each_char do | character|
|
20
21
|
character == '#' ? result << digits.shift : result << character
|
21
|
-
result
|
22
22
|
end
|
23
|
-
|
23
|
+
result
|
24
24
|
else
|
25
25
|
self
|
26
26
|
end
|
data/rails/init.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require 'validates_and_formats_phones'
|
1
|
+
require 'validates_and_formats_phones/phone_formatter'
|
2
|
+
require 'validates_and_formats_phones/validates_and_formats_phones'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_and_formats_phones
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernie Telles
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-08 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,13 +22,10 @@ extensions: []
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- README
|
24
24
|
files:
|
25
|
-
-
|
26
|
-
- Rakefile
|
25
|
+
- README.rdoc
|
27
26
|
- README
|
28
|
-
- install.rb
|
29
27
|
- discover.rb
|
30
|
-
-
|
31
|
-
- README.rdoc
|
28
|
+
- Rakefile
|
32
29
|
- lib/validates_and_formats_phones/validates_and_formats_phones.rb
|
33
30
|
- lib/validates_and_formats_phones/phone_formatter.rb
|
34
31
|
- lib/validates_and_formats_phones.rb
|
data/init.rb
DELETED
data/install.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Install hook code here
|
data/uninstall.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Uninstall hook code here
|