Class: Chatterbox::ExceptionNotification::RailsExtracter
- Inherits:
-
Object
- Object
- Chatterbox::ExceptionNotification::RailsExtracter
- Defined in:
- lib/chatterbox/exception_notification/rails_extracter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #extract_rails_info(hash) ⇒ Object
- #extract_request_info(hash) ⇒ Object
- #filter_rails_root(hash) ⇒ Object
-
#initialize(notification) ⇒ RailsExtracter
constructor
A new instance of RailsExtracter.
- #notice ⇒ Object
- #rails_configuration ⇒ Object
- #rails_root ⇒ Object
Constructor Details
#initialize(notification) ⇒ RailsExtracter
Returns a new instance of RailsExtracter.
7 8 9 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 7 def initialize(notification) @notification = notification end |
Class Method Details
.wrap(notification = {}) ⇒ Object
3 4 5 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 3 def self.wrap(notification = {}) new(notification).notice end |
Instance Method Details
#extract_rails_info(hash) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 27 def extract_rails_info(hash) return hash if rails_configuration.nil? hash.merge({ :rails_info => { :rails_env => rails_configuration.env.to_s, :rails_root => rails_root, :rails_version => rails_configuration.version } }) end |
#extract_request_info(hash) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 38 def extract_request_info(hash) return hash unless hash.key?(:request) request = hash.delete(:request) hash.merge({ :request => { :url => request.url, :remote_ip => request.remote_ip, :parameters => request.parameters } }) end |
#filter_rails_root(hash) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 17 def filter_rails_root(hash) return hash unless hash[:backtrace] return hash if rails_root.blank? cleaner = ActiveSupport::BacktraceCleaner.new cleaner.add_filter { |line| line.gsub(rails_root, "[RAILS_ROOT]") } backtrace = cleaner.clean(hash[:backtrace]) hash[:backtrace] = backtrace hash end |
#notice ⇒ Object
11 12 13 14 15 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 11 def notice hsh = extract_rails_info(@notification) hsh = extract_request_info(hsh) filter_rails_root(hsh) end |
#rails_configuration ⇒ Object
54 55 56 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 54 def rails_configuration Object.const_get("Rails") if Object.const_defined?("Rails") end |
#rails_root ⇒ Object
50 51 52 |
# File 'lib/chatterbox/exception_notification/rails_extracter.rb', line 50 def rails_root rails_configuration.try(:root).to_s end |