Class: Similatron::HtmlReport

Inherits:
Object
  • Object
show all
Defined in:
lib/similatron/html_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(run) ⇒ HtmlReport

Returns a new instance of HtmlReport.



6
7
8
9
# File 'lib/similatron/html_report.rb', line 6

def initialize(run)
  @run = run
  @time = Time.now
end

Instance Attribute Details

#runObject (readonly)

Returns the value of attribute run.



4
5
6
# File 'lib/similatron/html_report.rb', line 4

def run
  @run
end

Instance Method Details

#css_stylesObject



17
18
19
20
21
22
# File 'lib/similatron/html_report.rb', line 17

def css_styles
  ["normalize.css", "skeleton.css"].map do |file|
    css_path = File.join(Similatron.lib_path, "assets/Skeleton-2.0.4/css", file)
    File.read(css_path)
  end
end

#failures?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/similatron/html_report.rb', line 36

def failures?
  !run.failed_comparisons.empty?
end

#full_path(path) ⇒ Object



24
25
26
# File 'lib/similatron/html_report.rb', line 24

def full_path(path)
  File.expand_path(path)
end

#ok?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/similatron/html_report.rb', line 40

def ok?
  !overwrites? && !failures?
end

#overwrites?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/similatron/html_report.rb', line 32

def overwrites?
  !run.overwrite_comparisons.empty?
end

#renderObject



11
12
13
14
15
# File 'lib/similatron/html_report.rb', line 11

def render
  template_path = File.join(Similatron.lib_path, "assets/report.html.erb")
  template = ERB.new(File.read(template_path))
  template.result(binding)
end

#run_atObject



28
29
30
# File 'lib/similatron/html_report.rb', line 28

def run_at
  @time.strftime("%b %d, %Y %H:%M")
end