Class: Pakman::Finder

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/pakman/finder.rb

Instance Method Summary collapse

Instance Method Details

#find_manifests(patterns, excludes = []) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pakman/finder.rb', line 10

def find_manifests( patterns, excludes=[] )
  manifests = []

  patterns.each do |pattern|
    pattern.gsub!( '\\', '/')  # normalize path; make sure all path use / only
    logger.debug "Checking >#{pattern}<"
    Dir.glob( pattern ) do |file|
      logger.debug "  Found manifest candidate >#{file}<"
      if File.directory?( file ) # NB: do not include directories
        logger.debug "  Skipping match; it's a directory"
      else
        unless exclude?( file, excludes )  # check for excludes; skip if excluded
          logger.debug "  Adding match >#{file}<"

          ## todo/fix:
          # array first entry - downcase and gsub('.txt','') ??
          # use Pakman.pakname_from_file()

          manifests << [ File.basename( file ), file ]
        end
      end
    end
  end

  manifests
end