Class: Kaya::View::Parser
- Inherits:
-
Object
- Object
- Kaya::View::Parser
- Defined in:
- lib/kaya/view/parser.rb
Class Method Summary collapse
-
.adapt_to_kaya(source, result) ⇒ Object
Parses cucumber report html doc Divides in each parts of document.
- .extract_summary(source) ⇒ Object
-
.finished_statement?(source) ⇒ Boolean
Checks if report says that execution is finised.
- .get_elapsed_time_for_zero(source) ⇒ Object
- .get_scenarios_summary(source) ⇒ Object
-
.get_status(source) ⇒ Object
Returns the status present on html cucumber report.
-
.has_scenarios_executed?(source) ⇒ Boolean
Checks if has scenario results summary.
-
.kaya_info(result) ⇒ String
This is the information added to html report.
-
.no_scenario_but_green?(source) ⇒ Boolean
Checks if result report is about no scenarios executed (scenarios not found).
Class Method Details
.adapt_to_kaya(source, result) ⇒ Object
Parses cucumber report html doc Divides in each parts of document
9 10 11 12 13 14 15 |
# File 'lib/kaya/view/parser.rb', line 9 def self.adapt_to_kaya(source, result) source.gsub! 'Collapse All</p></div></div></div>'," Collapse All</p></div></div></div> <div>#{kaya_info(result)}</div>" # end source.inspect end |
.extract_summary(source) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/kaya/view/parser.rb', line 30 def self.extract_summary source if no_scenario_but_green?(source) # 0 scenarios executed get_elapsed_time_for_zero(source) elsif has_scenarios_executed?(source) # scenarios executed > 0 get_scenarios_summary(source) else "running" end end |
.finished_statement?(source) ⇒ Boolean
Checks if report says that execution is finised
50 51 52 |
# File 'lib/kaya/view/parser.rb', line 50 def self.finished_statement? source !(source =~ /Finished in .*s seconds/).nil? end |
.get_elapsed_time_for_zero(source) ⇒ Object
69 70 71 |
# File 'lib/kaya/view/parser.rb', line 69 def self.get_elapsed_time_for_zero(source) "0 Scenarios " + source.scan(/Finished in <strong>0m0.000s seconds/).first.gsub("<strong>","") end |
.get_scenarios_summary(source) ⇒ Object
73 74 75 |
# File 'lib/kaya/view/parser.rb', line 73 def self.get_scenarios_summary(source) source.scan(/\d+\sscenario.*\)/).first.gsub(/\<.+\>/,' - ') end |
.get_status(source) ⇒ Object
Returns the status present on html cucumber report
43 44 45 |
# File 'lib/kaya/view/parser.rb', line 43 def self.get_status(source) source.scan(/\d\sscenarios?\s\(\d+\s(\w+)/i).flatten.first if finished_statement?(source) end |
.has_scenarios_executed?(source) ⇒ Boolean
Checks if has scenario results summary
64 65 66 |
# File 'lib/kaya/view/parser.rb', line 64 def self.has_scenarios_executed? source (source.include? "scenario") and (source.scan(/\d+\sscenario.*\)/).size > 0) end |
.kaya_info(result) ⇒ String
This is the information added to html report
20 21 22 23 24 25 26 27 28 |
# File 'lib/kaya/view/parser.rb', line 20 def self.kaya_info(result) info = "<h2><strong>Suite:</strong> #{result.suite_name}</h2>" info += "<h4>Execution name: #{result.execution_name.gsub('-_-',' ')}</h4>" unless result.execution_name.empty? info += "<h4>Command: #{result.command}</h4>" info += "<h4>Custom Params: #{result.custom_params_values.split('=').last}</h4>" info += "<h4>Started: #{result.started_at_formatted}</h4>" info += "<h4>Commit ID: #{result.git_log.split('\n').first}</h4>" info += "<h4><input type='button' onclick='window.close();' value='Close this window' />" end |
.no_scenario_but_green?(source) ⇒ Boolean
Checks if result report is about no scenarios executed (scenarios not found)
57 58 59 |
# File 'lib/kaya/view/parser.rb', line 57 def self.no_scenario_but_green?(source) source.include? '0m0.000s seconds' end |