Sha256: 7579f4778b508d779634cb8e4064f6baa8ae42c2513f91e255ca8f92483ec8d6

Contents?: true

Size: 995 Bytes

Versions: 12

Compression:

Stored size: 995 Bytes

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(file)
      relative_path("assets/#{file}")
    end

    def file_path(file)
      relative_path(file)
    end

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

    private

    def relative_path(file)
      (root_directory + file).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

12 entries across 12 versions & 1 rubygems

Version Path
rubycritic-2.6.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.5.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.4.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.4.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.3.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.2.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.1.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-2.0.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-1.4.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-1.3.0 lib/rubycritic/report_generators/view_helpers.rb
rubycritic-1.2.1 lib/rubycritic/report_generators/view_helpers.rb
rubycritic-1.2.0 lib/rubycritic/report_generators/view_helpers.rb