lib/u3d/log_analyzer.rb in u3d-1.0.1 vs lib/u3d/log_analyzer.rb in u3d-1.0.2
- old
+ new
@@ -76,19 +76,12 @@
# Check if phase is changing
@phases.each do |name, phase|
next if name == @active_phase
next unless line =~ phase['phase_start_pattern']
- if @active_rule
- # Active rule should be finished
- # If it is still active during phase change, it means that something went wrong
- UI.error("[#{@active_phase}] Could not finish active rule '#{@active_rule}'. Aborting it.")
- @active_rule = nil
- end
+ finish_phase
@active_phase = name
- @context.clear
- @rule_lines_buffer.clear
UI.verbose("--- Beginning #{name} phase ---")
break
end
apply_ruleset = lambda do |ruleset, header|
@@ -187,14 +180,32 @@
break
end
end
end
- apply_ruleset.call(@phases[@active_phase]['rules'], @active_phase) if @active_phase
+ if @active_phase
+ apply_ruleset.call(@phases[@active_phase]['rules'], @active_phase)
+ if @phases[@active_phase]['phase_end_pattern'] && @phases[@active_phase]['phase_end_pattern'] =~ line
+ finish_phase
+ end
+ end
apply_ruleset.call(@generic_rules, 'GENERAL')
end
private
+
+ def finish_phase
+ if @active_rule
+ # Active rule should be finished
+ # If it is still active during phase change, it means that something went wrong
+ UI.error("[#{@active_phase}] Could not finish active rule '#{@active_rule}'. Aborting it.")
+ @active_rule = nil
+ end
+ UI.verbose("--- Ending #{@active_phase} phase ---")
+ @active_phase = nil
+ @context.clear
+ @rule_lines_buffer.clear
+ end
def rules_path
path = ENV["U3D_RULES_PATH"]
unless path.nil?
UI.user_error!("Specified rules path '#{path}' isn't a file") unless File.exist? path