Class: Jarbs::Packager
- Inherits:
-
Object
- Object
- Jarbs::Packager
- Includes:
- Commander::UI
- Defined in:
- lib/jarbs/packager.rb
Instance Method Summary collapse
-
#initialize(function) ⇒ Packager
constructor
A new instance of Packager.
- #package ⇒ Object
- #write_zip(data) ⇒ Object
Constructor Details
#initialize(function) ⇒ Packager
Returns a new instance of Packager.
7 8 9 |
# File 'lib/jarbs/packager.rb', line 7 def initialize(function) @function = function end |
Instance Method Details
#package ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jarbs/packager.rb', line 11 def package say_ok "Packaging..." stream = Zip::OutputStream.write_buffer do |out| @function.each_file do |filename, contents| out.put_next_entry(filename) out.write contents end end write_zip(stream.string) if $debug # return the generated zip data stream.string end |
#write_zip(data) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/jarbs/packager.rb', line 27 def write_zip(data) zipname = File.join(@function.root_path, "#{@function.name}.zip") File.open(zipname, 'w') {|zip| zip.write(data) } say_warning "DEBUG: Output debug package to #{zipname}" end |