Module: EmailVeracity::Config

Defined in:
lib/email_veracity/config.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
:whitelist => %w[
  aol.com
  gmail.com
  hotmail.com
  me.com
  mac.com
  msn.com
  rogers.com
  sympatico.ca
  yahoo.com
  telus.com
  sprint.com
  sprint.ca ],
:blacklist => %w[
  dodgeit.com
  mintemail.com
  mintemail.uni.cc
  1mintemail.mooo.com
  spammotel.com
  trashmail.net ],
:valid_pattern => %r{
  ^
  (
    [\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+
    \.
  )
  *
  [\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+
  @
  (
    (
      (
        (
          (
            [a-z0-9]{1}
            [a-z0-9\-]{0,62}
            [a-z0-9]{1}
          )
          |
          [a-z]
        )
        \.
      )+
      [a-z]{2,6}
    )
    |
    (
      \d{1,3}
      \.
    ){3}
    \d{1,3}
    (
      \:\d{1,5}
    )?
  )
  $
}xi,
:must_include => [],
:timeout => 2,
:skip_lookup => false,
:enforce_blacklist => false,
:enforce_whitelist => true }

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



69
70
71
# File 'lib/email_veracity/config.rb', line 69

def [](key)
  @options[key.to_sym]
end

.[]=(key, value) ⇒ Object



73
74
75
# File 'lib/email_veracity/config.rb', line 73

def []=(key, value)
  @options[key.to_sym] = value
end

.enforced_record?(record) ⇒ Boolean

Returns:

  • (Boolean)


95
96
97
98
# File 'lib/email_veracity/config.rb', line 95

def enforced_record?(record)
  return unless @options[:must_include].is_a?(Array)
  @options[:must_include].any? { |i| i.to_s == record.to_s }
end

.optionsObject



77
78
79
# File 'lib/email_veracity/config.rb', line 77

def options
  @options
end

.options=(options) ⇒ Object



81
82
83
84
85
86
# File 'lib/email_veracity/config.rb', line 81

def options=(options)
  unless options.is_a?(Hash)
    raise ArgumentError, "options must be a Hash not #{options.class}"
  end
  @options = options
end

.revert!Object



100
101
102
# File 'lib/email_veracity/config.rb', line 100

def revert!
  @options = DEFAULT_OPTIONS.clone
end

.update(options) ⇒ Object



88
89
90
91
92
93
# File 'lib/email_veracity/config.rb', line 88

def update(options)
  unless options.is_a?(Hash)
    raise ArgumentError, "options must be a Hash not #{options.class}"
  end
  @options.update(options)
end