Sha256: 71d6835e2ba84f1cb8ebcec967c291981b9d369af9a79c6c76b32c9b120367a3

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Launchy
    
    ROOT_DIR        = File.expand_path(File.join(File.dirname(__FILE__),".."))
    LIB_DIR         = File.join(ROOT_DIR,"lib").freeze
    RESOURCE_DIR    = File.join(ROOT_DIR,"resources").freeze
    
    # 
    # Utility method to require all files ending in .rb in the directory
    # with the same name as this file minus .rb
    #
    def 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 
    module_function :require_all_libs_relative_to
    
    class << self
        def do_magic(*params)
            klass = Launchy::Spawnable::Application.find_application_class_for(*params)
            if klass then 
                klass.run(*params)
            else
                $stderr.puts "Unable to launch #{params.join(' ')}"
            end
        end
    end
end

Launchy.require_all_libs_relative_to(__FILE__)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
launchy-0.1.2 lib/launchy.rb
launchy-0.1.0 lib/launchy.rb
launchy-0.1.1 lib/launchy.rb