seven_zip_ruby 1.2.0-x64-mingw32 → 1.2.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7bfc97460839b982620b9d95aa1f26b08924d94
|
4
|
+
data.tar.gz: ff5be17cb064e3bc71ca92bb9d6abe31c6ec36d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1450a3b36d11412ce3c06eb44156ee9d55c74d13f7e786f99f915302e246a630d7c47cb47855f2fd247e17b85f891aa9b132caf115f028376c04b79385a88c1f
|
7
|
+
data.tar.gz: 5a2da147ee99299f721a60785fa4ac427463f5e9c2e3d8492c62ce8b00c9443e2150c9da65078436b7b4edfc6873ef16b23b1ee4c4fe022a801ae33e5109aa34
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require("stringio")
|
2
|
+
require("thread")
|
2
3
|
|
3
4
|
module SevenZipRuby
|
4
5
|
|
@@ -165,7 +166,7 @@ module SevenZipRuby
|
|
165
166
|
def extract(stream, index, dir = ".", param = {})
|
166
167
|
password = { password: param.delete(:password) }
|
167
168
|
self.open(stream, password) do |szr|
|
168
|
-
szr.extract(index, dir
|
169
|
+
szr.extract(index, dir)
|
169
170
|
end
|
170
171
|
end
|
171
172
|
|
@@ -183,7 +184,7 @@ module SevenZipRuby
|
|
183
184
|
def extract_all(stream, dir = ".", param = {})
|
184
185
|
password = { password: param.delete(:password) }
|
185
186
|
self.open(stream, password) do |szr|
|
186
|
-
szr.extract_all(dir
|
187
|
+
szr.extract_all(dir)
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
@@ -267,7 +268,9 @@ module SevenZipRuby
|
|
267
268
|
# end
|
268
269
|
def test
|
269
270
|
begin
|
270
|
-
|
271
|
+
synchronize do
|
272
|
+
return test_all_impl(nil)
|
273
|
+
end
|
271
274
|
rescue
|
272
275
|
return false
|
273
276
|
end
|
@@ -288,7 +291,9 @@ module SevenZipRuby
|
|
288
291
|
# end
|
289
292
|
def verify_detail
|
290
293
|
begin
|
291
|
-
|
294
|
+
synchronize do
|
295
|
+
return test_all_impl(true)
|
296
|
+
end
|
292
297
|
rescue
|
293
298
|
return nil
|
294
299
|
end
|
@@ -320,11 +325,15 @@ module SevenZipRuby
|
|
320
325
|
return extract_all(path)
|
321
326
|
when Enumerable
|
322
327
|
index_list = index.map(&:to_i).sort.uniq
|
323
|
-
|
328
|
+
synchronize do
|
329
|
+
extract_files_impl(index_list, file_proc(path))
|
330
|
+
end
|
324
331
|
when nil
|
325
332
|
raise ArgumentError.new("Invalid parameter index")
|
326
333
|
else
|
327
|
-
|
334
|
+
synchronize do
|
335
|
+
extract_impl(index.to_i, file_proc(path))
|
336
|
+
end
|
328
337
|
end
|
329
338
|
end
|
330
339
|
|
@@ -340,7 +349,9 @@ module SevenZipRuby
|
|
340
349
|
# end
|
341
350
|
# end
|
342
351
|
def extract_all(dir = ".")
|
343
|
-
|
352
|
+
synchronize do
|
353
|
+
extract_all_impl(file_proc(File.expand_path(dir)))
|
354
|
+
end
|
344
355
|
end
|
345
356
|
|
346
357
|
# Extract entires of 7zip archive to local directory based on the block return value.
|
@@ -393,7 +404,9 @@ module SevenZipRuby
|
|
393
404
|
end
|
394
405
|
|
395
406
|
ret = []
|
396
|
-
|
407
|
+
synchronize do
|
408
|
+
extract_all_impl(data_proc(ret, idx_prj))
|
409
|
+
end
|
397
410
|
return ret
|
398
411
|
|
399
412
|
when Enumerable
|
@@ -401,7 +414,9 @@ module SevenZipRuby
|
|
401
414
|
idx_prj = Hash[*(index_list.each_with_index.map{ |idx, i| [ idx, i ] }.flatten)]
|
402
415
|
|
403
416
|
ret = []
|
404
|
-
|
417
|
+
synchronize do
|
418
|
+
extract_files_impl(index_list, data_proc(ret, idx_prj))
|
419
|
+
end
|
405
420
|
return ret
|
406
421
|
|
407
422
|
when nil
|
@@ -418,7 +433,9 @@ module SevenZipRuby
|
|
418
433
|
end
|
419
434
|
|
420
435
|
ret = []
|
421
|
-
|
436
|
+
synchronize do
|
437
|
+
extract_impl(index, data_proc(ret, idx_prj))
|
438
|
+
end
|
422
439
|
return ret[0]
|
423
440
|
|
424
441
|
end
|
@@ -482,6 +499,18 @@ module SevenZipRuby
|
|
482
499
|
end
|
483
500
|
end
|
484
501
|
private :data_proc
|
502
|
+
|
503
|
+
COMPRESS_GUARD = Mutex.new # :nodoc:
|
504
|
+
def synchronize # :nodoc:
|
505
|
+
if (COMPRESS_GUARD)
|
506
|
+
COMPRESS_GUARD.synchronize do
|
507
|
+
yield
|
508
|
+
end
|
509
|
+
else
|
510
|
+
yield
|
511
|
+
end
|
512
|
+
end
|
513
|
+
private :synchronize
|
485
514
|
end
|
486
515
|
|
487
516
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require("stringio")
|
2
|
+
require("thread")
|
2
3
|
|
3
4
|
module SevenZipRuby
|
4
5
|
|
@@ -253,7 +254,9 @@ module SevenZipRuby
|
|
253
254
|
# szw.close
|
254
255
|
# end
|
255
256
|
def compress
|
256
|
-
|
257
|
+
synchronize do
|
258
|
+
compress_impl(compress_proc)
|
259
|
+
end
|
257
260
|
return self
|
258
261
|
end
|
259
262
|
|
@@ -421,6 +424,18 @@ module SevenZipRuby
|
|
421
424
|
end
|
422
425
|
end
|
423
426
|
private :compress_proc
|
427
|
+
|
428
|
+
COMPRESS_GUARD = Mutex.new # :nodoc:
|
429
|
+
def synchronize # :nodoc:
|
430
|
+
if (COMPRESS_GUARD)
|
431
|
+
COMPRESS_GUARD.synchronize do
|
432
|
+
yield
|
433
|
+
end
|
434
|
+
else
|
435
|
+
yield
|
436
|
+
end
|
437
|
+
end
|
438
|
+
private :synchronize
|
424
439
|
end
|
425
440
|
|
426
441
|
|
data/spec/seven_zip_ruby_spec.rb
CHANGED
@@ -79,6 +79,24 @@ describe SevenZipRuby do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
example "singleton method: extract" do
|
83
|
+
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_FILE, "rb") do |file|
|
84
|
+
SevenZipRuby::SevenZipReader.extract(file, :all, SevenZipRubySpecHelper::EXTRACT_DIR)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
example "singleton method: extract_all" do
|
89
|
+
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_FILE, "rb") do |file|
|
90
|
+
SevenZipRuby::SevenZipReader.extract_all(file, SevenZipRubySpecHelper::EXTRACT_DIR)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
example "singleton method: verify" do
|
95
|
+
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_FILE, "rb") do |file|
|
96
|
+
SevenZipRuby::SevenZipReader.verify(file)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
82
100
|
example "extract archive" do
|
83
101
|
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_FILE, "rb") do |file|
|
84
102
|
SevenZipRuby::SevenZipReader.open(file) do |szr|
|
@@ -144,6 +162,28 @@ describe SevenZipRuby do
|
|
144
162
|
end
|
145
163
|
end
|
146
164
|
|
165
|
+
example "run in multi threads" do
|
166
|
+
s = StringIO.new
|
167
|
+
SevenZipRuby::SevenZipWriter.open(s) do |szw|
|
168
|
+
szw.add_data(SevenZipRubySpecHelper::SAMPLE_LARGE_RANDOM_DATA, "data.bin")
|
169
|
+
end
|
170
|
+
data = s.string
|
171
|
+
|
172
|
+
th_list = []
|
173
|
+
100.times do
|
174
|
+
th = Thread.new do
|
175
|
+
stream = StringIO.new(data)
|
176
|
+
SevenZipRuby::SevenZipReader.open(stream) do |szr|
|
177
|
+
szr.extract_data(0)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
th_list.push(th)
|
181
|
+
end
|
182
|
+
th_list.each do |t|
|
183
|
+
t.join
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
147
187
|
|
148
188
|
describe "error handling" do
|
149
189
|
|
@@ -470,6 +510,24 @@ describe SevenZipRuby do
|
|
470
510
|
expect(size.sort.reverse).to eq size
|
471
511
|
end
|
472
512
|
|
513
|
+
example "run in multi threads" do
|
514
|
+
th_list = []
|
515
|
+
mutex = Mutex.new
|
516
|
+
100.times do
|
517
|
+
th = Thread.new do
|
518
|
+
stream = StringIO.new
|
519
|
+
SevenZipRuby::SevenZipWriter.open(stream) do |szw|
|
520
|
+
data = SevenZipRubySpecHelper::SAMPLE_LARGE_RANDOM_DATA
|
521
|
+
szw.add_data(data, "hoge.dat")
|
522
|
+
end
|
523
|
+
end
|
524
|
+
th_list.push(th)
|
525
|
+
end
|
526
|
+
th_list.each do |t|
|
527
|
+
t.join
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
473
531
|
if (SevenZipRubySpecHelper.processor_count && SevenZipRubySpecHelper.processor_count > 1)
|
474
532
|
example "set multi_thread" do
|
475
533
|
time = [ false, true ].map do |multi_thread|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seven_zip_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- Masamitsu MURASE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|