Module: ExceptionHub::Configuration

Included in:
ExceptionHub
Defined in:
lib/exception_hub/configuration.rb

Constant Summary collapse

IGNORED_EXCEPTIONS_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

Instance Attribute Details

#after_create_exception_callbacksArray<Proc> (readonly)

Returns Callbacks after the exception is created.

Returns:

  • (Array<Proc>)

    Callbacks after the exception is created



32
33
34
# File 'lib/exception_hub/configuration.rb', line 32

def after_create_exception_callbacks
  @after_create_exception_callbacks
end

#before_create_exception_callbacksArray<Proc> (readonly)

Returns Callbacks before the exception is created.

Returns:

  • (Array<Proc>)

    Callbacks before the exception is created



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

def before_create_exception_callbacks
  @before_create_exception_callbacks
end

#github_api_tokenString

Returns Github token to make API calls with.

Returns:

  • (String)

    Github token to make API calls with



28
29
30
# File 'lib/exception_hub/configuration.rb', line 28

def github_api_token
  @github_api_token
end

#github_user_nameString

Returns Github username for the user account that will make the API calls.

Returns:

  • (String)

    Github username for the user account that will make the API calls



16
17
18
# File 'lib/exception_hub/configuration.rb', line 16

def github_user_name
  @github_user_name
end

#ignored_exceptionsArray<String>

Returns Exception types as strings of the message to ignore.

Returns:

  • (Array<String>)

    Exception types as strings of the message to ignore



40
41
42
# File 'lib/exception_hub/configuration.rb', line 40

def ignored_exceptions
  @ignored_exceptions
end

#loggerLogger

Returns Logger to send output messages to.

Returns:

  • (Logger)

    Logger to send output messages to



48
49
50
# File 'lib/exception_hub/configuration.rb', line 48

def logger
  @logger
end

#repo_nameString

Returns Name of the Github repository.

Returns:

  • (String)

    Name of the Github repository



12
13
14
# File 'lib/exception_hub/configuration.rb', line 12

def repo_name
  @repo_name
end

#repo_ownerString

Returns Name of the user or organization that hosts the repository.

Returns:

  • (String)

    Name of the user or organization that hosts the repository



20
21
22
# File 'lib/exception_hub/configuration.rb', line 20

def repo_owner
  @repo_owner
end

#reporting_environmentsArray<Symbol>

Returns Environments to send exceptions from.

Returns:

  • (Array<Symbol>)

    Environments to send exceptions from



44
45
46
# File 'lib/exception_hub/configuration.rb', line 44

def reporting_environments
  @reporting_environments
end

#send_all_exceptionsBoolean

Returns If true, sends all exceptions to Github including duplicates.

Returns:

  • (Boolean)

    If true, sends all exceptions to Github including duplicates.



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

def send_all_exceptions
  @send_all_exceptions
end

Instance Method Details

#after_create_exception(&block) ⇒ Object



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

def after_create_exception(&block)
  @after_create_exception_callbacks << block if block
end

#before_create_exception(&block) ⇒ Object



77
78
79
# File 'lib/exception_hub/configuration.rb', line 77

def before_create_exception(&block)
  @before_create_exception_callbacks << block if block
end

#configure {|config| ... } ⇒ Object Also known as: config

Provides configuration block for ExceptionHub

Examples:

ExceptionHub.configure do |config|
  config.repo_name = 'exception_hub'
  # ...
end

Yields:

  • (config)

    Current instance of ExceptionHub::Configuration



58
59
60
61
62
# File 'lib/exception_hub/configuration.rb', line 58

def configure
  define_defaults
  yield(self) if block_given?
  true
end

#define_defaultsObject



65
66
67
68
69
70
71
# File 'lib/exception_hub/configuration.rb', line 65

def define_defaults
  @after_create_exception_callbacks ||= []
  @before_create_exception_callbacks ||= []
  @ignored_exceptions ||= IGNORED_EXCEPTIONS_DEFAULT.dup
  @reporting_environments ||= [:production]
  @logger ||= defined?(::Rails) && ::Rails.logger || Logger.new(STDOUT)
end