Class: Zucchini::Reporter::HTML

Inherits:
Object
  • Object
show all
Defined in:
lib/zucchini/reporters/html.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(features, ci) ⇒ HTML

Returns a new instance of HTML.



13
14
15
16
17
18
# File 'lib/zucchini/reporters/html.rb', line 13

def initialize(features, ci)
  @features = features
  @device   = features[0].device
  @time     = Time.now.strftime("%T, %e %B %Y")
  @ci       = ci ? 'ci' : ''
end

Class Method Details

.generate(features, report_path, ci) ⇒ Object



8
9
10
11
# File 'lib/zucchini/reporters/html.rb', line 8

def self.generate(features, report_path, ci)
  Zucchini::Reporter::HTML.new(features, ci).write(report_path)
  "HTML report generated to #{report_path}"
end

Instance Method Details

#write(report_path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zucchini/reporters/html.rb', line 20

def write(report_path)
  template_path  = "#{File.dirname(__FILE__)}/html/template.erb.html"
  gem_assets_dir = "#{File.dirname(__FILE__)}/html"

  files_path = report_path.chomp(File.extname report_path) + '_files'

  @assets_path = copy_assets(gem_assets_dir, "#{files_path}/assets", report_path)
  @features    = copy_images(@features,      "#{files_path}/images", report_path)

  File.open(report_path, 'w+') do |f|
    f.write ERB.new(File.read(template_path)).result(binding)
  end
end