presso 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/presso.rb +11 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0676312e4ccbb2170348ba9c0b3f09f39cf44811
4
- data.tar.gz: b827bd3ad3277dc6de6496b5d46817a6959bdb9c
3
+ metadata.gz: 86e5f35bdc09fa0c12db4f0f539428643b5ea1ed
4
+ data.tar.gz: 1adb07ec20aabb8751fbc0a7f68327f5f6568751
5
5
  SHA512:
6
- metadata.gz: acaa585142de00a910fe1cf3209513030854e116c77a754c399df4646bb097fc3a5e95c77a88a2b3b5886aac79702f8d2d2a824e467f49833e7a0c68dc0d3bfe
7
- data.tar.gz: b3170a14985018015fb923350d69ae1ad53900c404b24c0de9ef1e8b66215fefab7ba12d831fc5ae28b115701761a38b7e58de99783220f0288210c664db843e
6
+ metadata.gz: 00d2b8876a9bae179d45d6ce955d070d586152745deb635928fbf659960be0e5b1581455748204769a330a7c092fc2e5c08a4683486100303380c3444b8080bb
7
+ data.tar.gz: a165e75e63efbc34e388fba2e4a283173d3b193fd71a51b5f3dacfd1c4d93926a4e3f7f49bcbcdd81a76200381911358359f2eeea0b14b5c1aa16669dabd0a98
data/lib/presso.rb CHANGED
@@ -3,7 +3,7 @@ require 'java'
3
3
  raise LoadError, "Incompatible JRuby version. Use at least JRuby 1.7.4. See JRUBY-7157." if JRUBY_VERSION =~ /^1\.7\.[0-3]$/
4
4
 
5
5
  class Presso
6
- VERSION = '1.0.0'.freeze
6
+ VERSION = '1.0.1'.freeze
7
7
 
8
8
  module JavaUtilZip
9
9
  include_package 'java.util.zip'
@@ -16,17 +16,20 @@ class Presso
16
16
  Dir.chdir(input_directory) do
17
17
  File.open(output_path, File::WRONLY|File::CREAT|File::EXCL, binmode: true) do |file|
18
18
  stream = JavaUtilZip::ZipOutputStream.new(file.to_outputstream)
19
+ stream_io = stream.to_io
19
20
  Dir['**/*'].each do |path|
20
21
  if File.file?(path)
21
- stream.putNextEntry(JavaUtilZip::ZipEntry.new(path))
22
- IO.copy_stream(path, stream.to_io)
22
+ stream.put_next_entry(JavaUtilZip::ZipEntry.new(path))
23
+ IO.copy_stream(path, stream_io)
24
+ stream_io.flush
23
25
  elsif File.directory?(path)
24
- stream.putNextEntry(JavaUtilZip::ZipEntry.new(path+'/'))
26
+ stream.put_next_entry(JavaUtilZip::ZipEntry.new(path+'/'))
25
27
  else
26
28
  raise PressoError, "File #{path} is not a regular file."
27
29
  end
30
+ stream.close_entry
28
31
  end
29
- stream.close
32
+ stream_io.close
30
33
  end
31
34
  end
32
35
  end
@@ -35,6 +38,7 @@ class Presso
35
38
  raise PressoError, "Target directory #{output_directory} already exists." if File.exists?(output_directory)
36
39
  File.open(input_path, 'rb') do |file|
37
40
  stream = JavaUtilZip::ZipInputStream.new(file.to_inputstream)
41
+ stream_io = stream.to_io
38
42
  FileUtils.mkdir_p(output_directory)
39
43
  Dir.chdir(output_directory) do
40
44
  while (entry = stream.next_entry)
@@ -42,12 +46,12 @@ class Presso
42
46
  FileUtils.mkdir_p(entry.name)
43
47
  else
44
48
  FileUtils.mkdir_p(File.dirname(entry.name))
45
- IO.copy_stream(stream.to_io, entry.name)
49
+ IO.copy_stream(stream_io, entry.name)
46
50
  end
47
51
  stream.close_entry
48
52
  end
49
53
  end
50
- stream.close
54
+ stream_io.close
51
55
  end
52
56
  end
53
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presso
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burt Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Easy zip and unzip, backed by java.util.zip
14
14
  email: