Module: RailsPerformanceHelper
- Defined in:
- app/helpers/rails_performance_helper.rb
Instance Method Summary collapse
- #active?(section) ⇒ Boolean
- #format_datetime(e) ⇒ Object
- #insert_css_file(file) ⇒ Object
- #insert_js_file(file) ⇒ Object
- #round_it(value) ⇒ Object
- #statistics_link(title, report, group) ⇒ Object
- #stats_icon ⇒ Object
- #status_tag(status) ⇒ Object
Instance Method Details
#active?(section) ⇒ Boolean
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/helpers/rails_performance_helper.rb', line 61 def active?(section) case section when :dashboard "is-active" if controller_name == "rails_performance" && action_name == "index" when :crashes "is-active" if controller_name == "rails_performance" && action_name == "crashes" when :requests "is-active" if controller_name == "rails_performance" && action_name == "requests" when :recent "is-active" if controller_name == "rails_performance" && action_name == "recent" end end |
#format_datetime(e) ⇒ Object
57 58 59 |
# File 'app/helpers/rails_performance_helper.rb', line 57 def format_datetime(e) e.strftime("%Y-%m-%d %H:%M:%S") end |
#insert_css_file(file) ⇒ Object
49 50 51 |
# File 'app/helpers/rails_performance_helper.rb', line 49 def insert_css_file(file) raw "<style>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../views/stylesheets/#{file}")}</style>" end |
#insert_js_file(file) ⇒ Object
53 54 55 |
# File 'app/helpers/rails_performance_helper.rb', line 53 def insert_js_file(file) raw "<script>#{raw File.read File.expand_path(File.dirname(__FILE__) + "/../views/javascripts/#{file}")}</script>" end |
#round_it(value) ⇒ Object
2 3 4 5 6 7 |
# File 'app/helpers/rails_performance_helper.rb', line 2 def round_it(value) return nil unless value return value if value.is_a?(Integer) value.nan? ? nil : value.round(2) end |
#statistics_link(title, report, group) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/rails_performance_helper.rb', line 9 def statistics_link(title, report, group) = case report.group when :controller_action_format ca = group.split("|") c, a = ca[0].split("#") { controller_eq: c, action_eq: a, format_eq: ca[1] } else {} end link_to title, rails_performance_path(), target: '_blank' end |
#stats_icon ⇒ Object
44 45 46 47 |
# File 'app/helpers/rails_performance_helper.rb', line 44 def stats_icon # https://www.iconfinder.com/iconsets/vivid raw File.read(File.(File.dirname(__FILE__) + "/../assets/images/stat.svg")) end |
#status_tag(status) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/helpers/rails_performance_helper.rb', line 26 def status_tag(status) klass = case status.to_s when /^5/ "tag is-danger" when /^4/ "tag is-warning" when /^3/ "tag is-info" when /^2/ "tag is-success" else nil end content_tag(:span, class: klass) do status end end |