Class: Rubycritic::BaseGenerator

Inherits:
Object
  • Object
show all
Includes:
ViewHelpers
Defined in:
lib/rubycritic/report_generators/base_generator.rb

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ViewHelpers

#analysed_file_name, #asset_path, #code_index_path, #javascript_path, #overview_path, #root_directory, #smell_location_path, #smells_index_path, #stylesheet_path

Class Method Details

.erb_template(template_path) ⇒ Object



7
8
9
# File 'lib/rubycritic/report_generators/base_generator.rb', line 7

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

Instance Method Details

#file_directoryObject



24
25
26
# File 'lib/rubycritic/report_generators/base_generator.rb', line 24

def file_directory
  root_directory
end

#file_hrefObject



16
17
18
# File 'lib/rubycritic/report_generators/base_generator.rb', line 16

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

#file_nameObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/rubycritic/report_generators/base_generator.rb', line 28

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

#file_pathnameObject



20
21
22
# File 'lib/rubycritic/report_generators/base_generator.rb', line 20

def file_pathname
  File.join(file_directory, file_name)
end

#get_bindingObject



36
37
38
# File 'lib/rubycritic/report_generators/base_generator.rb', line 36

def get_binding
  binding
end

#renderObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/rubycritic/report_generators/base_generator.rb', line 32

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