Sha256: 673d5f33a0e875a2558b702de39462e4ad0e95d7417fa7a877a489cee2f56f15

Contents?: true

Size: 667 Bytes

Versions: 12

Compression:

Stored size: 667 Bytes

Contents

# frozen_string_literal: true

module Spandx
  module Core
    class PathTraversal
      attr_reader :root

      def initialize(root, recursive: true)
        @root = Pathname.new(root)
        @recursive = recursive
      end

      def each(&block)
        each_file_in(root, &block)
      end

      private

      def recursive?
        @recursive
      end

      def each_file_in(path, &block)
        files = path.directory? ? path.children : [path]
        files.each do |file|
          if file.directory?
            each_file_in(file, &block) if recursive?
          else
            block.call(file)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spandx-0.18.3 lib/spandx/core/path_traversal.rb
spandx-0.18.2 lib/spandx/core/path_traversal.rb
spandx-0.18.1 lib/spandx/core/path_traversal.rb
spandx-0.18.0 lib/spandx/core/path_traversal.rb
spandx-0.17.0 lib/spandx/core/path_traversal.rb
spandx-0.16.1 lib/spandx/core/path_traversal.rb
spandx-0.16.0 lib/spandx/core/path_traversal.rb
spandx-0.15.1 lib/spandx/core/path_traversal.rb
spandx-0.15.0 lib/spandx/core/path_traversal.rb
spandx-0.14.0 lib/spandx/core/path_traversal.rb
spandx-0.13.5 lib/spandx/core/path_traversal.rb
spandx-0.13.4 lib/spandx/core/path_traversal.rb