require 'pathname'

class Pathname

  # Already included in 1.8.4+ version of Ruby
  if ! instance_methods.include?(:descend)

    # Calls the _block_ for every successive subdirectory of the
    # directory path from the root (absolute path) unitl +.+
    # (relative path) is reached.
    def descend()
      @path.scan(%r{[^/]*/?})[0...-1].inject('') do |path, dir|
        yield Pathname.new(path << dir)
      path
      end
    end

  end

end
