From 4338b9735130099e06f72f557ebf37e5e93686c2 Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Fri, 6 Feb 2009 09:32:37 -0500 Subject: [PATCH] Do not rely on requiring "find". Cut-and-pasted the code instead. --- mongo-ruby-driver.gemspec | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/mongo-ruby-driver.gemspec b/mongo-ruby-driver.gemspec index 63a1269..87b740a 100644 --- a/mongo-ruby-driver.gemspec +++ b/mongo-ruby-driver.gemspec @@ -1,4 +1,45 @@ -require 'find' +# This is a copy of the code in the stdlib file 'find.rb'. GitHub doesn't seem +# to allow me to "require 'find'". +module Find + def find(*paths) # :yield: path + paths.collect!{|d| d.dup} + while file = paths.shift + catch(:prune) do + yield file.dup.taint + next unless File.exist? file + begin + if File.lstat(file).directory? then + d = Dir.open(file) + begin + for f in d + next if f == "." or f == ".." + if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then + f = file + f + elsif file == "/" then + f = "/" + f + else + f = File.join(file, f) + end + paths.unshift f.untaint + end + ensure + d.close + end + end + rescue Errno::ENOENT, Errno::EACCES + end + end + end + end + + def prune + throw :prune + end + + module_function :find, :prune +end + +# ================================================================ def self.files_in(dir) files = []