Class: Mutx::View::Parser
- Inherits:
-
Object
- Object
- Mutx::View::Parser
- Defined in:
- lib/mutx/view/parser.rb
Class Method Summary collapse
-
.adapt_to_mutx(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.
-
.mutx_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_mutx(source, result) ⇒ Object
Parses cucumber report html doc Divides in each parts of document
10 11 12 13 14 15 16 |
# File 'lib/mutx/view/parser.rb', line 10 def self.adapt_to_mutx(source, result) source.gsub! 'Collapse All</p></div></div></div>'," Collapse All</p></div></div></div> <div>#{mutx_info(result)}</div>" # end source.inspect end |
.extract_summary(source) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/mutx/view/parser.rb', line 31 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
51 52 53 |
# File 'lib/mutx/view/parser.rb', line 51 def self.finished_statement? source !(source =~ /Finished in .*s seconds/).nil? end |
.get_elapsed_time_for_zero(source) ⇒ Object
70 71 72 |
# File 'lib/mutx/view/parser.rb', line 70 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
74 75 76 |
# File 'lib/mutx/view/parser.rb', line 74 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
44 45 46 |
# File 'lib/mutx/view/parser.rb', line 44 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
65 66 67 |
# File 'lib/mutx/view/parser.rb', line 65 def self.has_scenarios_executed? source (source.include? "scenario") and (source.scan(/\d+\sscenario.*\)/).size > 0) end |
.mutx_info(result) ⇒ String
This is the information added to html report
21 22 23 24 25 26 27 28 29 |
# File 'lib/mutx/view/parser.rb', line 21 def self.mutx_info(result) info = "<h2><strong>Task:</strong> #{result.task_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)
58 59 60 |
# File 'lib/mutx/view/parser.rb', line 58 def self.no_scenario_but_green?(source) source.include? '0m0.000s seconds' end |