Class: Inspector::Constraints::Email
Constant Summary
collapse
- PATTERN =
begin
if (RUBY_VERSION == '1.9.2' && RUBY_ENGINE == 'jruby' && JRUBY_VERSION <= '1.6.3') || RUBY_VERSION >= '1.9.2'
letter = 'a-zA-Z'
else
letter = 'a-zA-Z\p{L}' end
digit = '0-9'
atext = "[#{letter}#{digit}\!\#\$\%\&\'\*+\/\=\?\^\_\`\{\|\}\~\-]"
dot_atom_text = "#{atext}+([.]#{atext}*)+"
dot_atom = dot_atom_text
no_ws_ctl = '\x01-\x08\x11\x12\x14-\x1f\x7f'
qtext = "[^#{no_ws_ctl}\\x0d\\x22\\x5c]" text = '[\x01-\x09\x11\x12\x14-\x7f]'
quoted_pair = "(\\x5c#{text})"
qcontent = "(?:#{qtext}|#{quoted_pair})"
quoted_string = "[\"]#{qcontent}+[\"]"
atom = "#{atext}+"
word = "(?:#{atom}|#{quoted_string})"
obs_local_part = "#{word}([.]#{word})*"
local_part = "(?:#{dot_atom}|#{quoted_string}|#{obs_local_part})"
dtext = "[#{no_ws_ctl}\\x21-\\x5a\\x5e-\\x7e]"
dcontent = "(?:#{dtext}|#{quoted_pair})"
domain_literal = "\\[#{dcontent}+\\]"
obs_domain = "#{atom}([.]#{atom})+"
domain = "(?:#{dot_atom}|#{domain_literal}|#{obs_domain})"
addr_spec = "#{local_part}\@#{domain}"
pattern = /\A#{addr_spec}\z/u
end
Instance Method Summary
collapse
#negate!, #positive?, #validator
Instance Method Details
#inspect ⇒ Object
52
53
54
|
# File 'lib/inspector/constraints/email.rb', line 52
def inspect
"#<email>"
end
|
#to_s ⇒ Object
48
49
50
|
# File 'lib/inspector/constraints/email.rb', line 48
def to_s
"be_an_email"
end
|
#valid?(email) ⇒ Boolean
44
45
46
|
# File 'lib/inspector/constraints/email.rb', line 44
def valid?(email)
!(PATTERN =~ email).nil?
end
|