repaired_system.rb

Path: lib/rake/repaired_system.rb
Last Update: Thu Mar 12 18:40:43 -0700 2009

Copyright (c) 2008 James M. Lawrence

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Required files

rbconfig  

Methods

Public Instance methods

[Source]

     # File lib/rake/repaired_system.rb, line 141
141:     def `(cmd) #`
142:       backticks_previous(repair_command(cmd))
143:     end

[Source]

     # File lib/rake/repaired_system.rb, line 105
105:     def find_runnable(file)
106:       if file =~ RUNNABLE_PATTERN
107:         file
108:       else
109:         [nil, ".", *ENV["PATH"].split(";")].each { |path|
110:           RUNNABLE_EXTS.each { |ext|
111:             test = (path ? "#{path}/" : "") + "#{file}.#{ext}"
112:             if File.exist?(test)
113:               return test
114:             end
115:           }
116:         }
117:         nil
118:       end
119:     end

[Source]

    # File lib/rake/repaired_system.rb, line 83
83:     def join_command(*args)
84:       first =
85:         if args.first =~ %r!\s!
86:           quote(args.first)
87:         else
88:           args.first
89:         end
90:       [to_backslashes(first), *tail(args)].join(" ")
91:     end

[Source]

    # File lib/rake/repaired_system.rb, line 97
97:     def quote(string)
98:       %Q!"#{string}"!
99:     end

[Source]

    # File lib/rake/repaired_system.rb, line 70
70:     def repair_command(cmd)
71:       if (match = cmd.match(%r!\A\s*\"(.*?)\"!)) or
72:          (match = cmd.match(%r!\A(\S+)!))
73:         if runnable = find_runnable(match.captures.first)
74:           quote(to_backslashes(runnable)) + match.post_match
75:         else
76:           cmd
77:         end
78:       else
79:         cmd
80:       end
81:     end

[Source]

     # File lib/rake/repaired_system.rb, line 121
121:     def system(cmd, *args)
122:       file = cmd.to_s
123:       repaired_args = 
124:         if args.empty?
125:           [repair_command(file)]
126:         elsif file =~ BATCHFILE_PATTERN
127:           [ENV["COMSPEC"], "/c", to_backslashes(File.expand_path(file)), *args]
128:         elsif runnable = find_runnable(file)
129:           [to_backslashes(File.expand_path(runnable)), *args]
130:         else
131:           # maybe a built-in shell command
132:           [join_command(file, *args)]
133:         end
134:       if repaired_args.size == 1
135:         system_previous("call #{repaired_args.first}")
136:       else
137:         system_previous(*repaired_args)
138:       end
139:     end

[Source]

     # File lib/rake/repaired_system.rb, line 101
101:     def tail(array)
102:       array[1..-1]
103:     end

[Source]

    # File lib/rake/repaired_system.rb, line 93
93:     def to_backslashes(string)
94:       string.gsub("/", "\\")
95:     end

[Validate]