Browse files

Adding merge_zip support.

  • Loading branch information...
1 parent 6dba527 commit 2d2d62ab8e749d8a38c8a59a47fb5224c178d2d1 Andrew Kirilenko committed Feb 24, 2014
View
6 Gemfile.lock
@@ -1,10 +1,10 @@
PATH
remote: .
specs:
- iron_worker_ng (1.2.0)
+ iron_worker_ng (1.3.0)
bundler
iron_core (>= 1.0.0)
- rubyzip (>= 1.0.0)
+ rubyzip (= 0.9.9)
GEM
remote: https://rubygems.org/
@@ -58,7 +58,7 @@ GEM
rest_client (>= 1.7.1)
rest_client (1.7.2)
netrc (~> 0.7.7)
- rubyzip (1.1.0)
+ rubyzip (0.9.9)
simple_oauth (0.2.0)
test-unit (2.5.5)
thread_safe (0.1.3)
View
2 iron_worker_ng.gemspec
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency 'iron_core', '>= 1.0.0'
gem.add_runtime_dependency 'bundler'
- gem.add_runtime_dependency 'rubyzip', '>= 1.0.0'
+ gem.add_runtime_dependency 'rubyzip', '= 0.9.9'

This is nasty. You've downgraded and fixed the RubyZip version to an exact one which was released 2 years ago. Most newer gems have installation problems with this, since they need RubyZip >= 1.0.0 (released a year ago).

Issue raised

This is preventing a couple of my apps to upgrade to iron_worker_ng 1.5.0, since i've other gems which need rubyzip >= 1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
gem.add_development_dependency 'test-unit'
gem.add_development_dependency 'minitest'
View
2 lib/iron_worker_ng/code/base.rb
@@ -8,6 +8,7 @@
require 'iron_worker_ng/feature/common/merge_file'
require 'iron_worker_ng/feature/common/merge_dir'
require 'iron_worker_ng/feature/common/merge_deb'
+require 'iron_worker_ng/feature/common/merge_zip'
require 'iron_worker_ng/feature/common/set_env'
module IronWorkerNG
@@ -30,6 +31,7 @@ class Base
include IronWorkerNG::Feature::Common::MergeFile::InstanceMethods
include IronWorkerNG::Feature::Common::MergeDir::InstanceMethods
include IronWorkerNG::Feature::Common::MergeDeb::InstanceMethods
+ include IronWorkerNG::Feature::Common::MergeZip::InstanceMethods
include IronWorkerNG::Feature::Common::SetEnv::InstanceMethods
def initialize(*args, &block)
View
6 lib/iron_worker_ng/code/container/zip.rb
@@ -1,6 +1,6 @@
-require 'zip'
+require 'zip/zip'
-Zip.continue_on_exists_proc = true
+Zip.options[:continue_on_exists_proc] = true
module IronWorkerNG
module Code
@@ -10,7 +10,7 @@ def initialize
super
@name = @name + '.zip'
- @zip = ::Zip::File.open(@name, ::Zip::File::CREATE)
+ @zip = ::Zip::ZipFile.open(@name, ::Zip::ZipFile::CREATE)
end
def add(dest, src)
View
68 lib/iron_worker_ng/feature/common/merge_zip.rb
@@ -0,0 +1,68 @@
+module IronWorkerNG
+ module Feature
+ module Common
+ module MergeZip
+ class Feature < IronWorkerNG::Feature::Base
+ attr_reader :path
+ attr_reader :dest
+
+ def initialize(code, path, dest)
+ super(code)
+
+ @path = path
+ @dest = dest + (dest.empty? || dest.end_with?('/') ? '' : '/')
+ end
+
+ 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::ZipFile.open(zip)
+ zipf.restore_permissions = true
+
+ zipf.each do |f|
+ next if zipf.get_entry(f).ftype == :directory
+
+ zipf.get_entry(f).extract(tmp_dir_name + '/' + File.basename(f.name))
+
+ container_add(container, @dest + f.name, tmp_dir_name + '/' + File.basename(f.name), true)
+
+ FileUtils.rm(tmp_dir_name + '/' + File.basename(f.name))
+ end
+ end
+
+ FileUtils.rm_rf(tmp_dir_name)
+ end
+ end
+
+ 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
+ end
+
+ module InstanceMethods
+ def merge_zip(path, dest = '')
+ IronCore::Logger.info 'IronWorkerNG', "Merging zip with path='#{path}' and dest='#{dest}'"
+
+ @features << IronWorkerNG::Feature::Common::MergeZip::Feature.new(self, path, dest)
+ end
+
+ alias :zip :merge_zip
+ end
+ end
+ end
+ end
+end
View
2 lib/iron_worker_ng/version.rb
@@ -1,5 +1,5 @@
module IronWorkerNG
- VERSION = '1.2.0'
+ VERSION = '1.3.0'
def self.version
VERSION

0 comments on commit 2d2d62a

Please sign in to comment.