Class: IronWorkerNG::Feature::Common::MergeZip::Feature
- Defined in:
- lib/iron_worker_ng/feature/common/merge_zip.rb
Instance Attribute Summary collapse
-
#dest ⇒ Object
readonly
Returns the value of attribute dest.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #build_command ⇒ Object
- #bundle(container) ⇒ Object
-
#initialize(code, path, dest) ⇒ Feature
constructor
A new instance of Feature.
Methods inherited from Base
Constructor Details
#initialize(code, path, dest) ⇒ Feature
Returns a new instance of Feature.
9 10 11 12 13 14 |
# File 'lib/iron_worker_ng/feature/common/merge_zip.rb', line 9 def initialize(code, path, dest) super(code) @path = path @dest = dest + (dest.empty? || dest.end_with?('/') ? '' : '/') end |
Instance Attribute Details
#dest ⇒ Object (readonly)
Returns the value of attribute dest.
7 8 9 |
# File 'lib/iron_worker_ng/feature/common/merge_zip.rb', line 7 def dest @dest end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/iron_worker_ng/feature/common/merge_zip.rb', line 6 def path @path end |
Instance Method Details
#build_command ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/iron_worker_ng/feature/common/merge_zip.rb', line 48 def build_command if @code.remote_build_command || @code.full_remote_build if @code.full_remote_build && IronWorkerNG::Fetcher.remote?(rebase(@path)) "zip '#{rebase(@path)}', '#{@dest}'" else "zip '#{@code.dest_dir}#{@dest}#{File.basename(@path)}', '#{@dest}'" end else nil end end |
#bundle(container) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/iron_worker_ng/feature/common/merge_zip.rb', line 16 def bundle(container) IronCore::Logger.debug 'IronWorkerNG', "Bundling zip with path='#{@path}' and dest='#{@dest}'" if (not @code.full_remote_build) || (not IronWorkerNG::Fetcher.remote?(rebase(@path))) tmp_dir_name = ::Dir.tmpdir + '/' + ::Dir::Tmpname.make_tmpname('iron-worker-ng-', 'zip') ::Dir.mkdir(tmp_dir_name) IronWorkerNG::Fetcher.fetch_to_file(rebase(@path)) do |zip| zipf = ::Zip::File.open(zip) zipf. = true zipf.each do |f| next if zipf.get_entry(f).ftype == :directory FileUtils::mkdir_p(tmp_dir_name + '/' + File.dirname(f.name)) zipf.get_entry(f).extract(tmp_dir_name + '/' + f.name) end zipf.each do |f| next if zipf.get_entry(f).ftype == :directory container_add(container, @dest + f.name, tmp_dir_name + '/' + f.name) end end container.commit FileUtils.rm_rf(tmp_dir_name) end end |