sixarm_ruby_email_address_validation 1.2.2 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,3 @@
1
1
  CHANGELOG
2
-
2
+ 2011-06-12 1.2.4 Rename EMAIL_ADDRESS_PATTERN to EMAIL_ADDRESS_INNER_PATTERN for clarity
3
3
  2011-04-24 1.2.2 Update for Ruby 1.9.2 and Rails 3.0.6
@@ -1,36 +1,40 @@
1
+ = SixArm.com » Ruby » Email address validation using RFC 822 pattern matching
1
2
 
2
- = SixArm Ruby Gem: email address validation using RFC 822 pattern matching
3
+ Author:: Joel Parker Henderson, joel@joelparkerhenderson.com
4
+ Copyright:: Copyright (c) 2006-2011 Joel Parker Henderson
5
+ License:: See LICENSE.txt file
3
6
 
4
- Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
5
- Copyright:: Copyright (c) 2006-2010 Joel Parker Henderson
6
- License:: CreativeCommons License, Non-commercial Share Alike
7
- License:: LGPL, GNU Lesser General Public License
8
-
9
- Email address regex, to validate an email address using RFC 822.
7
+ Email address regular expression to validate an email address using RFC 822.
10
8
 
11
9
  This is a gem wrapper around http://tfletcher.com/lib/rfc822.rb
12
10
 
13
11
  Example:
14
- if EMAIL_ADDRESS_PATTERN=~'foo@bar.com'
12
+ if EMAIL_ADDRESS_INNER_PATTERN=~'foo@bar.com'
15
13
  puts "found"
16
14
  else
17
15
  puts "not found"
18
16
  end
19
17
  => found
20
18
 
19
+
20
+ == Pattern Match
21
+
21
22
  To find an email address in a string, do the pattern match
22
23
  then use the result, which is the match's string position:
23
24
 
24
25
  Example of match position:
25
- match_position = EMAIL_ADDRESS_PATTERN=~'foo@bar.com'
26
+ match_position = EMAIL_ADDRESS_INNER_PATTERN=~'foo@bar.com'
26
27
  => 0
27
28
 
28
- match_position = EMAIL_ADDRESS_PATTERN=~'... foo@bar.com ...'
29
+ match_position = EMAIL_ADDRESS_INNER_PATTERN=~'... foo@bar.com ...'
29
30
  => 4
30
31
 
31
- match_position = EMAIL_ADDRESS_PATTERN=~'... hello world ...'
32
+ match_position = EMAIL_ADDRESS_INNER_PATTERN=~'... hello world ...'
32
33
  => nil
33
34
 
35
+
36
+ == Exact Pattern Match
37
+
34
38
  To do an exact pattern match, use the EMAIL_ADDRESS_EXACT_PATTERN.
35
39
  This matches the entire string from start to end; in other words,
36
40
  the entire string must be one email address.
@@ -57,3 +61,15 @@ Example to validate an email address:
57
61
  EMAIL_ADDRESS_EXACT_PATTERN=~email_address ? true : false
58
62
  end
59
63
 
64
+
65
+ == Rails Validation
66
+
67
+ To add email address validation to a typical Ruby On Rails model:
68
+
69
+ class User
70
+ include EmailAddressValidation
71
+ validates :email_address, :format => { :with => EMAIL_ADDRESS_EXACT_PATTERN },
72
+ end
73
+
74
+
75
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.2.4
@@ -18,7 +18,7 @@ module EmailAddressValidation
18
18
  EMAIL_ADDRESS_DOMAIN = "#{EMAIL_ADDRESS_SUB_DOMAIN}(?:\\x2e#{EMAIL_ADDRESS_SUB_DOMAIN})*"
19
19
  EMAIL_ADDRESS_LOCAL_PART = "#{EMAIL_ADDRESS_WORD}(?:\\x2e#{EMAIL_ADDRESS_WORD})*"
20
20
  EMAIL_ADDRESS_SPEC = "#{EMAIL_ADDRESS_LOCAL_PART}\\x40#{EMAIL_ADDRESS_DOMAIN}"
21
- EMAIL_ADDRESS_PATTERN = Regexp.new "#{EMAIL_ADDRESS_SPEC}", nil, 'n'
21
+ EMAIL_ADDRESS_INNER_PATTERN = Regexp.new "#{EMAIL_ADDRESS_SPEC}", nil, 'n'
22
22
  EMAIL_ADDRESS_EXACT_PATTERN = Regexp.new "\\A#{EMAIL_ADDRESS_SPEC}\\z", nil, 'n'
23
23
 
24
24
  end
@@ -8,20 +8,20 @@ class Testing < Test::Unit::TestCase
8
8
 
9
9
  include EmailAddressValidation
10
10
 
11
- def test_pattern_success
12
- assert_equal(0,EMAIL_ADDRESS_PATTERN=~'foo@bar.com')
11
+ def test_inner_pattern_success
12
+ assert_equal(0,EMAIL_ADDRESS_INNER_PATTERN=~'foo@bar.com')
13
13
  end
14
14
 
15
- def test_pattern_failure
16
- assert_equal(nil,EMAIL_ADDRESS_PATTERN=~'foo')
15
+ def test_inner_pattern_failure
16
+ assert_equal(nil,EMAIL_ADDRESS_INNER_PATTERN=~'foo')
17
17
  end
18
18
 
19
- def test_pattern_chaff_success
20
- assert_equal(4,EMAIL_ADDRESS_PATTERN=~'... foo@bar.com ...')
19
+ def test_inner_pattern_chaff_success
20
+ assert_equal(4,EMAIL_ADDRESS_INNER_PATTERN=~'... foo@bar.com ...')
21
21
  end
22
22
 
23
- def test_pattern_chaff_failure
24
- assert_equal(nil,EMAIL_ADDRESS_PATTERN=~'... foo ...')
23
+ def test_inner_pattern_chaff_failure
24
+ assert_equal(nil,EMAIL_ADDRESS_INNER_PATTERN=~'... foo ...')
25
25
  end
26
26
 
27
27
  def test_exact_pattern_success
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sixarm_ruby_email_address_validation
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.2
5
+ version: 1.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - SixArm
@@ -30,7 +30,7 @@ cert_chain:
30
30
  eabwpCbAopo=
31
31
  -----END CERTIFICATE-----
32
32
 
33
- date: 2011-04-24 00:00:00 -07:00
33
+ date: 2011-07-08 00:00:00 -07:00
34
34
  default_executable:
35
35
  dependencies: []
36
36
 
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements: []
77
77
 
78
78
  rubyforge_project:
79
- rubygems_version: 1.6.2
79
+ rubygems_version: 1.3.9.2
80
80
  signing_key:
81
81
  specification_version: 3
82
82
  summary: "SixArm \xC2\xBB Ruby \xC2\xBB Email address validation using RFC 822 pattern match regex regular expressions"
metadata.gz.sig CHANGED
Binary file