class Rnotifier::Config
Constants
- CLIENT
- DEFAULT
Attributes
api_host[RW]
api_key[RW]
app_env[RW]
capture_code[RW]
current_env[RW]
environments[RW]
event_path[RW]
exception_path[RW]
ignore_bots[RW]
ignore_exceptions[RW]
valid[RW]
Public Class Methods
[](val)
click to toggle source
# File lib/rnotifier/config.rb, line 19 def [](val) DEFAULT[val] end
app_root()
click to toggle source
# File lib/rnotifier/config.rb, line 82 def app_root (defined?(Rails) && Rails.respond_to?(:root)) ? Rails.root.to_s : Dir.pwd end
get_app_env()
click to toggle source
# File lib/rnotifier/config.rb, line 63 def get_app_env { :env => self.current_env, :pid => $$, :host => (Socket.gethostname rescue ''), :user_name => ENV['USER'] || ENV['USERNAME'], :program_name => $PROGRAM_NAME, :app_root => self.app_root, :language => { :name => 'ruby', :version => "#{(RUBY_VERSION rescue '')}-p#{(RUBY_PATCHLEVEL rescue '')}", :platform => (RUBY_PLATFORM rescue ''), :ruby_path => Gem.ruby, :gem_path => Gem.path }, :timezone => (Time.now.zone rescue nil) } end
init()
click to toggle source
# File lib/rnotifier/config.rb, line 23 def init Rlogger.init self.valid = false self.current_env = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development' self.environments ||= [] if self.environments.is_a?(String) || self.environments.is_a?(Symbol) self.environments = self.environments.to_s.split(',').collect(&:strip) end #Return if config environments not include current env return if !self.environments.empty? && !self.environments.include?(self.current_env) #Check for ignore env if DEFAULT[:ignore_env].include?(self.current_env) && !self.environments.include?(self.current_env) return end if self.api_key.nil? and !ENV['RNOTIFIER_API_KEY'].nil? self.api_key = ENV['RNOTIFIER_API_KEY'] end return if self.api_key.to_s.length == 0 self.api_host ||= DEFAULT[:api_host] self.exception_path = '/' + [DEFAULT[:api_version], DEFAULT[:exception_path]].join('/') self.app_env = get_app_env self.ignore_exceptions = self.ignore_exceptions.split(',').map(&:strip) if self.ignore_exceptions.is_a?(String) self.ignore_bots = self.ignore_bots.split(',').map(&:strip) if self.ignore_bots.is_a?(String) self.event_path = '/' + [DEFAULT[:api_version], DEFAULT[:event_path]].join('/') self.valid = true end
valid?()
click to toggle source
# File lib/rnotifier/config.rb, line 59 def valid? self.valid end