Class: FileSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/file-set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(set) ⇒ FileSet

Returns a new instance of FileSet.



7
8
9
10
11
12
13
14
15
# File 'lib/file-set.rb', line 7

def initialize(set)
 @files= []
 case
   when (set.is_a?(String))
     include_file(set)
   when (set.is_a?(Array))
     set.each { |f| include_file(f) }
  end
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



5
6
7
# File 'lib/file-set.rb', line 5

def files
  @files
end

Instance Method Details

#eachObject



38
39
40
# File 'lib/file-set.rb', line 38

def each
  @files.each { |f| yield f }
end

#include_file(file) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/file-set.rb', line 17

def include_file(file)
  full_path= File.expand_path(file)

  if File.directory?(full_path)
    Dir.foreach(full_path) { |f|
        next if ('.'==f[/^\./])
        include_file(File.join(full_path, f))
    }
  else
    if (File.exists?(full_path))
      source_file= SourceFile.from_path(full_path)
    else
      source_file= Target.current.find_file(file)
      return if (!source_file)
    end
    
    return if (@files.include?(source_file))
    @files << source_file
  end
end