Class: ValidationTrackerClient::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/validation_tracker_client/configuration.rb

Overview

Used to set up and modify settings for the notifier.

Constant Summary collapse

OPTIONS =
[:api_key, :development_environments,
:development_lookup, :environment_name, :host,
:http_open_timeout, :http_read_timeout,
:notifier_name, :notifier_url, :notifier_version,
:params_filters, :project_root, :port, :protocol, :proxy_host,
:proxy_pass, :proxy_port, :proxy_user, :secure, :framework,
:user_information].freeze
DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
DEFAULT_BACKTRACE_FILTERS =
[
  lambda { |line|
    if defined?(ValidationTrackerClient.configuration.project_root) && ValidationTrackerClient.configuration.project_root.to_s != '' 
      line.gsub(/#{ValidationTrackerClient.configuration.project_root}/, "[PROJECT_ROOT]")
    else
      line
    end
  },
  lambda { |line| line.gsub(/^\.\//, "") },
  lambda { |line|
    if defined?(Gem)
      Gem.path.inject(line) do |line, path|
        line.gsub(/#{path}/, "[GEM_ROOT]")
      end
    end
  },
  lambda { |line| line if line !~ %r{lib/validation_tracker_client} }
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/validation_tracker_client/configuration.rb', line 102

def initialize
  @secure                   = false
  @host                     = 'validation-tracker.heroku.com'
  @http_open_timeout        = 2
  @http_read_timeout        = 5
  @params_filters           = DEFAULT_PARAMS_FILTERS.dup
  @ignore_user_agent        = []
  @development_environments = %w(test cucumber)
  @development_lookup       = true
  @notifier_name            = 'Validation Tracker Notifier'
  @notifier_version         = VERSION
  @notifier_url             = 'http://validation-tracker.heroku.com'
  @framework                = 'Standalone'
  @user_information         = 'Validation Tracker Error {{error_id}}'
end

Instance Attribute Details

#api_keyObject

The API key for your project, found on the project edit form.



14
15
16
# File 'lib/validation_tracker_client/configuration.rb', line 14

def api_key
  @api_key
end

#development_environmentsObject

A list of environments in which notifications should not be sent.



49
50
51
# File 'lib/validation_tracker_client/configuration.rb', line 49

def development_environments
  @development_environments
end

#development_lookupObject

true if you want to check for production errors matching development errors, false otherwise.



52
53
54
# File 'lib/validation_tracker_client/configuration.rb', line 52

def development_lookup
  @development_lookup
end

#environment_nameObject

The name of the environment the application is running in



55
56
57
# File 'lib/validation_tracker_client/configuration.rb', line 55

def environment_name
  @environment_name
end

#frameworkObject

The framework ValidationTrackerClient is configured to use



76
77
78
# File 'lib/validation_tracker_client/configuration.rb', line 76

def framework
  @framework
end

#hostObject

The host to connect to (defaults to validation-tracker.heroku.com).



17
18
19
# File 'lib/validation_tracker_client/configuration.rb', line 17

def host
  @host
end

#http_open_timeoutObject

The HTTP open timeout in seconds (defaults to 2).



27
28
29
# File 'lib/validation_tracker_client/configuration.rb', line 27

def http_open_timeout
  @http_open_timeout
end

#http_read_timeoutObject

The HTTP read timeout in seconds (defaults to 5).



30
31
32
# File 'lib/validation_tracker_client/configuration.rb', line 30

def http_read_timeout
  @http_read_timeout
end

#loggerObject

The logger used by ValidationTrackerClient



70
71
72
# File 'lib/validation_tracker_client/configuration.rb', line 70

def logger
  @logger
end

#notifier_nameObject

The name of the notifier library being used to send notifications (such as “Validation Tracker Notifier”)



61
62
63
# File 'lib/validation_tracker_client/configuration.rb', line 61

def notifier_name
  @notifier_name
end

#notifier_urlObject

The url of the notifier library being used to send notifications



67
68
69
# File 'lib/validation_tracker_client/configuration.rb', line 67

def notifier_url
  @notifier_url
end

#notifier_versionObject

The version of the notifier library being used to send notifications (such as “1.0.2”)



64
65
66
# File 'lib/validation_tracker_client/configuration.rb', line 64

def notifier_version
  @notifier_version
end

#params_filtersObject (readonly)

A list of parameters that should be filtered out of what is sent to Validation Tracker. By default, all “password” attributes will have their contents replaced.



46
47
48
# File 'lib/validation_tracker_client/configuration.rb', line 46

def params_filters
  @params_filters
end

#portObject

The port on which your Validation Tracker server runs (defaults to 443 for secure connections, 80 for insecure connections).



21
22
23
# File 'lib/validation_tracker_client/configuration.rb', line 21

def port
  @port
end

#project_rootObject

The path to the project in which the error occurred, such as the RAILS_ROOT



58
59
60
# File 'lib/validation_tracker_client/configuration.rb', line 58

def project_root
  @project_root
end

#proxy_hostObject

The hostname of your proxy server (if using a proxy)



33
34
35
# File 'lib/validation_tracker_client/configuration.rb', line 33

def proxy_host
  @proxy_host
end

#proxy_passObject

The password to use when logging into your proxy server (if using a proxy)



42
43
44
# File 'lib/validation_tracker_client/configuration.rb', line 42

def proxy_pass
  @proxy_pass
end

#proxy_portObject

The port of your proxy server (if using a proxy)



36
37
38
# File 'lib/validation_tracker_client/configuration.rb', line 36

def proxy_port
  @proxy_port
end

#proxy_userObject

The username to use when logging into your proxy server (if using a proxy)



39
40
41
# File 'lib/validation_tracker_client/configuration.rb', line 39

def proxy_user
  @proxy_user
end

#secureObject Also known as: secure?

true for https connections, false for http connections.



24
25
26
# File 'lib/validation_tracker_client/configuration.rb', line 24

def secure
  @secure
end

#user_informationObject

The text that the placeholder is replaced with. {error_id} is the actual error number.



73
74
75
# File 'lib/validation_tracker_client/configuration.rb', line 73

def user_information
  @user_information
end

Instance Method Details

#[](option) ⇒ Object

Allows config options to be read like a hash

Parameters:

  • option (Symbol)

    Key for a given attribute



122
123
124
# File 'lib/validation_tracker_client/configuration.rb', line 122

def [](option)
  send(option)
end

#environment_filtersObject



158
159
160
161
# File 'lib/validation_tracker_client/configuration.rb', line 158

def environment_filters
  warn 'config.environment_filters has been deprecated and has no effect.'
  []
end

#merge(hash) ⇒ Object

Returns a hash of all configurable options merged with hash

Parameters:

  • hash (Hash)

    A set of configuration options that will take precedence over the defaults



136
137
138
# File 'lib/validation_tracker_client/configuration.rb', line 136

def merge(hash)
  to_hash.merge(hash)
end

#protocolObject



150
151
152
153
154
155
156
# File 'lib/validation_tracker_client/configuration.rb', line 150

def protocol
  if secure?
    'https'
  else
    'http'
  end
end

#public?Boolean

Determines if the notifier will send notices.

Returns:

  • (Boolean)

    Returns false if in a development environment, true otherwise.



142
143
144
# File 'lib/validation_tracker_client/configuration.rb', line 142

def public?
  !development_environments.include?(environment_name)
end

#to_hashObject

Returns a hash of all configurable options



127
128
129
130
131
# File 'lib/validation_tracker_client/configuration.rb', line 127

def to_hash
  OPTIONS.inject({}) do |hash, option|
    hash.merge(option.to_sym => send(option))
  end
end