Class: RubyCritic::Generator::Html::Base

Inherits:
Object
  • Object
show all
Includes:
ViewHelpers
Defined in:
lib/rubycritic/generators/html/base.rb

Direct Known Subclasses

CodeFile, CodeIndex, Line, Overview, SimpleCovIndex, SmellsIndex

Constant Summary collapse

TEMPLATES_DIR =
File.expand_path('templates', __dir__)
LAYOUT_TEMPLATE =
erb_template(File.join('layouts', 'application.html.erb'))

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ViewHelpers

#asset_path, #code_index_path, #file_path, #smell_location_path, #timeago_tag

Class Method Details

.erb_template(template_path) ⇒ Object



11
12
13
# File 'lib/rubycritic/generators/html/base.rb', line 11

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

Instance Method Details

#file_directoryObject



28
29
30
# File 'lib/rubycritic/generators/html/base.rb', line 28

def file_directory
  @file_directory ||= root_directory
end

#file_hrefObject



20
21
22
# File 'lib/rubycritic/generators/html/base.rb', line 20

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

#file_nameObject

Raises:

  • (NotImplementedError)


32
33
34
35
# File 'lib/rubycritic/generators/html/base.rb', line 32

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

#file_pathnameObject



24
25
26
# File 'lib/rubycritic/generators/html/base.rb', line 24

def file_pathname
  File.join(file_directory, file_name)
end

#renderObject

Raises:

  • (NotImplementedError)


37
38
39
40
# File 'lib/rubycritic/generators/html/base.rb', line 37

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