Rake::AltSystem

Alternate implementations of system() and backticks `` on Windows for ruby-1.8 and earlier.

Constants

WINDOWS
RUNNABLE_EXTS
RUNNABLE_PATTERN

Public Class Methods

define_module_function(name, &block) click to toggle source
    # File lib/rake/alt_system.rb, line 35
35:     def define_module_function(name, &block)
36:       define_method(name, &block)
37:       module_function(name)
38:     end

Public Instance Methods

backticks(cmd) click to toggle source
    # File lib/rake/alt_system.rb, line 97
97:     def backticks(cmd)
98:       kernel_backticks(repair_command(cmd))
99:     end
find_runnable(file) click to toggle source
    # File lib/rake/alt_system.rb, line 70
70:     def find_runnable(file)
71:       if file =~ RUNNABLE_PATTERN
72:         file
73:       else
74:         RUNNABLE_EXTS.each { |ext|
75:           if File.exist?(test = "#{file}.#{ext}")
76:             return test
77:           end
78:         }
79:         nil
80:       end
81:     end
repair_command(cmd) click to toggle source
    # File lib/rake/alt_system.rb, line 50
50:     def repair_command(cmd)
51:       "call " + (
52:         if cmd =~ %\A\s*\".*?\"!
53:           # already quoted
54:           cmd
55:         elsif match = cmd.match(%\A\s*(\S+)!)
56:           if match[1] =~ %/!
57:             # avoid x/y.bat interpretation as x with option /y
58:             %"#{match[1]}"! + match.post_match
59:           else
60:             # a shell command will fail if quoted
61:             cmd
62:           end
63:         else
64:           # empty or whitespace
65:           cmd
66:         end
67:       )
68:     end
system(cmd, *args) click to toggle source
    # File lib/rake/alt_system.rb, line 83
83:     def system(cmd, *args)
84:       repaired = (
85:         if args.empty?
86:           [repair_command(cmd)]
87:         elsif runnable = find_runnable(cmd)
88:           [File.expand_path(runnable), *args]
89:         else
90:           # non-existent file
91:           [cmd, *args]
92:         end
93:       )
94:       kernel_system(*repaired)
95:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.