Module: Buildr::ZipTask::IncludeFiles

Included in:
Buildr::ZipTask, Path
Defined in:
lib/tasks/zip.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#exclude(*files) ⇒ Object

Exclude the specified file or directories.



42
43
44
45
# File 'lib/tasks/zip.rb', line 42

def exclude(*files)
  (@files ||= FileList[]).exclude *files
  self
end

#include(*files) ⇒ Object Also known as: add

Include the specified files or directories.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tasks/zip.rb', line 16

def include(*files)
  if Hash === files.last
    options = files.pop
  else
    options = {}
  end
  files = files.flatten

  if options[:path]
    path(options[:path]).include *files +[ options.reject { |k,v| k == :path } ]
  elsif options[:as]
    raise "You can only use the :as option in combination with the :path option" unless options.keys.size == 1
    raise "You can only use one file with the :as option" unless files.size == 1
    include_as(files.first.to_s, options[:as])
  elsif options[:merge]
    raise "You can only use the :merge option in combination with the :path option" unless options.keys.size == 1
    files.each { |file| merge file }
  elsif options.keys.empty?
    (@files ||= FileList[]).include files.map(&:to_s)
  else
    raise "Unrecognized option #{options.keys.join(", ")}"
  end
  self
end

#merge(*files) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/tasks/zip.rb', line 48

def merge(*files)
  if Hash === files.last
    options = files.pop
  else
    options = {}
  end

  if options[:path]
    path(options[:path]).merge *files +[ options.reject { |k,v| k == :path } ]
  elsif options.keys.empty?
    files.collect do |file|
      @expand_sources << proc { file.to_s }
      expander = ZipExpander.new(file)
      @add_files << proc { |zip| expander.expand(zip, @path) }
      expander
    end.first
  else
    raise "Unrecognized option #{options.keys.join(", ")}"
  end
end