Sha256: dc39ffb397f068eca981a047fa53e96414e77af79a6558a236f57c0ff4e760dd

Contents?: true

Size: 1.39 KB

Versions: 21

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

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 image_path(file)
      asset_path("images/#{file}")
    end

    def file_path(file)
      relative_path(file)
    end

    def smell_location_path(location)
      smell_location = "#{location.pathname.sub_ext('.html')}#L#{location.line}"
      if Config.compare_branches_mode?
        file_path("#{File.expand_path(Config.feature_root_directory)}/#{smell_location}")
      else
        file_path(smell_location)
      end
    end

    def code_index_path(root_directory, file_name)
      file_path("#{File.expand_path(root_directory)}/#{file_name}")
    end

    private

    def relative_path(file)
      (root_directory + file).relative_path_from(file_directory)
    end

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

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

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
rubycritic-4.5.2 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.5.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.5.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.4.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.4.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.3.3 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.3.2 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.3.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.3.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.2.2 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.2.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.2.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-simplecov-4.1.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-simplecov-4.1.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.1.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.0.2 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.0.1 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-4.0.0 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-3.5.2 lib/rubycritic/generators/html/view_helpers.rb
rubycritic-3.5.1 lib/rubycritic/generators/html/view_helpers.rb