Parent

Included Modules

Class/Module Index [+]

Quicksearch

Rabbit::Console

Public Class Methods

get_last_name(klass) click to toggle source
# File lib/rabbit/console.rb, line 43
def get_last_name(klass)
  klass.name.split("::").last
end
new(logger=nil) click to toggle source
# File lib/rabbit/console.rb, line 48
def initialize(logger=nil)
  @logger = logger || Logger.default
end
parse!(args, logger=nil, &block) click to toggle source
# File lib/rabbit/console.rb, line 39
def parse!(args, logger=nil, &block)
  new(logger).parse!(args, &block)
end

Public Instance Methods

parse!(args) click to toggle source
# File lib/rabbit/console.rb, line 52
def parse!(args)
  options = OpenStruct.new
  options.logger = @logger
  options.default_logger = @logger
  options.druby_uri = "druby://127.0.0.1:10101"
  options.version = VERSION
  options.options_file = nil
  options.rest = []
  options.before_hooks = []
  options.after_hooks = []

  process_locale_options(args)

  parser = OptionParser.new(banner) do |_parser|
    yield(_parser, options)
    setup_common_options(_parser, options)
  end

  begin
    options_file = options.options_file
    if options_file and File.file?(options_file)
      read_options_file(parser, options, options_file)
    end
    options.before_hooks.each do |hook|
      hook.call(self, parser, options)
    end
    options.rest.concat(parser.parse!(args))
    options.after_hooks.each do |hook|
      hook.call(self, parser, options)
    end
  rescue
    @logger.fatal($!.message)
  end

  [options, options.logger]
end
read_options_file(parser, options, options_file) click to toggle source
# File lib/rabbit/console.rb, line 89
def read_options_file(parser, options, options_file)
  options_in_file = []
  File.open(options_file) do |file|
    file.each_line do |line|
      options_in_file.concat(Shellwords.split(line))
    end
  end
  source_info = parser.parse(options_in_file)

  source_info = source_info.collect do |path|
    if URI(path).scheme
      path
    else
      if Pathname(path).absolute?
        path
      else
        File.join(File.dirname(options_file), path)
      end
    end
  end
  options.rest.concat(source_info)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.