Class: FaaStRuby::Package
- Inherits:
-
Object
- Object
- FaaStRuby::Package
- Defined in:
- lib/faastruby/cli/package.rb
Instance Method Summary collapse
-
#build ⇒ Object
Zip the input directory.
-
#initialize(input_dir, output_file, exclude: []) ⇒ Package
constructor
Initialize with the directory to zip and the location of the output archive.
Constructor Details
#initialize(input_dir, output_file, exclude: []) ⇒ Package
Initialize with the directory to zip and the location of the output archive.
5 6 7 8 9 |
# File 'lib/faastruby/cli/package.rb', line 5 def initialize(input_dir, output_file, exclude: []) @input_dir = input_dir @output_file = output_file @exclude = ['.', '..', '.git', @output_file.split('/').last] + exclude end |
Instance Method Details
#build ⇒ Object
Zip the input directory.
12 13 14 15 16 17 18 19 |
# File 'lib/faastruby/cli/package.rb', line 12 def build entries = Dir.entries(@input_dir) entries.delete_if {|e| @exclude.include?(e)} FileUtils.rm_f(@output_file) # Make sure file doesn't exist ::Zip::File.open(@output_file, ::Zip::File::CREATE) do |zipfile| write_entries entries, '', zipfile end end |