Module: LoggedExceptionsHelper

Defined in:
app/helpers/logged_exceptions_helper.rb

Instance Method Summary collapse

Instance Method Details

#filtered?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/helpers/logged_exceptions_helper.rb', line 14

def filtered?
  [:query, :date_ranges_filter, :exception_names_filter, :controller_actions_filter].any? { |p| params[p] }
end

#listify(text) ⇒ Object



18
19
20
21
# File 'app/helpers/logged_exceptions_helper.rb', line 18

def listify(text)
  list_items = text.scan(/^\s*\* (.+)/).map {|match| (:li, match.first) }
  (:ul, list_items)
end

#page_title(text) ⇒ Object



23
24
25
26
27
28
29
30
# File 'app/helpers/logged_exceptions_helper.rb', line 23

def page_title(text)
  title = ""
  unless controller.application_name.blank?
    title << "#{controller.application_name} :: "
  end
  title << text.to_s
  content_for(:title, title.to_s)
end

#pretty_exception_date(exception) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/logged_exceptions_helper.rb', line 2

def pretty_exception_date(exception)
  if Date.today == exception.created_at.to_date
    if exception.created_at > Time.now - 4.hours
      "#{time_ago_in_words(exception.created_at).gsub(/about /,"~ ")} ago"
    else
      "Today, #{exception.created_at.strftime(Time::DATE_FORMATS[:exc_time])}"
    end
  else
    exception.created_at.strftime(Time::DATE_FORMATS[:exc_date])
  end
end

#pretty_format(text) ⇒ Object

Rescue textilize call if RedCloth is not available.



33
34
35
36
37
38
39
# File 'app/helpers/logged_exceptions_helper.rb', line 33

def pretty_format(text)
  begin
    textilize(text).html_safe
  rescue
    simple_format(text).html_safe
  end
end