def sub_dir_of(file, base = base_directory)
      file = Pathname.new(file) unless file.respond_to?(:relative_path_from)
      base = Pathname.new(base) unless base.respond_to?(:relative_path_from)
      rel = file.relative_path_from(base)
      if file.directory?
        rel
      else
        rel.dirname
      end
    end
def sub_dir_of(file, base = base_directory)
      file = Pathname.new(file) unless file.respond_to?(:relative_path_from)
      base = Pathname.new(base) unless base.respond_to?(:relative_path_from)
      rel = file.relative_path_from(base)
      if file.directory?
        rel
      else
        rel.dirname
      end
    end
Returns the sub directory of the current base directory that the
 given file is in