Parent

Launchy::Detect::Runner

Public Class Methods

detect() click to toggle source

Detect the current command runner

This will return an instance of the Runner to be used to do the application launching.

If a runner cannot be detected then raise Runner::NotFoundError

The runner rules are, in order:

1) If you are on windows, you use the Windows Runner no matter what 2) If you are using the jruby engine, use the Jruby Runner. Unless rule

   (1) took effect

3) Use Forkable (barring rules (1) and (2))

    # File lib/launchy/detect/runner.rb, line 22
22:     def self.detect
23:       host_os_family = Launchy::Detect::HostOsFamily.detect
24:       ruby_engine    = Launchy::Detect::RubyEngine.detect
25: 
26:       return Windows.new if host_os_family.windows?
27:       if ruby_engine.jruby? then
28:         require 'spoon'
29:         return Jruby.new
30:       end
31:       return Forkable.new
32:     end

Public Instance Methods

commandline_normalize( cmdline ) click to toggle source
    # File lib/launchy/detect/runner.rb, line 46
46:     def commandline_normalize( cmdline )
47:       c = cmdline.flatten!
48:       c = c.find_all { |a| (not a.nil?) and ( a.size > 0 ) }
49:       Launchy.log "commandline_normalized => #{c.join(' ')}"
50:       return c
51:     end
dry_run( cmd, *args ) click to toggle source
    # File lib/launchy/detect/runner.rb, line 53
53:     def dry_run( cmd, *args )
54:       shell_commands(cmd, args).join(" ")
55:     end
run( cmd, *args ) click to toggle source
    # File lib/launchy/detect/runner.rb, line 57
57:     def run( cmd, *args )
58:       raise Launchy::CommandNotFoundError, "No command found to run with args '#{args.join(' ')}'. If this is unexpected, #{Launchy.bug_report_message}" unless cmd
59:       if Launchy.dry_run? then
60:         $stdout.puts dry_run( cmd, *args )
61:       else
62:         wet_run( cmd, *args )
63:       end
64:     end
shell_commands( cmd, args ) click to toggle source

cut it down to just the shell commands that will be passed to exec or posix_spawn. The cmd argument is split according to shell rules and the args are not escaped because they whole set is passed to system as *args and in that case system shell escaping rules are not done.

    # File lib/launchy/detect/runner.rb, line 40
40:     def shell_commands( cmd, args )
41:       cmdline = [ cmd.shellsplit ]
42:       cmdline << args.flatten.collect{ |a| a.to_s }
43:       return commandline_normalize( cmdline )
44:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.