Sha256: 982d01a1f813ead69ee5c4ec5964f7dfb747e92748f02cf230b2abd5aee37ccf

Contents?: true

Size: 1.39 KB

Versions: 18

Compression:

Stored size: 1.39 KB

Contents

module Launchy
  #
  # Utility method to require all files ending in .rb in the directory
  # with the same name as this file minus .rb
  #
  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

  class << self
    #
    # Convenience method to launch an item
    #
    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

    # Setting the LAUNCHY_DEBUG environment variable to 'true' will spew
    # debug information to $stderr
    def log(msg)
      if ENV['LAUNCHY_DEBUG'] == 'true' then
        $stderr.puts "LAUNCHY_DEBUG: #{msg}"
      end
    end

    # Create an instance of the commandline application of launchy
    def command_line
      Launchy::CommandLine.new
    end
  end
end

Launchy.require_all_libs_relative_to(__FILE__)

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/launchy-0.3.7/lib/launchy.rb
launchy-0.4.0 lib/launchy.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/launchy-0.3.7/lib/launchy.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/launchy-0.3.7/lib/launchy.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/launchy-0.3.7/lib/launchy.rb
launchy-0.3.7 lib/launchy.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/launchy-0.3.5/lib/launchy.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/launchy-0.3.5/lib/launchy.rb
launchy-0.3.5 lib/launchy.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.10.17 vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.10.16 vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.10.15 vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
middleman-0.10.14 vendor/gems/gems/launchy-0.3.3/lib/launchy.rb
launchy-0.3.3 lib/launchy.rb