Sha256: b663539ad42381cb95c7b4e51655dd0d23f32f39ed1a49f3b7941899fc78f7e4

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

require "erb"
require "rubycritic/report_generators/view_helpers"

module Rubycritic

  class BaseGenerator
    def self.erb_template(template_path)
      ERB.new(File.read(File.join(TEMPLATES_DIR, template_path)))
    end

    TEMPLATES_DIR = File.expand_path("../templates", __FILE__)
    LAYOUT_TEMPLATE = erb_template(File.join("layouts", "application.html.erb"))

    include ViewHelpers

    def file_href
      "file://#{file_pathname}"
    end

    def file_pathname
      File.join(file_directory, file_name)
    end

    def file_directory
      root_directory
    end

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

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

    def get_binding
      binding
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubycritic-0.0.12 lib/rubycritic/report_generators/base_generator.rb
rubycritic-0.0.11 lib/rubycritic/report_generators/base_generator.rb
rubycritic-0.0.10 lib/rubycritic/report_generators/base_generator.rb