The entry point into Launchy. This is the sole supported public API.
Launchy.open( uri, options = {} )
The currently defined global options are:
:debug Turn on debugging output :application Explicitly state what application class is going to be used :host_os Explicitly state what host operating system to pretend to be :ruby_engine Explicitly state what ruby engine to pretend to be under :dry_run Do nothing and print the command that would be executed on $stdout
Other options may be used, and those will be passed directly to the application class
# File lib/launchy.rb, line 71 71: def application 72: @application || ENV['LAUNCHY_APPLICATION'] 73: end
# File lib/launchy.rb, line 67 67: def application=( app ) 68: @application = app 69: end
# File lib/launchy.rb, line 99 99: def bug_report_message 100: "Please rerun with environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at https://github.com/copiousfreetime/launchy/issues/new" 101: end
# File lib/launchy.rb, line 57 57: def debug=( d ) 58: @debug = (d == "true") 59: end
we may do logging before a call to ‘open’, hence the need to check LAUNCHY_DEBUG here
# File lib/launchy.rb, line 63 63: def debug? 64: @debug || (ENV['LAUNCHY_DEBUG'] == 'true') 65: end
# File lib/launchy.rb, line 91 91: def dry_run=( dry_run ) 92: @dry_run = dry_run 93: end
# File lib/launchy.rb, line 95 95: def dry_run? 96: @dry_run 97: end
# File lib/launchy.rb, line 49 49: def extract_global_options( options ) 50: Launchy.debug = options.delete( :debug ) || ENV['LAUNCHY_DEBUG'] 51: Launchy.application = options.delete( :application ) || ENV['LAUNCHY_APPLICATION'] 52: Launchy.host_os = options.delete( :host_os ) || ENV['LAUNCHY_HOST_OS'] 53: Launchy.ruby_engine = options.delete( :ruby_engine ) || ENV['LAUNCHY_RUBY_ENGINE'] 54: Launchy.dry_run = options.delete( :dry_run ) || ENV['LAUNCHY_DRY_RUN'] 55: end
# File lib/launchy.rb, line 79 79: def host_os 80: @host_os || ENV['LAUNCHY_HOST_OS'] 81: end
# File lib/launchy.rb, line 75 75: def host_os=( host_os ) 76: @host_os = host_os 77: end
# File lib/launchy.rb, line 103 103: def log(msg) 104: $stderr.puts "LAUNCHY_DEBUG: #{msg}" if Launchy.debug? 105: end
Convenience method to launch an item
# File lib/launchy.rb, line 25 25: def open(uri, options = {} ) 26: begin 27: extract_global_options( options ) 28: uri = Addressable::URI.parse( uri ) 29: app = Launchy::Application.handling( uri ) 30: app.new.open( uri, options ) 31: rescue Exception => e 32: msg = "Failure in opening #{uri} with options #{options.inspect}: #{e}" 33: Launchy.log "#{self.name} : #{msg}" 34: e.backtrace.each do |bt| 35: Launchy.log bt 36: end 37: $stderr.puts msg 38: end 39: end
# File lib/launchy.rb, line 41 41: def reset_global_options 42: Launchy.debug = false 43: Launchy.application = nil 44: Launchy.host_os = nil 45: Launchy.ruby_engine = nil 46: Launchy.dry_run = false 47: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.