Class: ET::SubmissionFileList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/et/submission_file_list.rb

Constant Summary collapse

DEFAULT_IGNORE_GLOBS =
[
  '.etignore',
  'node_modules/',
  'coverage/'
]

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SubmissionFileList

Returns a new instance of SubmissionFileList.



12
13
14
# File 'lib/et/submission_file_list.rb', line 12

def initialize(path)
  @path = path
end

Instance Method Details

#each(&block) ⇒ Object



34
35
36
37
38
# File 'lib/et/submission_file_list.rb', line 34

def each(&block)
  files.each do |file|
    block.call(file)
  end
end

#filesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/et/submission_file_list.rb', line 16

def files
  unless @files
    @files = Rake::FileList[File.join(@path, "**/*"), File.join(@path, ".etignore")]
    ignore_globs.each do |glob|
      filename = File.join(@path, glob)

      if File.directory?(filename)
        filename += glob.end_with?("/") ? "**/*" : "/**/*"
      end

      @files = @files.exclude(filename)
    end
    @files = @files.sub(File.join(@path, "/"), "")
  end

  @files
end