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
- .get_hostname ⇒ Object
- .get_username ⇒ Object
- .language_version_string ⇒ Object
- .libraries_loaded ⇒ Object
- .to_hash(framework) ⇒ Object
Class Method Details
.application_root ⇒ Object
30 31 32 |
# File 'lib/exceptional/application_environment.rb', line 30 def self.application_root Config.application_root end |
.environment ⇒ Object
26 27 28 |
# File 'lib/exceptional/application_environment.rb', line 26 def self.environment Config.application_environment end |
.extract_environment(env) ⇒ Object
34 35 36 37 38 |
# File 'lib/exceptional/application_environment.rb', line 34 def self.extract_environment(env) env.reject do |k, v| (k =~ /^HTTP_/) || Exceptional::ENVIRONMENT_FILTER.include?(k) end end |
.get_hostname ⇒ Object
40 41 42 43 44 45 |
# File 'lib/exceptional/application_environment.rb', line 40 def self.get_hostname require 'socket' unless defined?(Socket) Socket.gethostname rescue 'UNKNOWN' end |
.get_username ⇒ Object
51 52 53 |
# File 'lib/exceptional/application_environment.rb', line 51 def self.get_username ENV['LOGNAME'] || ENV['USER'] || ENV['USERNAME'] || ENV['APACHE_RUN_USER'] || 'UNKNOWN' end |
.language_version_string ⇒ Object
47 48 49 |
# File 'lib/exceptional/application_environment.rb', line 47 def self.language_version_string "#{RUBY_VERSION rescue '?.?.?'} p#{RUBY_PATCHLEVEL rescue '???'} #{RUBY_RELEASE_DATE rescue '????-??-??'} #{RUBY_PLATFORM rescue '????'}" end |
.libraries_loaded ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/exceptional/application_environment.rb', line 55 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(framework) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/exceptional/application_environment.rb', line 5 def self.to_hash(framework) { '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.to_s.respond_to?(:force_encoding) ? application_root.to_s.force_encoding("UTF-8") : application_root), 'language' => 'ruby', 'language_version' => language_version_string, 'framework' => framework, 'libraries_loaded' => libraries_loaded } } end |