-
Notifications
You must be signed in to change notification settings - Fork 21
/
console.rb
31 lines (30 loc) · 934 Bytes
/
console.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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 LoadError => exception
puts exception
require "#{p}"
requires << "-r #{p} "
end
end
cmd << "#{irb_name} #{requires} --simple-prompt #{ARGV.join(' ')}"
exec cmd
end