seven_zip_ruby 1.2.0-x86-mingw32 → 1.2.1-x86-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: 8196c94279f08f664188803a8007c5a992c31685
4
- data.tar.gz: c819c78dbd780e420f54206b11dab937542a3982
3
+ metadata.gz: 91f7b44889e262c53f68a16bff9ca709503fd8a3
4
+ data.tar.gz: 0bdca3000310e5f74b3322aa49d6a5fea1e6acf6
5
5
  SHA512:
6
- metadata.gz: 96ed7cd28a07c35fd16492d5733ae12e3a48255cce18fbcf190a6175ce89030546ca0c01f787990dbb1edcddd809c01da1dc380cdcb43d44355a779efb196342
7
- data.tar.gz: 5cad6570612584dbc85e30ff19f24182a5d497b96c0852ad7945e3e73c758eafacef5d4103e0e542efb000e003e7e1dee3c9264b9f6ba697ac35e9fa7d26e3cd
6
+ metadata.gz: 689ffdae9d3e90ffa4bee9790c8db0a710fdd96eb9d2b834e934e4d4456804d923923e3eded0f6c67493b0bbfe7698feaf13c8910b0942810f78f9c7d84fcaab
7
+ data.tar.gz: 05026822e8d1d3d25a9181f2c47351494b3c6e046ccc01afb0b3e75fca91df9dc9a1d8843d30c09a85cd2fcb76de6266f7b8f49e280f19351719a6c8a9150875
@@ -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, param)
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, param)
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
- return test_all_impl(nil)
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
- return test_all_impl(true)
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
- extract_files_impl(index_list, file_proc(path))
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
- extract_impl(index.to_i, file_proc(path))
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
- extract_all_impl(file_proc(File.expand_path(dir)))
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
- extract_all_impl(data_proc(ret, idx_prj))
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
- extract_files_impl(index_list, data_proc(ret, idx_prj))
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
- extract_impl(index, data_proc(ret, idx_prj))
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
- compress_impl(compress_proc)
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
 
@@ -1,3 +1,3 @@
1
1
  module SevenZipRuby
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -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.0
4
+ version: 1.2.1
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - Masamitsu MURASE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler