Sha256: 0e1d06349b1914d3042c2053431b515776c22eea54f705af5c3899c69eb8fb96

Contents?: true

Size: 822 Bytes

Versions: 2

Compression:

Stored size: 822 Bytes

Contents

require "rouge"
require "rails_rinku"

module Audits1984
  module ApplicationHelper
    def format_date(date)
      # <time datetime="2016-1-1">11:09 PM - 1 Jan 2016</time>
      date.strftime("%Y-%m-%d")
    end

    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

    def highlighted_code_from(commands)
      highlight_code commands.collect(&:statements).collect(&:strip).filter(&:present?).join("\n")
    end

    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

    def sensitive_session_decoration(session)
      "*" if session.sensitive?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
audits1984-0.1.1 app/helpers/audits1984/application_helper.rb
audits1984-0.1.0 app/helpers/audits1984/application_helper.rb