class RubyCritic::Generator::Html::CodeFile
Constants
- LINE_NUMBER_OFFSET
- TEMPLATE
Public Class Methods
new(analysed_module)
click to toggle source
# File lib/rubycritic/generators/html/code_file.rb, line 13 def initialize(analysed_module) @analysed_module = analysed_module @pathname = @analysed_module.pathname set_header_links if Config.compare_branches_mode? end
Public Instance Methods
file_directory()
click to toggle source
# File lib/rubycritic/generators/html/code_file.rb, line 25 def file_directory @file_directory ||= root_directory + @pathname.dirname end
file_location()
click to toggle source
# File lib/rubycritic/generators/html/code_file.rb, line 33 def file_location @pathname.sub_ext('.html') end
file_name()
click to toggle source
# File lib/rubycritic/generators/html/code_file.rb, line 29 def file_name @pathname.basename.sub_ext('.html') end
render()
click to toggle source
# File lib/rubycritic/generators/html/code_file.rb, line 37 def render file_code = [] File.readlines(@pathname).each.with_index(LINE_NUMBER_OFFSET) do |line_text, line_number| location = Location.new(@pathname, line_number) line_smells = @analysed_module.smells_at_location(location) file_code << Line.new(file_directory, line_text, line_smells).render end file_body = TEMPLATE.result(base_binding { file_code.join }) LAYOUT_TEMPLATE.result(base_binding { file_body }) end
set_header_links()
click to toggle source
# File lib/rubycritic/generators/html/code_file.rb, line 19 def set_header_links @base_path = code_index_path(Config.base_root_directory, file_location) @feature_path = code_index_path(Config.feature_root_directory, file_location) @build_path = code_index_path(Config.compare_root_directory, file_location) end