Sha256: 8b88252f27a43049b3eb84545f47fff35e74314bfe344322fd466bda76e21c65

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# the console command
def console(options)
  send(:open_irb, options, ARGV)
end

# the actual method to do the irb opening
def open_irb(options, argv)
  tm_lib   = File.dirname(__FILE__) + '/../../../taskmapper.rb'
  irb_name = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'  
  requires = "-r rubygems -r #{tm_lib} "
  cmd = ''
  if File.exist?(config = File.expand_path(options[:config]))
    ENV['TASKMAPPER_CONFIG']=config
  end
  providers = !options[:provider].nil? ? [options[:provider]] : YAML.load_file(config).keys
  providers.delete 'default'
  require 'rubygems'
  require 'taskmapper'
  providers.inject(requires) do |mem, p|
    begin
      require "taskmapper-#{p}"
      requires << "-r taskmapper-#{p} "
    rescue Exception => exception
      #puts exception
      begin
        require "#{p}"
        requires << "-r #{p} "
      rescue Exception => exception
        warn "Could not require the '#{p}' provider. Is it installed?"
      end
    end
  end
  cmd << "#{irb_name} #{requires} --simple-prompt #{ARGV.join(' ')}"
  exec cmd
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taskmapper-0.8.1 lib/taskmapper/cli/commands/console.rb
taskmapper-0.8.0 lib/taskmapper/cli/commands/console.rb