Launchy::Application::Browser

The class handling the browser application and all of its schemes

Public Class Methods

handles?( uri ) click to toggle source
    # File lib/launchy/applications/browser.rb, line 10
10:     def self.handles?( uri )
11:       return true if schemes.include?( uri.scheme )
12:       return true if File.exist?( uri.path )
13:     end
schemes() click to toggle source
   # File lib/launchy/applications/browser.rb, line 6
6:     def self.schemes
7:       ] http https ftp file ]
8:     end

Public Instance Methods

app_list() click to toggle source

use a call back mechanism to get the right app_list that is decided by the host_os_family class.

    # File lib/launchy/applications/browser.rb, line 40
40:     def app_list
41:       host_os_family.app_list( self )
42:     end
browser_cmdline() click to toggle source

Get the full commandline of what we are going to add the uri to

    # File lib/launchy/applications/browser.rb, line 53
53:     def browser_cmdline
54:       possibilities = (browser_env + app_list).flatten
55:       possibilities.each do |p|
56:         Launchy.log "#{self.class.name} : possibility : #{p}"
57:       end
58:       if browser = possibilities.shift then
59:         Launchy.log "#{self.class.name} : Using browser value '#{browser}'"
60:         return browser
61:       end
62:       raise Launchy::CommandNotFoundError, "Unable to find a browser command. If this is unexpected, #{Launchy.bug_report_message}"
63:     end
browser_env() click to toggle source
    # File lib/launchy/applications/browser.rb, line 44
44:     def browser_env
45:       return [] unless ENV['BROWSER']
46:       browser_env = ENV['BROWSER'].split( File::PATH_SEPARATOR )
47:       browser_env.flatten!
48:       browser_env.delete_if { |b| b.nil? || (b.strip.size == 0) }
49:       return browser_env
50:     end
cmd_and_args( uri, options = {} ) click to toggle source
    # File lib/launchy/applications/browser.rb, line 65
65:     def cmd_and_args( uri, options = {} )
66:       cmd = browser_cmdline
67:       args = [ uri.to_s ]
68:       if cmd =~ /%s/ then
69:         cmd.gsub!( /%s/, args.shift )
70:       end
71:       return [cmd, args]
72:     end
cygwin_app_list() click to toggle source
    # File lib/launchy/applications/browser.rb, line 19
19:     def cygwin_app_list
20:       [ 'cmd /C start /b' ]
21:     end
darwin_app_list() click to toggle source
    # File lib/launchy/applications/browser.rb, line 23
23:     def darwin_app_list
24:       [ find_executable( "open" ) ]
25:     end
nix_app_list() click to toggle source
    # File lib/launchy/applications/browser.rb, line 27
27:     def nix_app_list
28:       app_list = ] xdg-open ]
29:       if nix_de = Launchy::Detect::NixDesktopEnvironment.detect then
30:         app_list << nix_de.browser
31:         app_list << nix_de.fallback_browsers
32:       end
33:       app_list.flatten!
34:       app_list.delete_if { |b| b.nil? || (b.strip.size == 0) }
35:       app_list.collect { |bin| find_executable( bin ) }.find_all { |x| not x.nil? }
36:     end
open( uri, options = {} ) click to toggle source

final assembly of the command and do %s substitution www.catb.org/~esr/BROWSER/index.html

    # File lib/launchy/applications/browser.rb, line 76
76:     def open( uri, options = {} )
77:       cmd, args = cmd_and_args( uri, options )
78:       run( cmd, args )
79:     end
windows_app_list() click to toggle source
    # File lib/launchy/applications/browser.rb, line 15
15:     def windows_app_list
16:       [ 'start /b' ]
17:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.