Class: Pione::Package::PackageExpander
- Inherits:
-
Object
- Object
- Pione::Package::PackageExpander
- Defined in:
- lib/pione/package/package-expander.rb
Overview
PackageExpander expands package files from ZIP archive.
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
-
#expand(output) ⇒ Object
Expand package files into the output location.
-
#initialize(location) ⇒ PackageExpander
constructor
Create a instance with the target location.
Constructor Details
#initialize(location) ⇒ PackageExpander
Create a instance with the target location.
11 12 13 |
# File 'lib/pione/package/package-expander.rb', line 11 def initialize(location) @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/pione/package/package-expander.rb', line 5 def location @location end |
Instance Method Details
#expand(output) ⇒ Object
Expand package files into the output location.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pione/package/package-expander.rb', line 16 def (output) # make local cache of target location location = @location.local # expand zip archive Zip::File.open(location.path.to_s) do |zip| zip.each do |entry| unless entry.ftype == :directory tmp = Temppath.create entry.extract(tmp.to_s) Location[tmp].move(output + entry.name) end end end end |