Module: Launchy
- Defined in:
- lib/launchy/paths.rb,
lib/launchy.rb,
lib/launchy/browser.rb,
lib/launchy/version.rb,
lib/launchy/application.rb,
lib/launchy/command_line.rb
Overview
– Copyright © 2007 Jeremy Hinegardner All rights reserved. See LICENSE and/or COPYING for details. ++
Defined Under Namespace
Modules: Paths, Version Classes: Application, Browser, CommandLine
Constant Summary collapse
Class Method Summary collapse
-
.command_line ⇒ Object
Create an instance of the commandline application of launchy.
-
.log(msg) ⇒ Object
Setting the LAUNCHY_DEBUG environment variable to ‘true’ will spew debug information to $stderr.
-
.open(*params) ⇒ Object
Convenience method to launch an item.
-
.require_all_libs_relative_to(fname) ⇒ Object
Utility method to require all files ending in .rb in the directory with the same name as this file minus .rb.
Class Method Details
.command_line ⇒ Object
Create an instance of the commandline application of launchy
47 48 49 |
# File 'lib/launchy.rb', line 47 def command_line Launchy::CommandLine.new end |
.log(msg) ⇒ Object
Setting the LAUNCHY_DEBUG environment variable to ‘true’ will spew debug information to $stderr
40 41 42 43 44 |
# File 'lib/launchy.rb', line 40 def log(msg) if ENV['LAUNCHY_DEBUG'] == 'true' then $stderr.puts "LAUNCHY_DEBUG: #{msg}" end end |
.open(*params) ⇒ Object
Convenience method to launch an item
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/launchy.rb', line 21 def open(*params) begin klass = Launchy::Application.find_application_class_for(*params) if klass then klass.run(*params) else msg = "Unable to launch #{params.join(' ')}" Launchy.log "#{self.name} : #{msg}" $stderr.puts msg end rescue Exception => e msg = "Failure in opening #{params.join(' ')} : #{e}" Launchy.log "#{self.name} : #{msg}" $stderr.puts msg end end |
.require_all_libs_relative_to(fname) ⇒ Object
Utility method to require all files ending in .rb in the directory with the same name as this file minus .rb
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/launchy.rb', line 6 def self.require_all_libs_relative_to(fname) prepend = File.basename(fname,".rb") search_me = File.join(File.dirname(fname),prepend) Dir.entries(search_me).each do |rb| if File.extname(rb) == ".rb" then require "#{prepend}/#{File.basename(rb,".rb")}" end end end |