def rackup_path
return @rackup_path if @rackup_path
if path_supplied = ARGV.delete("-R")
@rackup_path = ARGV.delete(@ourargs[@ourargs.index("-R") + 1])
if @rackup_path and File.file?(@rackup_path)
return @rackup_path
else
$stderr.puts "rackup does not exist at #{@rackup_path} (given with -R)"
end
end
unless is_windows?
@rackup_path = %x{which rackup}.to_s.chomp
if @rackup_path.size > 0 and File.file?(@rackup_path)
return @rackup_path
end
end
libs = ENV["RUBYLIB"].to_s.split(is_windows? ? ";" : ":")
if rack_lib = libs.detect { |r| r.match %r<(\\|/)rack\1> }
require "pathname"
@rackup_path = Pathname.new(rack_lib).parent.join("bin").join("rackup").expand_path
return @rackup_path if File.file?(@rackup_path)
end
begin
require "rubygems"
require "rack"
require "pathname"
@rackup_path = Pathname.new(Gem.bindir).join("rackup").to_s
return @rackup_path if File.file?(@rackup_path)
rescue LoadError
nil
end
@rackup_path = nil
raise "Cannot find path to rackup, please supply full path to rackup with -R"
end