Class: Trackler::FileBundle

Inherits:
Object
  • Object
show all
Defined in:
lib/trackler/file_bundle.rb

Overview

A FileBundle is a collection of files from within an exercise directory It contains all the files that will be provided by the ‘exercism fetch` command EXCEPT for those whose names match any of the ignore patterns.

Instance Method Summary collapse

Constructor Details

#initialize(base_directory, ignore_patterns = []) ⇒ FileBundle

Returns a new instance of FileBundle.



8
9
10
11
# File 'lib/trackler/file_bundle.rb', line 8

def initialize(base_directory, ignore_patterns = [])
  @base_directory = base_directory
  @ignore_patterns = ignore_patterns
end

Instance Method Details

#pathsObject



23
24
25
# File 'lib/trackler/file_bundle.rb', line 23

def paths
  all_files_below(base_directory).reject { |file| ignored? file }.sort
end

#zipObject



13
14
15
16
17
18
19
20
21
# File 'lib/trackler/file_bundle.rb', line 13

def zip
  Zip::OutputStream.write_buffer do |io|
    paths.each do |path|
      io.put_next_entry(path.relative_path_from(base_directory))
      io.print IO.read(path)
    end
    yield io if block_given?
  end
end