Sha256: 43119d9291214cc6f0e809acfe900ba3550e271572129ade9ae8176ebeebb9cd

Contents?: true

Size: 1.21 KB

Versions: 25

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

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', __dir__)
        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,
                "The #{self.class} class must implement the #{__method__} method."
        end

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

        private

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

        def base_binding
          binding
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
rubycritic-4.9.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.9.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.8.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.8.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.7.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.6.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.6.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.5.2 lib/rubycritic/generators/html/base.rb
rubycritic-4.5.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.5.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.4.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.4.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.3.3 lib/rubycritic/generators/html/base.rb
rubycritic-4.3.2 lib/rubycritic/generators/html/base.rb
rubycritic-4.3.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.3.0 lib/rubycritic/generators/html/base.rb
rubycritic-4.2.2 lib/rubycritic/generators/html/base.rb
rubycritic-4.2.1 lib/rubycritic/generators/html/base.rb
rubycritic-4.2.0 lib/rubycritic/generators/html/base.rb
rubycritic-simplecov-4.1.1 lib/rubycritic/generators/html/base.rb