sixarm_ruby_email_address_validation 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -0
- data/INSTALL.txt +32 -0
- data/LICENSE.txt +12 -0
- data/README.rdoc +59 -0
- data/lib/sixarm_ruby_email_address_validation.rb +82 -0
- data/test/sixarm_ruby_email_address_validation_test.rb +37 -0
- metadata +80 -0
- metadata.gz.sig +2 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
�����N6r���I1�W���}}\�)�;{o���4;1]}{ۂ���M�k���"R�`�Aܗ#PW�d�o!��8���&��QJ��|����j/8r�c�=b�5��bGW<����j{;�2�-���J��
|
data/INSTALL.txt
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
= SixArm.com Ruby Gem Install
|
3
|
+
|
4
|
+
|
5
|
+
First-time users: add our gem certificate and source.
|
6
|
+
When you do this once, it works for all our gems.
|
7
|
+
|
8
|
+
sudo wget http://sixarm.com/sixarm.pem
|
9
|
+
sudo gem cert --add sixarm.pem
|
10
|
+
sudo gem sources --add http://sixarm.com
|
11
|
+
|
12
|
+
Install the gem with advanced options.
|
13
|
+
|
14
|
+
sudo gem install sixarm_ruby_email_address_validation --test --trust-policy HighSecurity
|
15
|
+
|
16
|
+
|
17
|
+
== Notes
|
18
|
+
|
19
|
+
Do you have any questions, comments, suggestions, or feedback?
|
20
|
+
Let us know, we're happy to help. Our email is sixarm@sixarm.com
|
21
|
+
|
22
|
+
Do you want to create your own high security gems?
|
23
|
+
Learn how at http://www.rubygems.org/read/chapter/21
|
24
|
+
|
25
|
+
To see your current gem certificate list:
|
26
|
+
|
27
|
+
sudo gem cert --list
|
28
|
+
|
29
|
+
Our cert looks like this:
|
30
|
+
|
31
|
+
/C=US/ST=California/L=San Francisco/O=SixArm/CN=sixarm.com
|
32
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
You may choose any of these licenses:
|
4
|
+
|
5
|
+
- CreativeCommons License, Non-commercial Share Alike
|
6
|
+
- LGPL, GNU Lesser General Public License
|
7
|
+
- MIT License
|
8
|
+
- Ruby License
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
11
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
= SixArm Ruby Gem: email address validation using RFC 822 pattern matching
|
3
|
+
|
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.
|
10
|
+
|
11
|
+
This is a gem wrapper around http://tfletcher.com/lib/rfc822.rb
|
12
|
+
|
13
|
+
Example:
|
14
|
+
if EMAIL_ADDRESS_PATTERN=~'foo@bar.com'
|
15
|
+
puts "found"
|
16
|
+
else
|
17
|
+
puts "not found"
|
18
|
+
end
|
19
|
+
=> found
|
20
|
+
|
21
|
+
To find an email address in a string, do the pattern match
|
22
|
+
then use the result, which is the match's string position:
|
23
|
+
|
24
|
+
Example of match position:
|
25
|
+
match_position = EMAIL_ADDRESS_PATTERN=~'foo@bar.com'
|
26
|
+
=> 0
|
27
|
+
|
28
|
+
match_position = EMAIL_ADDRESS_PATTERN=~'... foo@bar.com ...'
|
29
|
+
=> 4
|
30
|
+
|
31
|
+
match_position = EMAIL_ADDRESS_PATTERN=~'... hello world ...'
|
32
|
+
=> nil
|
33
|
+
|
34
|
+
To do an exact pattern match, use the EMAIL_ADDRESS_EXACT_PATTERN.
|
35
|
+
This matches the entire string from start to end; in other words,
|
36
|
+
the entire string must be one email address.
|
37
|
+
|
38
|
+
Example of exact pattern match:
|
39
|
+
if EMAIL_ADDRESS_EXACT_PATTERN=~'foo@bar.com'
|
40
|
+
puts "found"
|
41
|
+
else
|
42
|
+
puts "not found"
|
43
|
+
end
|
44
|
+
=> found
|
45
|
+
|
46
|
+
if EMAIL_ADDRESS_EXACT_PATTERN=~'... foo@bar.com ...'
|
47
|
+
puts "found"
|
48
|
+
else
|
49
|
+
puts "not found"
|
50
|
+
end
|
51
|
+
=> not found
|
52
|
+
|
53
|
+
The exact pattern is especialy useful to validate an email address.
|
54
|
+
|
55
|
+
Example to validate an email address:
|
56
|
+
def valid?(email_address)
|
57
|
+
EMAIL_ADDRESS_EXACT_PATTERN=~email_address ? true : false
|
58
|
+
end
|
59
|
+
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin rdoc
|
3
|
+
|
4
|
+
= SixArm » Ruby » Email address validation using RFC 822 pattern matching
|
5
|
+
|
6
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
7
|
+
Copyright:: Copyright (c) 2006-2011 Joel Parker Henderson
|
8
|
+
License:: See LICENSE.txt file
|
9
|
+
|
10
|
+
Email address regex, to validate an email address using RFC 822.
|
11
|
+
|
12
|
+
This is a gem wrapper around http://tfletcher.com/lib/rfc822.rb
|
13
|
+
|
14
|
+
@example
|
15
|
+
if EMAIL_ADDRESS_PATTERN=~'foo@bar.com'
|
16
|
+
puts "found"
|
17
|
+
else
|
18
|
+
puts "not found"
|
19
|
+
end
|
20
|
+
=> found
|
21
|
+
|
22
|
+
To find an email address in a string, do the pattern match
|
23
|
+
then use the result, which is the match's string position:
|
24
|
+
|
25
|
+
@example of match position:
|
26
|
+
match_position = EMAIL_ADDRESS_PATTERN=~'foo@bar.com'
|
27
|
+
=> 0
|
28
|
+
|
29
|
+
match_position = EMAIL_ADDRESS_PATTERN=~'... foo@bar.com ...'
|
30
|
+
=> 4
|
31
|
+
|
32
|
+
match_position = EMAIL_ADDRESS_PATTERN=~'... hello world ...'
|
33
|
+
=> nil
|
34
|
+
|
35
|
+
|
36
|
+
To do an exact pattern match, use the EMAIL_ADDRESS_EXACT_PATTERN.
|
37
|
+
This matches the entire string from start to end; in other words,
|
38
|
+
the entire string must be one email address.
|
39
|
+
|
40
|
+
@example of exact pattern match:
|
41
|
+
if EMAIL_ADDRESS_EXACT_PATTERN=~'foo@bar.com'
|
42
|
+
puts "found"
|
43
|
+
else
|
44
|
+
puts "not found"
|
45
|
+
end
|
46
|
+
=> found
|
47
|
+
|
48
|
+
if EMAIL_ADDRESS_EXACT_PATTERN=~'... foo@bar.com ...'
|
49
|
+
puts "found"
|
50
|
+
else
|
51
|
+
puts "not found"
|
52
|
+
end
|
53
|
+
=> not found
|
54
|
+
|
55
|
+
The exact pattern is especialy useful to validate an email address.
|
56
|
+
|
57
|
+
Example to validate an email address:
|
58
|
+
def valid?(email_address)
|
59
|
+
EMAIL_ADDRESS_EXACT_PATTERN=~email_address ? true : false
|
60
|
+
end
|
61
|
+
|
62
|
+
=end
|
63
|
+
|
64
|
+
|
65
|
+
module EmailAddressValidation
|
66
|
+
|
67
|
+
EMAIL_ADDRESS_QTEXT = Regexp.new '[^\\x0d\\x22\\x5c\\x80-\\xff]', nil, 'n'
|
68
|
+
EMAIL_ADDRESS_DTEXT = Regexp.new '[^\\x0d\\x5b-\\x5d\\x80-\\xff]', nil, 'n'
|
69
|
+
EMAIL_ADDRESS_ATOM = Regexp.new '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+', nil, 'n'
|
70
|
+
EMAIL_ADDRESS_QUOTED_PAIR = Regexp.new '\\x5c[\\x00-\\x7f]', nil, 'n'
|
71
|
+
EMAIL_ADDRESS_DOMAIN_LITERAL = Regexp.new "\\x5b(?:#{EMAIL_ADDRESS_DTEXT}|#{EMAIL_ADDRESS_QUOTED_PAIR})*\\x5d", nil, 'n'
|
72
|
+
EMAIL_ADDRESS_QUOTED_STRING = Regexp.new "\\x22(?:#{EMAIL_ADDRESS_QTEXT}|#{EMAIL_ADDRESS_QUOTED_PAIR})*\\x22", nil, 'n'
|
73
|
+
EMAIL_ADDRESS_DOMAIN_REF = EMAIL_ADDRESS_ATOM
|
74
|
+
EMAIL_ADDRESS_SUB_DOMAIN = "(?:#{EMAIL_ADDRESS_DOMAIN_REF}|#{EMAIL_ADDRESS_DOMAIN_LITERAL})"
|
75
|
+
EMAIL_ADDRESS_WORD = "(?:#{EMAIL_ADDRESS_ATOM}|#{EMAIL_ADDRESS_QUOTED_STRING})"
|
76
|
+
EMAIL_ADDRESS_DOMAIN = "#{EMAIL_ADDRESS_SUB_DOMAIN}(?:\\x2e#{EMAIL_ADDRESS_SUB_DOMAIN})*"
|
77
|
+
EMAIL_ADDRESS_LOCAL_PART = "#{EMAIL_ADDRESS_WORD}(?:\\x2e#{EMAIL_ADDRESS_WORD})*"
|
78
|
+
EMAIL_ADDRESS_SPEC = "#{EMAIL_ADDRESS_LOCAL_PART}\\x40#{EMAIL_ADDRESS_DOMAIN}"
|
79
|
+
EMAIL_ADDRESS_PATTERN = Regexp.new "#{EMAIL_ADDRESS_SPEC}", nil, 'n'
|
80
|
+
EMAIL_ADDRESS_EXACT_PATTERN = Regexp.new "\\A#{EMAIL_ADDRESS_SPEC}\\z", nil, 'n'
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'sixarm_ruby_email_address_validation'
|
3
|
+
|
4
|
+
class Testing < Test::Unit::TestCase
|
5
|
+
|
6
|
+
include EmailAddressValidation
|
7
|
+
|
8
|
+
def test_pattern_success
|
9
|
+
assert_equal(0,EMAIL_ADDRESS_PATTERN=~'foo@bar.com')
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_pattern_failure
|
13
|
+
assert_equal(nil,EMAIL_ADDRESS_PATTERN=~'foo')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_pattern_chaff_success
|
17
|
+
assert_equal(4,EMAIL_ADDRESS_PATTERN=~'... foo@bar.com ...')
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_pattern_chaff_failure
|
21
|
+
assert_equal(nil,EMAIL_ADDRESS_PATTERN=~'... foo ...')
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_exact_pattern_success
|
25
|
+
assert_equal(0,EMAIL_ADDRESS_EXACT_PATTERN=~'foo@bar.com')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_exact_pattern_failure_due_to_left_chaff
|
29
|
+
assert_equal(nil,EMAIL_ADDRESS_EXACT_PATTERN=~'... foo@bar.com')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_exact_pattern_failure_due_to_right_chaff
|
33
|
+
assert_equal(nil,EMAIL_ADDRESS_EXACT_PATTERN=~'foo@bar.com ...')
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sixarm_ruby_email_address_validation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.2.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SixArm
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- |
|
13
|
+
-----BEGIN CERTIFICATE-----
|
14
|
+
MIIDBDCCAm2gAwIBAgIJAKPwEETU5bHoMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
|
15
|
+
BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
|
16
|
+
c2NvMQ8wDQYDVQQKEwZTaXhBcm0xEzARBgNVBAMTCnNpeGFybS5jb20wHhcNMTAx
|
17
|
+
MjEzMjMyNzEzWhcNMTMwOTA4MjMyNzEzWjBgMQswCQYDVQQGEwJVUzETMBEGA1UE
|
18
|
+
CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEPMA0GA1UEChMG
|
19
|
+
U2l4QXJtMRMwEQYDVQQDEwpzaXhhcm0uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GN
|
20
|
+
ADCBiQKBgQC94mD9JDwBsunsOI0VR3CXXbOWg9cWaWciwFyJNFiM7A9I8KPLfXUw
|
21
|
+
QC4czUe5ZuG4WHvinrWhkrCK+1dWBqoEClxdF/FoKO5a+tonGCjjmfy81JmFjjyx
|
22
|
+
eTsjsHyvw+Qik9kpf9aj6+pnkNrVswgNHVea2o9yabbEiS6VSeJWoQIDAQABo4HF
|
23
|
+
MIHCMB0GA1UdDgQWBBQzPJtqmSgc53eDN7aSzDQwr9TALDCBkgYDVR0jBIGKMIGH
|
24
|
+
gBQzPJtqmSgc53eDN7aSzDQwr9TALKFkpGIwYDELMAkGA1UEBhMCVVMxEzARBgNV
|
25
|
+
BAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDzANBgNVBAoT
|
26
|
+
BlNpeEFybTETMBEGA1UEAxMKc2l4YXJtLmNvbYIJAKPwEETU5bHoMAwGA1UdEwQF
|
27
|
+
MAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAooEexP/oPam1TP71SyuhxMb+uTrZbSQe
|
28
|
+
jVB+ExRwWadGwaNPUA56d39qwavwP+iu+3JpeonNMVvbWXF5naCX/dNFIeREHzER
|
29
|
+
ZDRQYMqru9TEMna6HD9zpcstF7vwThGovlOQ+3Y6plQ4nMzipXcZ9THqs65PIL0q
|
30
|
+
eabwpCbAopo=
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
|
33
|
+
date: 2011-04-06 00:00:00 -07:00
|
34
|
+
default_executable:
|
35
|
+
dependencies: []
|
36
|
+
|
37
|
+
description:
|
38
|
+
email: sixarm@sixarm.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- README.rdoc
|
47
|
+
- INSTALL.txt
|
48
|
+
- LICENSE.txt
|
49
|
+
- lib/sixarm_ruby_email_address_validation.rb
|
50
|
+
- test/sixarm_ruby_email_address_validation_test.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://sixarm.com/
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.6.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: "SixArm \xC2\xBB Ruby \xC2\xBB Email address validation using RFC 822 pattern match regex regular expressions"
|
79
|
+
test_files:
|
80
|
+
- test/sixarm_ruby_email_address_validation_test.rb
|
metadata.gz.sig
ADDED