seven_zip_ruby 1.2.0-x86-mswin32-100 → 1.2.1-x86-mswin32-100

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: c5f76d2c9638a3a822cf5857fd882751e10b08fb
4
- data.tar.gz: df3d399ba030d7877763bba565c53ee3601408e5
3
+ metadata.gz: a2591f2e4d7e5ffae2721a4fd74b3e3b37b5e396
4
+ data.tar.gz: 926dbe103501613ac3a842e1d62fef8928f4210b
5
5
  SHA512:
6
- metadata.gz: f703eb23188d2097dc2ea3c63bacb8487e86e611076d80a3465d7e45e92ad4834fc073b2301d98d3dcbb796e91aff0045831a0d65137000f795474af9b03c1e3
7
- data.tar.gz: 93a2e680ea29f54d5f169725f66ed22c49cb69459677bc3a4ff3d2a1a1d99c7c66af1a179a8577e76ac95fdf2513b161eef95835f2495c61f4b46e3c2f6d455a
6
+ metadata.gz: a420230781f066b54d1d95f5a61c46533a9186e2ded940fcdf137d4bb7dc6273fd94de2db88b1b73bae8a841920d446ef164e60e30d1eb7fba8ef020cd5d779d
7
+ data.tar.gz: ef32b145deb0ec70aec3fee472f40bc7c57fe2acec41ad1a370f0a1e6cce792c0fe7de25f2be31901c29580d0d57a8f92d349bc3232fe1d9a65f62e0f51d46e8
@@ -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-mswin32-100
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