Parent

Launchy::Application

Application is the base class of all the application types that launchy may invoke. It essentially defines the public api of the launchy system.

Every class that inherits from Application must define:

  1. A constructor taking no parameters

  2. An instance method ‘open’ taking a string or URI as the first parameter and a hash as the second

  3. A class method ‘handles?’ that takes a String and returns true if that class can handle the input.

Attributes

host_os_family[R]
ruby_engine[R]
runner[R]

Public Class Methods

find_executable( bin, *paths ) click to toggle source

Find the given executable in the available paths

# File lib/launchy/application.rb, line 29
def find_executable( bin, *paths )
  paths = ENV['PATH'].split( File::PATH_SEPARATOR ) if paths.empty?
  paths.each do |path|
    file = File.join( path, bin )
    if File.executable?( file ) then
      Launchy.log "#{self.name} : found executable #{file}"
      return file
    end
  end
  Launchy.log "#{self.name} : Unable to find `#{bin}' in #{paths.join(", ")}"
  return nil
end
handling( uri ) click to toggle source

Find the application that handles the given uri.

returns the Class that can handle the uri

# File lib/launchy/application.rb, line 21
def handling( uri )
  klass = find_child( :handles?, uri )
  return klass if klass
  raise ApplicationNotFoundError, "No application found to handle '#{uri}'"
end
new() click to toggle source
# File lib/launchy/application.rb, line 47
def initialize
  @host_os_family = Launchy::Detect::HostOsFamily.detect
  @ruby_engine    = Launchy::Detect::RubyEngine.detect
  @runner         = Launchy::Detect::Runner.detect
end

Public Instance Methods

find_executable( bin, *paths ) click to toggle source
# File lib/launchy/application.rb, line 53
def find_executable( bin, *paths )
  Application.find_executable( bin, *paths )
end
run( cmd, *args ) click to toggle source
# File lib/launchy/application.rb, line 57
def run( cmd, *args )
  runner.run( cmd, *args )
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.