Sha256: 884bd524ec24d302d141522d89f3650f497ab935b680491046c85326cfcbe68e

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

require "erb"
require "pathname"
require "rubycritic/generators/html/view_helpers"

module Rubycritic
  module Generator
    module Html

      class Base
        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
          @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

        private

        def root_directory
          @root_directory ||= Pathname.new(Config.root)
        end

        def get_binding
          binding
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubycritic-2.6.0 lib/rubycritic/generators/html/base.rb
rubycritic-2.5.0 lib/rubycritic/generators/html/base.rb
rubycritic-2.4.1 lib/rubycritic/generators/html/base.rb
rubycritic-2.4.0 lib/rubycritic/generators/html/base.rb
rubycritic-2.3.0 lib/rubycritic/generators/html/base.rb
rubycritic-2.2.0 lib/rubycritic/generators/html/base.rb
rubycritic-2.1.0 lib/rubycritic/generators/html/base.rb
rubycritic-2.0.0 lib/rubycritic/generators/html/base.rb
rubycritic-1.4.0 lib/rubycritic/generators/html/base.rb