Sha256: 6b40f660f0bf8b6ae91a888024678ddeb1667060ee39f7d48cf077f404cfb8ff

Contents?: true

Size: 1.04 KB

Versions: 24

Compression:

Stored size: 1.04 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__) + '/../../../ticketmaster.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['TICKETMASTER_CONFIG']=config
  end
  providers = !options[:provider].nil? ? [options[:provider]] : YAML.load_file(config).keys
  providers.delete 'default'
  require 'rubygems'
  require 'ticketmaster'
  providers.inject(requires) do |mem, p|
    begin
      require "ticketmaster-#{p}"
      requires << "-r ticketmaster-#{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

24 entries across 24 versions & 1 rubygems

Version Path
ticketmaster-0.7.0 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.6.10 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.6.9 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.6.8 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.6.7 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.6.6 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.5.6 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.5.5 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.5.3 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.5.2 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.5.1 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.5.0 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.9 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.8 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.7 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.6 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.5 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.3 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.2 lib/ticketmaster/cli/commands/console.rb
ticketmaster-0.4.1 lib/ticketmaster/cli/commands/console.rb