Sha256: 7a1c08345a4c35843daad136804fe16ab10eff82ba5469e8376a8ec128ced238

Contents?: true

Size: 1.29 KB

Versions: 13

Compression:

Stored size: 1.29 KB

Contents

module Redcar
  class Command
    class Executor
      include Redcar::Core::HasLogger
      
      def self.current_environment
        win = Redcar.app.focussed_window        
        tab = Redcar.app.focussed_notebook_tab
        { :win => win,
          :tab => tab }
      end
      
      def initialize(command_instance, options={})
        @command_instance = command_instance
        @options          = options
      end
      
      def execute
        @command_instance.environment(Executor.current_environment)
        begin
          if not @options.empty?
            result = @command_instance.execute(@options) 
          else
            result = @command_instance.execute
          end
        rescue Object => e
          @command_instance.error = e
          print_command_error(e)
        rescue java.lang.StackOverflowError => e
          @command_instance.error = e
          print_command_error(e)
        end
        record
        result
      end
      
      private

      def print_command_error(e)
        puts "Error in command #{@command_instance.class}"
        puts e.class.to_s + ": " + e.message.to_s
        puts e.backtrace
      end
      
      def record
        if Redcar.app.history
          Redcar.app.history.record(@command_instance)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
redcar-0.6.1 plugins/application/lib/application/command/executor.rb
redcar-0.6 plugins/application/lib/application/command/executor.rb
redcar-0.6.1dev plugins/application/lib/application/command/executor.rb
redcar-0.5.1 plugins/application/lib/application/command/executor.rb
redcar-0.5 plugins/application/lib/application/command/executor.rb
redcar-0.5.6dev plugins/application/lib/application/command/executor.rb
redcar-0.5.5dev plugins/application/lib/application/command/executor.rb
redcar-0.5.4dev plugins/application/lib/application/command/executor.rb
redcar-0.5.3dev plugins/application/lib/application/command/executor.rb
redcar-0.5.2dev plugins/application/lib/application/command/executor.rb
redcar-0.5.1dev plugins/application/lib/application/command/executor.rb
redcar-0.4.1 plugins/application/lib/application/command/executor.rb
redcar-0.4 plugins/application/lib/application/command/executor.rb