Class: Exceptional::ApplicationEnvironment
- Inherits:
-
Object
- Object
- Exceptional::ApplicationEnvironment
- Defined in:
- lib/exceptional/application_environment.rb
Class Method Summary collapse
- .application_root ⇒ Object
- .environment ⇒ Object
- .extract_environment(env) ⇒ Object
- .framework ⇒ Object
- .get_hostname ⇒ Object
- .get_username ⇒ Object
- .libraries_loaded ⇒ Object
- .to_hash ⇒ Object
Class Method Details
.application_root ⇒ Object
35 36 37 |
# File 'lib/exceptional/application_environment.rb', line 35 def self.application_root Config.application_root end |
.environment ⇒ Object
31 32 33 |
# File 'lib/exceptional/application_environment.rb', line 31 def self.environment Config.application_environment end |
.extract_environment(env) ⇒ Object
39 40 41 |
# File 'lib/exceptional/application_environment.rb', line 39 def self.extract_environment(env) env.reject{|k, v| k =~ /^HTTP_/} end |
.framework ⇒ Object
27 28 29 |
# File 'lib/exceptional/application_environment.rb', line 27 def self.framework defined?(RAILS_ENV) ? "rails" : nil end |
.get_hostname ⇒ Object
43 44 45 46 47 48 |
# File 'lib/exceptional/application_environment.rb', line 43 def self.get_hostname require 'socket' unless defined?(Socket) Socket.gethostname rescue 'UNKNOWN' end |
.get_username ⇒ Object
50 51 52 |
# File 'lib/exceptional/application_environment.rb', line 50 def self.get_username ENV['LOGNAME'] || ENV['USER'] || ENV['USERNAME'] || ENV['APACHE_RUN_USER'] || 'UNKNOWN' end |
.libraries_loaded ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/exceptional/application_environment.rb', line 54 def self.libraries_loaded begin return Hash[*Gem.loaded_specs.map{|name, gem_specification| [name, gem_specification.version.to_s]}.flatten] rescue end {} end |
.to_hash ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/exceptional/application_environment.rb', line 5 def self.to_hash hash = { 'client' => { 'name' => Exceptional::CLIENT_NAME, 'version' => Exceptional::VERSION, 'protocol_version' => Exceptional::PROTOCOL_VERSION }, 'application_environment' => { 'environment' => environment, 'env' => extract_environment(ENV), 'host' => get_hostname, 'run_as_user' => get_username, 'application_root_directory' => application_root, 'language' => 'ruby', 'language_version' => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} #{RUBY_RELEASE_DATE} #{RUBY_PLATFORM}", 'framework' => framework, 'libraries_loaded' => libraries_loaded } } hash end |