Class: CIAT::Feedback::HtmlFeedback

Inherits:
Object
  • Object
show all
Includes:
ERBHelpers, IO
Defined in:
lib/ciat/feedback/html_feedback.rb

Constant Summary

Constants included from IO

IO::OUTPUT_FOLDER, IO::REPORT_FILENAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IO

#read_file, #write_file

Methods included from ERBHelpers

#light_to_sentence, #light_to_word, #new_grouping?, #render, #replace_tabs, #title

Constructor Details

#initialize(counter, options) ⇒ HtmlFeedback

Returns a new instance of HtmlFeedback.



13
14
15
16
17
18
# File 'lib/ciat/feedback/html_feedback.rb', line 13

def initialize(counter, options)
  @counter = counter
  builder = CIAT::Feedback::HtmlFeedbackBuilder.new(options)
  @report_title = builder.build_report_title
  @report_filename = builder.build_report_filename
end

Instance Attribute Details

#report_filenameObject (readonly)

Returns the value of attribute report_filename.



11
12
13
# File 'lib/ciat/feedback/html_feedback.rb', line 11

def report_filename
  @report_filename
end

#report_titleObject (readonly)

Returns the value of attribute report_title.



10
11
12
# File 'lib/ciat/feedback/html_feedback.rb', line 10

def report_title
  @report_title
end

Instance Method Details

#build_erbObject



45
46
47
48
49
# File 'lib/ciat/feedback/html_feedback.rb', line 45

def build_erb
  e = ERB.new(template)
  e.filename = "report.html.erb"
  e
end

#generate_html(suite) ⇒ Object

:nodoc:



37
38
39
40
41
42
43
# File 'lib/ciat/feedback/html_feedback.rb', line 37

def generate_html(suite) #:nodoc:
  processors = suite.processors
  results = suite.results
  size = suite.size
  counter = @counter
  build_erb.result(binding)
end

#post_tests(suite) ⇒ Object



30
31
32
33
34
35
# File 'lib/ciat/feedback/html_feedback.rb', line 30

def post_tests(suite)
  write_file(
    report_filename, 
    generate_html(suite)
    )
end

#pre_tests(suite) ⇒ Object



20
21
22
23
24
# File 'lib/ciat/feedback/html_feedback.rb', line 20

def pre_tests(suite)
  FileUtils.mkdir_p(suite.output_folder)
  FileUtils.cp(File.join(File.dirname(__FILE__), "..", "..", "data", "ciat.css"), suite.output_folder)
  FileUtils.cp(File.join(File.dirname(__FILE__), "..", "..", "data", "prototype.js"), suite.output_folder)
end

#report_subresult(processor) ⇒ Object



26
27
28
# File 'lib/ciat/feedback/html_feedback.rb', line 26

def report_subresult(processor)
  nil
end

#templateObject

:nodoc:



51
52
53
54
55
# File 'lib/ciat/feedback/html_feedback.rb', line 51

def template #:nodoc:
  File.read(File.join(
    File.dirname(__FILE__), "..", "..", "templates", "report.html.erb"
    ))
end