Sha256: 61b40a50bceeaa8683c7d7aa6ea270b7f586da7ce8e84f58953191ea83b8b0b7

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents


module Stella::Adapter
  class CommandNotReady < RuntimeError
    def initialize(name="")
      super(Stella::TEXT.msg(:error_adapter_command_not_ready, name))
    end
  end
  
  class Base
    
    
    attr_accessor :arguments, :load_factor, :working_directory, :stats
    
    def initialize(options={}, arguments=[])
      self.arguments = arguments
      self.options = options
    end
    
    def load_factor=(load_factor)
      @load_factor = load_factor
    end
    def stdout_path
      File.join(@working_directory, 'STDOUT.txt')
    end
    
    def stderr_path
      File.join(@working_directory, 'STDERR.txt')
    end
    
    def summary_path(ext='yaml')
      File.join(@working_directory, "SUMMARY.#{ext}")
    end
    
    # process_options
    #
    # This method must be overridden by the implementing class. This is intended
    # for processing the command-specific command-line arguments
    def process_options
      raise Stella::TEXT.msg(:error_class_must_override, 'process_options')
    end
    
    def options=(options={})
      options = options.marshal_dump if options.is_a? OpenStruct
      unless options.nil? || options.empty?
        options.each_pair do |name,value|
          next if @private_variables.member?(name)
          Stella::LOGGER.info(:error_class_unknown_argument, name) && next unless self.respond_to?("#{name.to_s}=")
          instance_variable_set("@#{name.to_s}", value)
        end
      end
    end
    
    def arguments=(arguments=[])
      @arguments = arguments unless arguments.nil? 
    end
    
    def available?
      (version.to_f > 0)
    end
    
    def name
      @command_name
    end
    
    def command
      raise Stella::TEXT.msg(:error_class_must_override, 'command')
    end
    
    
  end
end
  

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stella-0.5.1 lib/stella/adapter/base.rb