presso 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/presso.rb +11 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e5f35bdc09fa0c12db4f0f539428643b5ea1ed
|
4
|
+
data.tar.gz: 1adb07ec20aabb8751fbc0a7f68327f5f6568751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
22
|
-
IO.copy_stream(path,
|
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.
|
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
|
-
|
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(
|
49
|
+
IO.copy_stream(stream_io, entry.name)
|
46
50
|
end
|
47
51
|
stream.close_entry
|
48
52
|
end
|
49
53
|
end
|
50
|
-
|
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.
|
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-
|
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:
|