Class: GreenPepper::FreeTextParser
- Inherits:
-
Object
- Object
- GreenPepper::FreeTextParser
- Defined in:
- lib/greenpepper/parser/freetextparser.rb
Instance Method Summary collapse
- #extract_content(document, filename = 'UNKNOWN') ⇒ Object
- #replace_scenarios(document, html_results) ⇒ Object
Instance Method Details
#extract_content(document, filename = 'UNKNOWN') ⇒ Object
16 17 18 19 |
# File 'lib/greenpepper/parser/freetextparser.rb', line 16 def extract_content(document, filename = 'UNKNOWN') doc = load_doc document, filename extract_scenarios_from_html(doc) end |
#replace_scenarios(document, html_results) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/greenpepper/parser/freetextparser.rb', line 21 def replace_scenarios(document, html_results) doc = load_doc document pres = find_free_text_pre doc if pres.size != html_results.size raise GreenPepperError.new("Mismatch in result size.") end pres.each_with_index{ |pre, index| new = (LibXML::XML::Parser.string( "<div>#{html_results[index]}</div>", :encoding => LibXML::XML::Encoding::UTF_8, :options => LibXML::XML::HTMLParser::Options::NOBLANKS).parse).root.copy(true) replace_node pre, new } doc.root.to_s end |