Class: UnitF::Tag::FileSet

Inherits:
Array
  • Object
show all
Includes:
Helpers
Defined in:
lib/unitf/tag/fileset.rb

Instance Method Summary collapse

Methods included from Helpers

#valid_file?

Constructor Details

#initialize(targets) ⇒ FileSet

Returns a new instance of FileSet.



6
7
8
9
10
11
# File 'lib/unitf/tag/fileset.rb', line 6

def initialize(targets)
  targets = [targets] if targets.is_a?(String)
  targets.each do |target|
    process_target(target)
  end
end

Instance Method Details

#find_files(root_path) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/unitf/tag/fileset.rb', line 22

def find_files(root_path)
  Find.find(root_path) do |file_path|
    UnitF::Log.debug("Considering #{file_path}")
    next unless valid_file?(file_path)

    UnitF::Log.debug("Including #{file_path}")
    append(UnitF::Tag::File.new(file_path))
  end
end

#process_target(target) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/unitf/tag/fileset.rb', line 13

def process_target(target)
  UnitF::Log.debug("Processing target #{target}...")
  if ::File.directory?(target)
    find_files(target)
  elsif valid_file?(target)
    append(UnitF::Tag::File.new(target))
  end
end