module CommandT
  module Scanner
    # Simplistic scanner that wraps 'find . -type f'.
    class Find
      def initialize path = Dir.pwd
        @path = path
      end

      def flush
        @paths = nil
      end

      def paths
        return @paths unless @paths.nil?
        begin
          pwd = Dir.pwd
          Dir.chdir @path
          @paths = `find . -type f 2> /dev/null`.split("\n")
        ensure
          Dir.chdir pwd
        end
        @paths
      end
    end # class Find
  end # module Scanner
end # module CommandT

module CommandT
  module Scanner
    # Simplistic scanner that wraps 'find . -type f'.
    class Find
      def initialize path = Dir.pwd, options = {}
        @path = path
        @max_depth = 15
        @max_depth = options[:max_depth].to_i unless options[:max_depth].nil?
      end

      def flush
        @paths = nil
      end

      def paths
        return @paths unless @paths.nil?
        begin
          pwd = Dir.pwd
          Dir.chdir @path
          @paths = `find . -type f -maxdepth #{@max_depth} 2> /dev/null`.split("\n")
        ensure
          Dir.chdir pwd
        end
        @paths
      end
    end # class Find
  end # module Scanner
end # module CommandT

Add max_depth option to Find class
Add max_depth option to Find class

This matches some but not all functionality in the Ruby scanner.

Signed-off-by: Wincent Colaiuta <c76ac2e9cd86441713c7dfae92c451f3e6d17fdc@wincent.com>
