Sha256: f2692339802fd9351a68b3375075992e22fdec8c6160b226c434a38ef26efcfb

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Rubycritic

  module ViewHelpers
    def timeago_tag(time)
      "<time class='js-timeago' datetime='#{time}'>#{time}</time>"
    end

    def javascript_tag(file)
      "<script src='" + asset_path("javascripts", "#{file}.js").to_s + "'></script>"
    end

    def stylesheet_path(file)
      asset_path("stylesheets", "#{file}.css")
    end

    def asset_path(*fragments)
      relative_path(([root_directory, "assets"] + fragments).reduce(:+))
    end

    def file_path(file)
      relative_path(root_directory + file)
    end

    def smell_location_path(location)
      file_path("#{location.pathname.sub_ext('.html')}#L#{location.line}")
    end

    private

    def relative_path(pathname)
      pathname.relative_path_from(file_directory)
    end

    def file_directory
      raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
    end

    def root_directory
      raise NotImplementedError.new("The #{self.class} class must implement the #{__method__} method.")
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubycritic-1.0.2 lib/rubycritic/report_generators/view_helpers.rb
rubycritic-1.0.1 lib/rubycritic/report_generators/view_helpers.rb
rubycritic-1.0.0 lib/rubycritic/report_generators/view_helpers.rb