Method: RubyApp::Session#process_event!

Defined in:
lib/ruby_app/session.rb

#process_event!(event) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/ruby_app/session.rb', line 83

def process_event!(event)

  event.process!

  if RubyApp::Session.configuration.scripts.enabled
    step = @steps[@steps_index]
    if step
      begin
        if event.is_a?(step._class)
          @steps_index += 1
          RubyApp::Log.duration(RubyApp::Log::INFO, "STEP      Current #{step._class} #{step.file}:#{step.line}#{step.block ? nil : ' (no block)'}") do
            step.block.call(event) if step.block
          end
          if @steps_index == @steps.length
            RubyApp::Log.info('-' * 80)
            RubyApp::Log.info("STEP      Completed #{@steps.length} steps")
            RubyApp::Log.info('-' * 80)
            event.alert("Completed #{@steps.length} steps.")
          else
            step = @steps[@steps_index]
            RubyApp::Log.info("STEP      Next    #{step._class} #{step.file}:#{step.line}#{step.block ? nil : ' (no block)'}")
          end
        end
      rescue => exception
        RubyApp::Log.info("STEP      Exception occurred at #{step.file}:#{step.line}")
        @steps_index = @steps.length
        raise
      end
    end
  end

end