Module: WhenAUser::Helpers

Included in:
Exceptions, Pageviews
Defined in:
lib/whenauser/helpers.rb

Instance Method Summary collapse

Instance Method Details

#actor_for_exception(exception) ⇒ Object



18
19
20
21
22
# File 'lib/whenauser/helpers.rb', line 18

def actor_for_exception(exception)
  backtrace = clean_backtrace(exception)
  fileline = backtrace.first.match(/^(.*:.*):/)[1] rescue @app.to_s
  "#{exception.class.to_s}:#{fileline}"
end

#clean_backtrace(exception) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/whenauser/helpers.rb', line 10

def clean_backtrace(exception)
  if defined?(Rails) && Rails.respond_to?(:backtrace_cleaner)
    Rails.backtrace_cleaner.send(:filter, exception.backtrace)
  else
    exception.backtrace
  end
end

#from_crawler(ignore_array, agent) ⇒ Object



3
4
5
6
7
8
# File 'lib/whenauser/helpers.rb', line 3

def from_crawler(ignore_array, agent)
  ignore_array.each do |crawler|
    return true if (agent =~ /\b(#{crawler})\b/i)
  end unless ignore_array.blank?
  false
end