lib/grache/packer/packer.rb in grache-0.0.2.pre.rc4 vs lib/grache/packer/packer.rb in grache-0.0.2.pre.rc8

- old
+ new

@@ -96,20 +96,27 @@ sha = Digest::SHA2.file(gemfile_lock).hexdigest uri = URI.parse("https://gdc-ms-grache.s3.amazonaws.com/grache-#{sha}.zip") puts "Looking for #{uri.to_s}" + name = uri.path.split('/').last + FileUtils.rm_rf name if File.exists?(name) + begin - name = uri.path.split('/').last Net::HTTP.start(uri.host) do |http| resp = http.get(uri.path) - open(name, 'wb') do |file| - file.write(resp.body) + if(resp.code == '200') + open(name, 'wb') do |file| + file.write(resp.body) + end + else + Packer.pack(opts) + return end end rescue => e - puts e.inspect + puts "ERROR: #{e.inspect}" end Zip::File.open(name) do |zip_file| # Handle entries one by one zip_file.each do |entry| @@ -118,11 +125,11 @@ out_path = "vendor/#{entry.name}" entry.extract(out_path) end end - puts "Removing old #{zip_file}" - FileUtils.rm_rf zip_file + puts "Removing old #{name}" + FileUtils.rm_rf name end def pack(opts = DEFAULT_PACK_OPTIONS) opts = DEFAULT_PACK_OPTIONS.merge(opts)