Class: DeepCover::Reporter::HTML::Site
- Inherits:
-
Base
- Object
- Base
- DeepCover::Reporter::HTML::Site
show all
- Includes:
- Memoize
- Defined in:
- lib/deep_cover/reporter/html/site.rb
Instance Attribute Summary
Attributes inherited from Base
#options
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Memoize
#freeze, included
Methods inherited from Base
#analysis, #each, #initialize, #populate_stats
Class Method Details
.save(coverage, output:, **options) ⇒ Object
63
64
65
|
# File 'lib/deep_cover/reporter/html/site.rb', line 63
def self.save(coverage, output:, **options)
Site.new(coverage, output: output, **options).save
end
|
Instance Method Details
#clear ⇒ Object
24
25
26
27
28
|
# File 'lib/deep_cover/reporter/html/site.rb', line 24
def clear
path.mkpath
path.rmtree
path.mkpath
end
|
#compile_stylesheet(source, dest) ⇒ Object
30
31
32
33
|
# File 'lib/deep_cover/reporter/html/site.rb', line 30
def compile_stylesheet(source, dest)
css = Sass::Engine.for_file(source, style: :expanded).to_css
File.write(dest, css)
end
|
#path ⇒ Object
13
14
15
|
# File 'lib/deep_cover/reporter/html/site.rb', line 13
def path
Pathname(options[:output])
end
|
#render_index ⇒ Object
35
36
37
|
# File 'lib/deep_cover/reporter/html/site.rb', line 35
def render_index
Tools.render_template(:index, Index.new(self))
end
|
#render_source(partial_path, covered_code) ⇒ Object
51
52
53
|
# File 'lib/deep_cover/reporter/html/site.rb', line 51
def render_source(partial_path, covered_code)
Tools.render_template(:source, Source.new(analysis.analyser_map.fetch(covered_code), partial_path))
end
|
#save ⇒ Object
17
18
19
20
21
22
|
# File 'lib/deep_cover/reporter/html/site.rb', line 17
def save
clear
save_assets
save_index
save_pages
end
|
#save_assets ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/deep_cover/reporter/html/site.rb', line 43
def save_assets
require 'fileutils'
src = "#{__dir__}/template/assets"
dest = path.join('assets')
FileUtils.cp_r(src, dest)
dest.join('deep_cover.css.sass').delete
end
|
#save_index ⇒ Object
39
40
41
|
# File 'lib/deep_cover/reporter/html/site.rb', line 39
def save_index
path.join('index.html').write(render_index)
end
|
#save_pages ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/deep_cover/reporter/html/site.rb', line 55
def save_pages
each do |partial_path, covered_code|
dest = path.join("#{partial_path}.html")
dest.dirname.mkpath
dest.write(render_source(partial_path, covered_code))
end
end
|