lib/my_utilities.rb in my_utilities-1.2.0 vs lib/my_utilities.rb in my_utilities-1.3.0

- old
+ new

@@ -47,22 +47,19 @@ single_opt ||= gen_opt1 long_opt ||= gen_opt2 key_of["--#{long_opt}"]=k opt_array << ["--#{long_opt}," "-#{single_opt}", GetoptLong::OPTIONAL_ARGUMENT] - } + end opts = GetoptLong.new opt_array opts.each do |opt, arg| return_array[key_of[opt]]=arg end return_array - end -end - end class Logger DEBUG=4 INFO=3 @@ -97,18 +94,19 @@ def parent_dir_match(rx, dir=".") # nil if this isn't a directory we're starting from return nil if !Dir.exists? dir - return dir if !(Dir.entries(dir).select { |x| rx.match x and File.file? File.join(dir, x) }.empty?) + find_files = Dir.entries(dir).select { |x| rx.match x and File.file? File.join(dir, x) } + return dir unless find_files.empty? # Don't recurse if the dir's parent is the dir return parent_dir_match(rx, File.join(dir, "..")) if(File.expand_path(dir) != '/') nil end end end - + private def self.generate_option_strings a=generate_single_option return [a, "#{a}_long_option"] end