Class: RubyCritic::Generator::Html::SimpleCovIndex

Inherits:
Base
  • Object
show all
Defined in:
lib/rubycritic/generators/html/simple_cov_index.rb

Constant Summary collapse

TEMPLATE =
erb_template('simple_cov_index.html.erb')

Constants inherited from Base

Base::LAYOUT_TEMPLATE, Base::TEMPLATES_DIR

Instance Method Summary collapse

Methods inherited from Base

erb_template, #file_directory, #file_href, #file_pathname

Methods included from ViewHelpers

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

Constructor Details

#initialize(analysed_modules) ⇒ SimpleCovIndex

Returns a new instance of SimpleCovIndex.


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

def initialize(analysed_modules)
  @analysed_modules = sorted(filtered(analysed_modules))
  set_header_links if Config.compare_branches_mode?
end

Instance Method Details

#file_nameObject


22
23
24
# File 'lib/rubycritic/generators/html/simple_cov_index.rb', line 22

def file_name
  'simple_cov_index.html'
end

#filtered(mods) ⇒ Object


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

def filtered(mods)
  mods.reject do |a_module|
    path = a_module.pathname.to_s
    path.start_with?('spec', 'test')
  end
end

#renderObject


26
27
28
29
# File 'lib/rubycritic/generators/html/simple_cov_index.rb', line 26

def render
  index_body = TEMPLATE.result(base_binding)
  LAYOUT_TEMPLATE.result(base_binding { index_body })
end

16
17
18
19
20
# File 'lib/rubycritic/generators/html/simple_cov_index.rb', line 16

def set_header_links
  @base_path = code_index_path(Config.base_root_directory, file_name)
  @feature_path = code_index_path(Config.feature_root_directory, file_name)
  @build_path = code_index_path(Config.compare_root_directory, file_name)
end

#sorted(mods) ⇒ Object


31
32
33
# File 'lib/rubycritic/generators/html/simple_cov_index.rb', line 31

def sorted(mods)
  mods.sort_by(&:coverage)
end