Class: Batbugger::Configuration

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

Constant Summary collapse

OPTIONS =
[:api_key, :backtrace_filters, :development_environments, :environment_name,
:host, :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
:ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
:params_filters, :project_root, :port, :protocol, :proxy_host, :proxy_pass,
:proxy_port, :proxy_user, :secure, :use_system_ssl_cert_chain, :framework,
:user_information, :rescue_rake_exceptions, :source_extract_radius,
:send_request_session, :debug].freeze
DEFAULT_PARAMS_FILTERS =
%w(password password_confirmation).freeze
DEFAULT_BACKTRACE_FILTERS =
[
  lambda { |line|
    if defined?(Batbugger.configuration.project_root) && Batbugger.configuration.project_root.to_s != ''
      line.sub(/#{Batbugger.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/batbugger} }
].freeze
IGNORE_DEFAULT =
['ActiveRecord::RecordNotFound',
'ActionController::RoutingError',
'ActionController::InvalidAuthenticityToken',
'CGI::Session::CookieStore::TamperedWithCookie',
'ActionController::UnknownAction',
'AbstractController::ActionNotFound',
'Mongoid::Errors::DocumentNotFound']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/batbugger/configuration.rb', line 103

def initialize
  @secure                    = true
  @use_system_ssl_cert_chain = false
  @host                      = 'www.batbugger.io'
  @http_open_timeout         = 2
  @http_read_timeout         = 5
  @params_filters            = DEFAULT_PARAMS_FILTERS.dup
  @backtrace_filters         = DEFAULT_BACKTRACE_FILTERS.dup
  @ignore_by_filters         = []
  @ignore                    = IGNORE_DEFAULT.dup
  @ignore_user_agent         = []
  @development_environments  = %w(development test cucumber)
  @notifier_name             = 'Batbugger Notifier'
  @notifier_version          = VERSION
  @notifier_url              = 'https://github.com/grepruby/batbugger'
  @framework                 = 'Standalone'
  @user_information          = 'Batbugger Error {{error_id}}'
  @rescue_rake_exceptions    = nil
  @source_extract_radius     = 2
  @send_request_session      = true
  @debug                     = false
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



11
12
13
# File 'lib/batbugger/configuration.rb', line 11

def api_key
  @api_key
end

#asyncObject Also known as: async?



161
162
163
164
# File 'lib/batbugger/configuration.rb', line 161

def async
  @async = Proc.new if block_given?
  @async
end

#backtrace_filtersObject (readonly)

Returns the value of attribute backtrace_filters.



35
36
37
# File 'lib/batbugger/configuration.rb', line 35

def backtrace_filters
  @backtrace_filters
end

#debugObject

Returns the value of attribute debug.



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

def debug
  @debug
end

#development_environmentsObject

Returns the value of attribute development_environments.



43
44
45
# File 'lib/batbugger/configuration.rb', line 43

def development_environments
  @development_environments
end

#environment_nameObject

Returns the value of attribute environment_name.



45
46
47
# File 'lib/batbugger/configuration.rb', line 45

def environment_name
  @environment_name
end

#frameworkObject

Returns the value of attribute framework.



59
60
61
# File 'lib/batbugger/configuration.rb', line 59

def framework
  @framework
end

#hostObject

Returns the value of attribute host.



13
14
15
# File 'lib/batbugger/configuration.rb', line 13

def host
  @host
end

#http_open_timeoutObject

Returns the value of attribute http_open_timeout.



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

def http_open_timeout
  @http_open_timeout
end

#http_read_timeoutObject

Returns the value of attribute http_read_timeout.



23
24
25
# File 'lib/batbugger/configuration.rb', line 23

def http_read_timeout
  @http_read_timeout
end

#ignoreObject (readonly)

Returns the value of attribute ignore.



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

def ignore
  @ignore
end

#ignore_by_filtersObject (readonly)

Returns the value of attribute ignore_by_filters.



37
38
39
# File 'lib/batbugger/configuration.rb', line 37

def ignore_by_filters
  @ignore_by_filters
end

#ignore_user_agentObject (readonly)

Returns the value of attribute ignore_user_agent.



41
42
43
# File 'lib/batbugger/configuration.rb', line 41

def ignore_user_agent
  @ignore_user_agent
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#notifier_nameObject

Returns the value of attribute notifier_name.



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

def notifier_name
  @notifier_name
end

#notifier_urlObject

Returns the value of attribute notifier_url.



53
54
55
# File 'lib/batbugger/configuration.rb', line 53

def notifier_url
  @notifier_url
end

#notifier_versionObject

Returns the value of attribute notifier_version.



51
52
53
# File 'lib/batbugger/configuration.rb', line 51

def notifier_version
  @notifier_version
end

#params_filtersObject (readonly)

Returns the value of attribute params_filters.



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

def params_filters
  @params_filters
end

#portObject

Returns the value of attribute port.



15
16
17
# File 'lib/batbugger/configuration.rb', line 15

def port
  @port
end

#project_rootObject

Returns the value of attribute project_root.



47
48
49
# File 'lib/batbugger/configuration.rb', line 47

def project_root
  @project_root
end

#proxy_hostObject

Returns the value of attribute proxy_host.



25
26
27
# File 'lib/batbugger/configuration.rb', line 25

def proxy_host
  @proxy_host
end

#proxy_passObject

Returns the value of attribute proxy_pass.



31
32
33
# File 'lib/batbugger/configuration.rb', line 31

def proxy_pass
  @proxy_pass
end

#proxy_portObject

Returns the value of attribute proxy_port.



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

def proxy_port
  @proxy_port
end

#proxy_userObject

Returns the value of attribute proxy_user.



29
30
31
# File 'lib/batbugger/configuration.rb', line 29

def proxy_user
  @proxy_user
end

#rescue_rake_exceptionsObject

Returns the value of attribute rescue_rake_exceptions.



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

def rescue_rake_exceptions
  @rescue_rake_exceptions
end

#secureObject Also known as: secure?

Returns the value of attribute secure.



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

def secure
  @secure
end

#send_request_sessionObject

Returns the value of attribute send_request_session.



65
66
67
# File 'lib/batbugger/configuration.rb', line 65

def send_request_session
  @send_request_session
end

#source_extract_radiusObject

Returns the value of attribute source_extract_radius.



63
64
65
# File 'lib/batbugger/configuration.rb', line 63

def source_extract_radius
  @source_extract_radius
end

#use_system_ssl_cert_chainObject Also known as: use_system_ssl_cert_chain?

Returns the value of attribute use_system_ssl_cert_chain.



19
20
21
# File 'lib/batbugger/configuration.rb', line 19

def use_system_ssl_cert_chain
  @use_system_ssl_cert_chain
end

#user_informationObject

Returns the value of attribute user_information.



57
58
59
# File 'lib/batbugger/configuration.rb', line 57

def user_information
  @user_information
end

Instance Method Details

#[](option) ⇒ Object



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

def [](option)
  send(option)
end

#ca_bundle_pathObject



179
180
181
182
183
184
185
# File 'lib/batbugger/configuration.rb', line 179

def ca_bundle_path
  if use_system_ssl_cert_chain? && File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
    OpenSSL::X509::DEFAULT_CERT_FILE
  else
    local_cert_path 
  end
end

#current_user_method=(null) ⇒ Object



191
# File 'lib/batbugger/configuration.rb', line 191

def current_user_method=(null) ; end

#filter_backtrace(&block) ⇒ Object



126
127
128
# File 'lib/batbugger/configuration.rb', line 126

def filter_backtrace(&block)
  self.backtrace_filters << block
end

#ignore_by_filter(&block) ⇒ Object



130
131
132
# File 'lib/batbugger/configuration.rb', line 130

def ignore_by_filter(&block)
  self.ignore_by_filters << block
end

#ignore_only=(names) ⇒ Object



134
135
136
# File 'lib/batbugger/configuration.rb', line 134

def ignore_only=(names)
  @ignore = [names].flatten
end

#ignore_user_agent_only=(names) ⇒ Object



138
139
140
# File 'lib/batbugger/configuration.rb', line 138

def ignore_user_agent_only=(names)
  @ignore_user_agent = [names].flatten
end

#local_cert_pathObject



187
188
189
# File 'lib/batbugger/configuration.rb', line 187

def local_cert_path
  File.expand_path(File.join("..", "..", "..", "resources", "ca-bundle.crt"), __FILE__)
end

#merge(hash) ⇒ Object



153
154
155
# File 'lib/batbugger/configuration.rb', line 153

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

#protocolObject



171
172
173
174
175
176
177
# File 'lib/batbugger/configuration.rb', line 171

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

#public?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/batbugger/configuration.rb', line 157

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

#to_hashObject



146
147
148
149
150
151
# File 'lib/batbugger/configuration.rb', line 146

def to_hash
  OPTIONS.inject({}) do |hash, option|
    hash[option.to_sym] = self.send(option)
    hash
  end
end