Module: Audits1984::ApplicationHelper
- Defined in:
- app/helpers/audits1984/application_helper.rb
Instance Method Summary collapse
- #auditor_name_for(auditor) ⇒ Object
- #format_date(date) ⇒ Object
- #format_date_and_time(date) ⇒ Object
- #highlight_code(source) ⇒ Object
- #highlighted_code_from(commands) ⇒ Object
- #sensitive_session_decoration(session) ⇒ Object
Instance Method Details
#auditor_name_for(auditor) ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/helpers/audits1984/application_helper.rb', line 6 def auditor_name_for(auditor) if auditor == Audits1984::Current.auditor "You" else auditor.public_send(Audits1984.auditor_name_attribute) end end |
#format_date(date) ⇒ Object
14 15 16 17 |
# File 'app/helpers/audits1984/application_helper.rb', line 14 def format_date(date) # <time datetime="2016-1-1">11:09 PM - 1 Jan 2016</time> date.strftime("%Y-%m-%d") end |
#format_date_and_time(date) ⇒ Object
19 20 21 22 |
# File 'app/helpers/audits1984/application_helper.rb', line 19 def format_date_and_time(date) # <time datetime="2016-1-1">11:09 PM - 1 Jan 2016</time> date.strftime("%Y-%m-%d at %I:%m %P") end |
#highlight_code(source) ⇒ Object
28 29 30 31 32 |
# File 'app/helpers/audits1984/application_helper.rb', line 28 def highlight_code(source) formatter = Rouge::Formatters::HTMLLinewise.new(Rouge::Formatters::HTML.new) lexer = Rouge::Lexers::Ruby.new formatter.format(lexer.lex(source)).html_safe end |
#highlighted_code_from(commands) ⇒ Object
24 25 26 |
# File 'app/helpers/audits1984/application_helper.rb', line 24 def highlighted_code_from(commands) highlight_code commands.collect(&:statements).collect(&:strip).filter(&:present?).join("\n") end |
#sensitive_session_decoration(session) ⇒ Object
34 35 36 |
# File 'app/helpers/audits1984/application_helper.rb', line 34 def sensitive_session_decoration(session) "*" if session.sensitive? end |