class ApplicationEnvironmentData

Attributes

exception[R]

Public Class Methods

new(exception) click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 4
def initialize(exception)
  @exception = exception
end

Public Instance Methods

data() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 8
def data
  {
    :application_environment =>
    {
      :environment => application_environment,
      :env => extract_environment(ENV),
      :host => get_hostname,
      :run_as_user => get_username,
      :application_root_directory => application_root_directory,
      :language => 'ruby',
      :language_version => language_version_string,
      :libraries_loaded => libraries_loaded
    }
  }
end

Private Instance Methods

application_environment() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 31
def application_environment
  config.application_environment
end
application_root() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 35
def application_root
  config.application_root
end
application_root_directory() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 26
def application_root_directory
  (application_root.to_s.respond_to?(:force_encoding) ?
   application_root.to_s.force_encoding("UTF-8") : application_root)
end
config() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 39
def config
  ErrorappNotifier.configuration
end
extract_environment(env) click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 43
def extract_environment(env)
  env.reject do |k, v|
    is_http_header = (k =~ /^HTTP_/)
    is_filtered = ErrorappNotifier::ENVIRONMENT_FILTER.include?(k)
    matches_whitelist = ErrorappNotifier::ENVIRONMENT_WHITELIST.
      any? do |whitelist_filter|
      whitelist_filter === k
    end
    is_http_header || is_filtered || !matches_whitelist
  end
end
get_hostname() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 55
def get_hostname
  require 'socket' unless defined?(Socket)
  Socket.gethostname
rescue
  'UNKNOWN'
end
get_username() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 62
def get_username
  ENV['LOGNAME'] || ENV['USER'] || ENV['USERNAME'] || ENV['APACHE_RUN_USER'] || 'UNKNOWN'
end
language_version_string() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 66
def language_version_string
  "#{RUBY_VERSION rescue '?.?.?'} p#{RUBY_PATCHLEVEL rescue '???'} #{RUBY_RELEASE_DATE rescue '????-??-??'} #{RUBY_PLATFORM rescue '????'}"
end
libraries_loaded() click to toggle source
# File lib/errorapp_notifier/application_environment_data.rb, line 70
def libraries_loaded
  begin
    return Hash[*Gem.loaded_specs.map{|name, gem_specification| [name, gem_specification.version.to_s]}.flatten]
  rescue
  end
  {}
end