Class: GreenPepper::HtmlWriter
- Inherits:
-
Object
- Object
- GreenPepper::HtmlWriter
- Defined in:
- lib/greenpepper/writer/htmlwriter.rb
Instance Attribute Summary collapse
-
#execution_units ⇒ Object
readonly
Returns the value of attribute execution_units.
Instance Method Summary collapse
-
#initialize ⇒ HtmlWriter
constructor
A new instance of HtmlWriter.
- #load_document(base_html, execution_units, write_options = {}) ⇒ Object
- #output ⇒ Object
- #support?(execution_unit) ⇒ Boolean
- #write(base_html, execution_units, write_options = {}) ⇒ Object
Constructor Details
#initialize ⇒ HtmlWriter
Returns a new instance of HtmlWriter.
16 17 |
# File 'lib/greenpepper/writer/htmlwriter.rb', line 16 def initialize end |
Instance Attribute Details
#execution_units ⇒ Object (readonly)
Returns the value of attribute execution_units.
14 15 16 |
# File 'lib/greenpepper/writer/htmlwriter.rb', line 14 def execution_units @execution_units end |
Instance Method Details
#load_document(base_html, execution_units, write_options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/greenpepper/writer/htmlwriter.rb', line 27 def load_document(base_html, execution_units, = {}) @html_doc = (LibXML::XML::HTMLParser.string base_html, :encoding => LibXML::XML::Encoding::UTF_8, :options => LibXML::XML::HTMLParser::Options::NOBLANKS).parse @execution_units = execution_units @tables = @html_doc.find('//table').to_a @write_options = nb_results_table = 0 @execution_units.each{ |unit| nb_results_table += unit.context.nb_table } if @tables.size != nb_results_table raise "Execution results doesn't have the same number of html " + "table than the file" end end |
#output ⇒ Object
19 20 21 |
# File 'lib/greenpepper/writer/htmlwriter.rb', line 19 def output @html_doc.to_s end |
#support?(execution_unit) ⇒ Boolean
23 24 25 |
# File 'lib/greenpepper/writer/htmlwriter.rb', line 23 def support? execution_unit execution_unit.result.is_a? HtmlTableExecutionResults end |
#write(base_html, execution_units, write_options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/greenpepper/writer/htmlwriter.rb', line 46 def write(base_html, execution_units, = {}) load_document(base_html, execution_units, ) @execution_units.each{ |unit| all_example_table = [] @tables[unit.context.first_table_index, unit.context.nb_table].each{ |table| all_example_table << table } write_results_to_html all_example_table, unit.result } @html_doc.to_s end |