Module: RulesIO::Helpers

Included in:
Exceptions, Users
Defined in:
lib/rulesio/helpers.rb

Instance Method Summary collapse

Instance Method Details

#actor_for_exception(exception) ⇒ Object



23
24
25
# File 'lib/rulesio/helpers.rb', line 23

def actor_for_exception(exception)
  "#{exception.class.to_s}:#{fileline(exception)}"
end

#clean_backtrace(exception) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rulesio/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

#fileline(exception) ⇒ Object



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

def fileline(exception)
  fl = clean_backtrace(exception).first.match(/^(.*:.*):/)[1] rescue @app.to_s
  fl.gsub(/ \((.*)\) /, '-\1-')
end

#from_crawler(ignore_array, agent) ⇒ Object



3
4
5
6
7
8
# File 'lib/rulesio/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