seven_zip_ruby 1.2.4-x64-mingw32 → 1.2.5-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +21 -5
- data/README.md +11 -0
- data/Rakefile +9 -1
- data/lib/seven_zip_ruby/7z.sfx +0 -0
- data/lib/seven_zip_ruby/7zCon.sfx +0 -0
- data/lib/seven_zip_ruby/seven_zip_reader.rb +1 -0
- data/lib/seven_zip_ruby/seven_zip_writer.rb +71 -13
- data/lib/seven_zip_ruby/version.rb +1 -1
- data/seven_zip_ruby.gemspec +31 -28
- data/spec/seven_zip_ruby_spec.rb +78 -10
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b7159795d1217f1ab2df4380632b03d2491d7f5
|
4
|
+
data.tar.gz: 1ab84afecf3443f733346e089cb2d8f6cace55e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96447e04d3cf1f0bb9bfa2f1a6554af910327ab7011ffac055badcd5537dd4a55b7103da52177482c4e32f639dca5a0011e2c5cbad5527658fccd214b4b7e302
|
7
|
+
data.tar.gz: 8310f52e5cd2d8329e319161e68b80f314eccd60121fef128fc9f980f571d88aee54d2de8244dfde85ce087024354bac7dafdd80908ec54db407b180051b0cda
|
data/.travis.yml
CHANGED
@@ -1,19 +1,35 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- "2.0
|
4
|
-
- "2.1
|
5
|
-
- "
|
3
|
+
- "2.0"
|
4
|
+
- "2.1"
|
5
|
+
- "2.2"
|
6
|
+
- "2.3.0"
|
7
|
+
- "2.3"
|
8
|
+
- "rbx-2.2.7"
|
6
9
|
- "ruby-head"
|
7
10
|
matrix:
|
8
11
|
allow_failures:
|
9
|
-
- rvm: "rbx-2"
|
12
|
+
- rvm: "rbx-2.2.7"
|
10
13
|
- rvm: "ruby-head"
|
14
|
+
include:
|
15
|
+
- rvm: 2.3.1
|
16
|
+
os: osx
|
17
|
+
osx_image: xcode7.3
|
11
18
|
notifications:
|
12
19
|
email: false
|
13
20
|
cache:
|
14
21
|
- apt
|
15
22
|
before_install:
|
23
|
+
- gem update bundler
|
16
24
|
- bundle install --path=vendor/bundle
|
17
|
-
-
|
25
|
+
- case $TRAVIS_OS_NAME in
|
26
|
+
linux)
|
27
|
+
sudo apt-get install p7zip-full
|
28
|
+
;;
|
29
|
+
osx)
|
30
|
+
brew update && brew tap wk8/p7zip9.20 && brew install p7zip920
|
31
|
+
;;
|
32
|
+
esac
|
33
|
+
|
18
34
|
install: bundle exec rake build_local
|
19
35
|
script: bundle exec rspec spec/seven_zip_ruby_spec.rb
|
data/README.md
CHANGED
@@ -148,6 +148,17 @@ File.open("filename.7z", "rb") do |file|
|
|
148
148
|
end
|
149
149
|
```
|
150
150
|
|
151
|
+
You can also create a self extracting archive for Windows.
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
File.open("filename.exe", "rb") do |file|
|
155
|
+
# :gui and :console can be specified as :sfx parameter.
|
156
|
+
SevenZipRuby::Writer.open(file, sfx: :gui) do |szr|
|
157
|
+
szr.add_data "file content", "file.txt"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
151
162
|
### Set compression mode
|
152
163
|
|
153
164
|
7zip supports LZMA, LZMA2, PPMD, BZIP2, DEFLATE and COPY.
|
data/Rakefile
CHANGED
@@ -9,7 +9,15 @@ task :build_platform => [ :pre_platform, :build, :post_platform ]
|
|
9
9
|
|
10
10
|
task :pre_platform do
|
11
11
|
FileUtils.mv("seven_zip_ruby.gemspec", "seven_zip_ruby.gemspec.bak")
|
12
|
-
|
12
|
+
|
13
|
+
versions = Dir.glob("lib/seven_zip_ruby/*").select{ |i| File.directory?(i) }.map{ |i| i.split("/").last }.sort_by{ |i| i.split(".").map(&:to_i) }
|
14
|
+
min_version = versions.first + ".0"
|
15
|
+
max_version = versions.last.split(".").first + "." + (versions.last.split(".").last.to_i + 1).to_s + ".0"
|
16
|
+
gemspec = File.open("resources/seven_zip_ruby.gemspec.platform", "r", &:read)
|
17
|
+
.gsub("SPEC_REQUIRED_RUBY_VERSION"){ "spec.required_ruby_version = [ '>= #{min_version}', '< #{max_version}' ]" }
|
18
|
+
File.open("seven_zip_ruby.gemspec", "w") do |f|
|
19
|
+
f.write(gemspec)
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
task :post_platform do
|
Binary file
|
Binary file
|
@@ -51,10 +51,26 @@ module SevenZipRuby
|
|
51
51
|
# szw.add_directory("test_dir")
|
52
52
|
# end
|
53
53
|
# end
|
54
|
+
#
|
55
|
+
# === Create a sfx, a self extracting archive for Windows executable binary.
|
56
|
+
# File.open("filename.exe", "wb") do |file|
|
57
|
+
# SevenZipRuby::SevenZipWriter.open(file, sfx: true) do |szw|
|
58
|
+
# szw.add_directory("test_dir")
|
59
|
+
# end
|
60
|
+
# end
|
54
61
|
class SevenZipWriter
|
55
62
|
# Encoding used for path string in 7zip archive.
|
56
63
|
PATH_ENCODING = Encoding::UTF_8
|
57
64
|
|
65
|
+
# Files for self extraction.
|
66
|
+
SFX_FILE_LIST = {
|
67
|
+
default: File.expand_path("../7z.sfx", __FILE__),
|
68
|
+
gui: File.expand_path("../7z.sfx", __FILE__),
|
69
|
+
console: File.expand_path("../7zCon.sfx", __FILE__)
|
70
|
+
} # :nodoc:
|
71
|
+
|
72
|
+
OPEN_PARAM_LIST = [ :password, :sfx ] # :nodoc:
|
73
|
+
|
58
74
|
@use_native_input_file_stream = true
|
59
75
|
|
60
76
|
class << self
|
@@ -64,10 +80,12 @@ module SevenZipRuby
|
|
64
80
|
#
|
65
81
|
# ==== Args
|
66
82
|
# +stream+ :: Output stream to write 7zip archive. <tt>stream.write</tt> is needed.
|
67
|
-
# +param+ :: Optional hash parameter.
|
83
|
+
# +param+ :: Optional hash parameter.
|
84
|
+
# <tt>:password</tt> key specifies password of this archive.
|
85
|
+
# <tt>:sfx</tt> key specifies Self Extracting mode. <tt>:gui</tt> and <tt>:console</tt> can be used. <tt>true</tt> is same as <tt>:gui</tt>.
|
68
86
|
#
|
69
87
|
# ==== Examples
|
70
|
-
# # Open archive
|
88
|
+
# # Open an archive
|
71
89
|
# File.open("filename.7z", "wb") do |file|
|
72
90
|
# SevenZipRuby::SevenZipWriter.open(file) do |szw|
|
73
91
|
# # Create archive.
|
@@ -84,6 +102,14 @@ module SevenZipRuby
|
|
84
102
|
# szw.compress # Compress must be called in this case.
|
85
103
|
# szw.close
|
86
104
|
# end
|
105
|
+
#
|
106
|
+
# # Create a self extracting archive. <tt>:gui</tt> and <tt>:console</tt> can be used.
|
107
|
+
# File.open("filename.7z", "wb") do |file|
|
108
|
+
# szw = SevenZipRuby::SevenZipWriter.open(file, sfx: :gui)
|
109
|
+
# # Create archive.
|
110
|
+
# szw.compress # Compress must be called in this case.
|
111
|
+
# szw.close
|
112
|
+
# end
|
87
113
|
def open(stream, param = {}, &block) # :yield: szw
|
88
114
|
szw = self.new
|
89
115
|
szw.open(stream, param)
|
@@ -104,7 +130,9 @@ module SevenZipRuby
|
|
104
130
|
#
|
105
131
|
# ==== Args
|
106
132
|
# +filename+ :: 7zip archive filename.
|
107
|
-
# +param+ :: Optional hash parameter.
|
133
|
+
# +param+ :: Optional hash parameter.
|
134
|
+
# <tt>:password</tt> key specifies password of this archive.
|
135
|
+
# <tt>:sfx</tt> key specifies Self Extracting mode. <tt>:gui</tt> and <tt>:console</tt> can be used. <tt>true</tt> is same as <tt>:gui</tt>.
|
108
136
|
#
|
109
137
|
# ==== Examples
|
110
138
|
# # Open archive
|
@@ -141,7 +169,9 @@ module SevenZipRuby
|
|
141
169
|
# ==== Args
|
142
170
|
# +stream+ :: Output stream to write 7zip archive. <tt>stream.write</tt> is needed.
|
143
171
|
# +dir+ :: Directory to be added to the 7zip archive. <b><tt>dir</tt></b> must be a <b>relative path</b>.
|
144
|
-
# +param+ :: Optional hash parameter.
|
172
|
+
# +param+ :: Optional hash parameter.
|
173
|
+
# <tt>:password</tt> key specifies password of this archive.
|
174
|
+
# <tt>:sfx</tt> key specifies Self Extracting mode. <tt>:gui</tt> and <tt>:console</tt> can be used. <tt>true</tt> is same as <tt>:gui</tt>.
|
145
175
|
#
|
146
176
|
# ==== Examples
|
147
177
|
# # Create 7zip archive which includes 'dir'.
|
@@ -149,9 +179,11 @@ module SevenZipRuby
|
|
149
179
|
# SevenZipRuby::SevenZipWriter.add_directory(file, 'dir')
|
150
180
|
# end
|
151
181
|
def add_directory(stream, dir, param = {})
|
152
|
-
|
153
|
-
|
154
|
-
|
182
|
+
param = param.clone
|
183
|
+
open_param = {}
|
184
|
+
OPEN_PARAM_LIST.each do |key|
|
185
|
+
open_param[key] = param.delete(key) if param.key?(key)
|
186
|
+
end
|
155
187
|
self.open(stream, open_param) do |szw|
|
156
188
|
szw.add_directory(dir, param)
|
157
189
|
end
|
@@ -163,7 +195,9 @@ module SevenZipRuby
|
|
163
195
|
# ==== Args
|
164
196
|
# +stream+ :: Output stream to write 7zip archive. <tt>stream.write</tt> is needed.
|
165
197
|
# +file+ :: File to be added to the 7zip archive. <b><tt>file</tt></b> must be a <b>relative path</b>.
|
166
|
-
# +param+ :: Optional hash parameter.
|
198
|
+
# +param+ :: Optional hash parameter.
|
199
|
+
# <tt>:password</tt> key specifies password of this archive.
|
200
|
+
# <tt>:sfx</tt> key specifies Self Extracting mode. <tt>:gui</tt> and <tt>:console</tt> can be used. <tt>true</tt> is same as <tt>:gui</tt>.
|
167
201
|
#
|
168
202
|
# ==== Examples
|
169
203
|
# # Create 7zip archive which includes 'file.txt'.
|
@@ -171,9 +205,11 @@ module SevenZipRuby
|
|
171
205
|
# SevenZipRuby::SevenZipWriter.add_file(file, 'file.txt')
|
172
206
|
# end
|
173
207
|
def add_file(stream, filename, param = {})
|
174
|
-
|
175
|
-
|
176
|
-
|
208
|
+
param = param.clone
|
209
|
+
open_param = {}
|
210
|
+
OPEN_PARAM_LIST.each do |key|
|
211
|
+
open_param[key] = param.delete(key) if param.key?(key)
|
212
|
+
end
|
177
213
|
self.open(stream, open_param) do |szw|
|
178
214
|
szw.add_file(filename, param)
|
179
215
|
end
|
@@ -186,7 +222,9 @@ module SevenZipRuby
|
|
186
222
|
#
|
187
223
|
# ==== Args
|
188
224
|
# +stream+ :: Output stream to write 7zip archive. <tt>stream.write</tt> is needed.
|
189
|
-
# +param+ :: Optional hash parameter.
|
225
|
+
# +param+ :: Optional hash parameter.
|
226
|
+
# <tt>:password</tt> key specifies password of this archive.
|
227
|
+
# <tt>:sfx</tt> key specifies Self Extracting mode. <tt>:gui</tt> and <tt>:console</tt> can be used. <tt>true</tt> is same as <tt>:gui</tt>.
|
190
228
|
#
|
191
229
|
# ==== Examples
|
192
230
|
# File.open("filename.7z", "wb") do |file|
|
@@ -197,16 +235,25 @@ module SevenZipRuby
|
|
197
235
|
# szw.close
|
198
236
|
# end
|
199
237
|
def open(stream, param = {})
|
238
|
+
param = param.clone
|
239
|
+
param[:password] = param[:password].to_s if (param[:password])
|
200
240
|
stream.set_encoding(Encoding::ASCII_8BIT)
|
241
|
+
|
242
|
+
add_sfx(stream, param[:sfx]) if param[:sfx]
|
243
|
+
|
201
244
|
open_impl(stream, param)
|
202
245
|
return self
|
203
246
|
end
|
204
247
|
|
205
248
|
# Open 7zip archive file to create.
|
206
249
|
#
|
250
|
+
# <tt>close</tt> method must be called later.
|
251
|
+
#
|
207
252
|
# ==== Args
|
208
253
|
# +filename+ :: 7zip archive filename.
|
209
|
-
# +param+ :: Optional hash parameter.
|
254
|
+
# +param+ :: Optional hash parameter.
|
255
|
+
# <tt>:password</tt> key specifies password of this archive.
|
256
|
+
# <tt>:sfx</tt> key specifies Self Extracting mode. <tt>:gui</tt> and <tt>:console</tt> can be used. <tt>true</tt> is same as <tt>:gui</tt>.
|
210
257
|
#
|
211
258
|
# ==== Examples
|
212
259
|
# szw = SevenZipRuby::SevenZipWriter.new
|
@@ -425,6 +472,17 @@ module SevenZipRuby
|
|
425
472
|
end
|
426
473
|
private :compress_proc
|
427
474
|
|
475
|
+
def add_sfx(stream, sfx)
|
476
|
+
sfx = :default if sfx == true
|
477
|
+
sfx_file = SFX_FILE_LIST[sfx]
|
478
|
+
raise ArgumentError.new("invalid option: :sfx") unless sfx_file
|
479
|
+
|
480
|
+
File.open(sfx_file, "rb") do |input|
|
481
|
+
IO.copy_stream(input, stream)
|
482
|
+
end
|
483
|
+
end
|
484
|
+
private :add_sfx
|
485
|
+
|
428
486
|
COMPRESS_GUARD = Mutex.new # :nodoc:
|
429
487
|
def synchronize # :nodoc:
|
430
488
|
if (COMPRESS_GUARD)
|
data/seven_zip_ruby.gemspec
CHANGED
@@ -1,28 +1,31 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'seven_zip_ruby/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "seven_zip_ruby"
|
8
|
-
spec.version = SevenZipRuby::VERSION
|
9
|
-
spec.authors = ["Masamitsu MURASE"]
|
10
|
-
spec.email = ["masamitsu.murase@gmail.com"]
|
11
|
-
spec.description = %q{SevenZipRuby (seven_zip_ruby) is a ruby gem library to read and write 7zip archives. This gem library calls official 7z.dll internally.}
|
12
|
-
spec.summary = %q{This is a ruby gem library to read and write 7zip files.}
|
13
|
-
spec.homepage = "https://github.com/masamitsu-murase/seven_zip_ruby"
|
14
|
-
spec.license = "LGPL + unRAR"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/).select{ |i| !(i.start_with?("pkg") || i.start_with?("resources") || i.start_with?("ext")) } + Dir.glob("lib/**/*.so").to_a
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.
|
22
|
-
spec.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'seven_zip_ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "seven_zip_ruby"
|
8
|
+
spec.version = SevenZipRuby::VERSION
|
9
|
+
spec.authors = ["Masamitsu MURASE"]
|
10
|
+
spec.email = ["masamitsu.murase@gmail.com"]
|
11
|
+
spec.description = %q{SevenZipRuby (seven_zip_ruby) is a ruby gem library to read and write 7zip archives. This gem library calls official 7z.dll internally.}
|
12
|
+
spec.summary = %q{This is a ruby gem library to read and write 7zip files.}
|
13
|
+
spec.homepage = "https://github.com/masamitsu-murase/seven_zip_ruby"
|
14
|
+
spec.license = "LGPL + unRAR"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/).select{ |i| !(i.start_with?("pkg") || i.start_with?("resources") || i.start_with?("ext")) } + Dir.glob("lib/**/*.so").to_a
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# spec.required_ruby_version = '>= 2.0.0'
|
22
|
+
spec.required_ruby_version = [ '>= 2.0.0', '< 2.4.0' ]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
|
28
|
+
# spec.extensions << "ext/seven_zip_ruby/extconf.rb"
|
29
|
+
|
30
|
+
spec.platform = Gem::Platform::CURRENT
|
31
|
+
end
|
data/spec/seven_zip_ruby_spec.rb
CHANGED
@@ -206,7 +206,7 @@ describe SevenZipRuby do
|
|
206
206
|
example "invalid index" do
|
207
207
|
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_FILE, "rb") do |file|
|
208
208
|
SevenZipRuby::SevenZipReader.open(file) do |szr|
|
209
|
-
expect{ szr.extract_data(nil) }.to raise_error
|
209
|
+
expect{ szr.extract_data(nil) }.to raise_error(ArgumentError)
|
210
210
|
end
|
211
211
|
end
|
212
212
|
end
|
@@ -214,18 +214,22 @@ describe SevenZipRuby do
|
|
214
214
|
example "invalid index for entry" do
|
215
215
|
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_FILE, "rb") do |file|
|
216
216
|
SevenZipRuby::SevenZipReader.open(file) do |szr|
|
217
|
-
expect{ szr.entry("a") }.to raise_error
|
217
|
+
expect{ szr.entry("a") }.to raise_error(TypeError)
|
218
218
|
end
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
222
|
example "invalid password" do
|
223
223
|
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_PASSWORD_FILE, "rb") do |file|
|
224
|
-
expect{ SevenZipRuby::Reader.open(file){ |szr| szr.extract_data(1) } }.to raise_error
|
224
|
+
expect{ SevenZipRuby::Reader.open(file){ |szr| szr.extract_data(1) } }.to raise_error(StandardError)
|
225
225
|
end
|
226
226
|
|
227
227
|
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_PASSWORD_FILE, "rb") do |file|
|
228
|
-
expect{ SevenZipRuby::Reader.open(file, password: "a"){ |szr| szr.extract_data(1) } }.to raise_error
|
228
|
+
expect{ SevenZipRuby::Reader.open(file, password: "a"){ |szr| szr.extract_data(1) } }.to raise_error(SevenZipRuby::InvalidArchive)
|
229
|
+
end
|
230
|
+
|
231
|
+
File.open(SevenZipRubySpecHelper::SEVEN_ZIP_PASSWORD_FILE, "rb") do |file|
|
232
|
+
expect{ SevenZipRuby::Reader.open(file, password: :InvalidType){ |szr| szr.extract_data(1) } }.to raise_error(SevenZipRuby::InvalidArchive)
|
229
233
|
end
|
230
234
|
end
|
231
235
|
|
@@ -299,8 +303,8 @@ describe SevenZipRuby do
|
|
299
303
|
end
|
300
304
|
|
301
305
|
example "clone and dup cannot be called." do
|
302
|
-
expect{ SevenZipRuby::SevenZipReader.new.clone }.to raise_error
|
303
|
-
expect{ SevenZipRuby::SevenZipReader.new.dup }.to raise_error
|
306
|
+
expect{ SevenZipRuby::SevenZipReader.new.clone }.to raise_error(NoMethodError)
|
307
|
+
expect{ SevenZipRuby::SevenZipReader.new.dup }.to raise_error(NoMethodError)
|
304
308
|
end
|
305
309
|
|
306
310
|
end
|
@@ -369,6 +373,70 @@ describe SevenZipRuby do
|
|
369
373
|
end
|
370
374
|
end
|
371
375
|
|
376
|
+
example "set password" do
|
377
|
+
sample_data = "Sample Data"
|
378
|
+
sample_password = "sample password"
|
379
|
+
|
380
|
+
output = StringIO.new("")
|
381
|
+
SevenZipRuby::SevenZipWriter.open(output, { password: sample_password }) do |szw|
|
382
|
+
szw.add_data(sample_data, "hoge.txt")
|
383
|
+
end
|
384
|
+
|
385
|
+
output.rewind
|
386
|
+
SevenZipRuby::SevenZipReader.open(output, { password: sample_password }) do |szr|
|
387
|
+
expect(szr.extract_data(0)).to eq sample_data
|
388
|
+
end
|
389
|
+
|
390
|
+
output.rewind
|
391
|
+
expect{
|
392
|
+
SevenZipRuby::SevenZipReader.open(output, { password: "invalid password" }) do |szr|
|
393
|
+
szr.extract_data(0)
|
394
|
+
end
|
395
|
+
}.to raise_error(SevenZipRuby::InvalidArchive)
|
396
|
+
|
397
|
+
|
398
|
+
output = StringIO.new("")
|
399
|
+
SevenZipRuby::SevenZipWriter.open(output, { password: sample_password.to_sym }) do |szw|
|
400
|
+
szw.add_data(sample_data, "hoge.txt")
|
401
|
+
end
|
402
|
+
|
403
|
+
output.rewind
|
404
|
+
SevenZipRuby::SevenZipReader.open(output, { password: sample_password }) do |szr|
|
405
|
+
expect(szr.extract_data(0)).to eq sample_data
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
example "create a sfx archive" do
|
410
|
+
time = Time.now
|
411
|
+
|
412
|
+
output = StringIO.new("")
|
413
|
+
SevenZipRuby::SevenZipWriter.open(output) do |szw|
|
414
|
+
szw.add_data("hogehoge", "hoge.txt", ctime: time, atime: time, mtime: time)
|
415
|
+
end
|
416
|
+
|
417
|
+
output1 = StringIO.new("")
|
418
|
+
SevenZipRuby::SevenZipWriter.open(output1, sfx: true) do |szw|
|
419
|
+
szw.add_data("hogehoge", "hoge.txt", ctime: time, atime: time, mtime: time)
|
420
|
+
end
|
421
|
+
|
422
|
+
output2 = StringIO.new("")
|
423
|
+
SevenZipRuby::SevenZipWriter.open(output2, sfx: :gui) do |szw|
|
424
|
+
szw.add_data("hogehoge", "hoge.txt", ctime: time, atime: time, mtime: time)
|
425
|
+
end
|
426
|
+
|
427
|
+
output3 = StringIO.new("")
|
428
|
+
SevenZipRuby::SevenZipWriter.open(output3, sfx: :console) do |szw|
|
429
|
+
szw.add_data("hogehoge", "hoge.txt", ctime: time, atime: time, mtime: time)
|
430
|
+
end
|
431
|
+
|
432
|
+
gui = File.open(SevenZipRuby::SevenZipWriter::SFX_FILE_LIST[:gui], "rb", &:read)
|
433
|
+
console = File.open(SevenZipRuby::SevenZipWriter::SFX_FILE_LIST[:console], "rb", &:read)
|
434
|
+
|
435
|
+
expect(output1.string).to eq gui + output.string
|
436
|
+
expect(output2.string).to eq gui + output.string
|
437
|
+
expect(output3.string).to eq console + output.string
|
438
|
+
end
|
439
|
+
|
372
440
|
[ true, false ].each do |use_native_input_file_stream|
|
373
441
|
example "add_directory: use_native_input_file_stream=#{use_native_input_file_stream}" do
|
374
442
|
SevenZipRuby::SevenZipWriter.use_native_input_file_stream = use_native_input_file_stream
|
@@ -562,11 +630,11 @@ describe SevenZipRuby do
|
|
562
630
|
end
|
563
631
|
|
564
632
|
example "invalid method" do
|
565
|
-
expect{ SevenZipRuby::SevenZipWriter.open(StringIO.new("")).method = "Unknown" }.to raise_error
|
633
|
+
expect{ SevenZipRuby::SevenZipWriter.open(StringIO.new("")).method = "Unknown" }.to raise_error(ArgumentError)
|
566
634
|
end
|
567
635
|
|
568
636
|
example "invalid level" do
|
569
|
-
expect{ SevenZipRuby::SevenZipWriter.open(StringIO.new("")).level = 2 }.to raise_error
|
637
|
+
expect{ SevenZipRuby::SevenZipWriter.open(StringIO.new("")).level = 2 }.to raise_error(ArgumentError)
|
570
638
|
end
|
571
639
|
|
572
640
|
example "add_data/mkdir/compress/close before open" do
|
@@ -592,8 +660,8 @@ describe SevenZipRuby do
|
|
592
660
|
end
|
593
661
|
|
594
662
|
example "clone and dup cannot be called." do
|
595
|
-
expect{ SevenZipRuby::SevenZipWriter.new.clone }.to raise_error
|
596
|
-
expect{ SevenZipRuby::SevenZipWriter.new.dup }.to raise_error
|
663
|
+
expect{ SevenZipRuby::SevenZipWriter.new.clone }.to raise_error(NoMethodError)
|
664
|
+
expect{ SevenZipRuby::SevenZipWriter.new.dup }.to raise_error(NoMethodError)
|
597
665
|
end
|
598
666
|
|
599
667
|
if (false && RUBY_ENGINE == "ruby")
|
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.5
|
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:
|
11
|
+
date: 2016-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,8 +67,14 @@ files:
|
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
69
|
- lib/seven_zip_ruby.rb
|
70
|
+
- lib/seven_zip_ruby/2.0/seven_zip_archive.so
|
71
|
+
- lib/seven_zip_ruby/2.1/seven_zip_archive.so
|
72
|
+
- lib/seven_zip_ruby/2.2/seven_zip_archive.so
|
73
|
+
- lib/seven_zip_ruby/2.3/seven_zip_archive.so
|
70
74
|
- lib/seven_zip_ruby/7z.dll
|
75
|
+
- lib/seven_zip_ruby/7z.sfx
|
71
76
|
- lib/seven_zip_ruby/7z64.dll
|
77
|
+
- lib/seven_zip_ruby/7zCon.sfx
|
72
78
|
- lib/seven_zip_ruby/archive_info.rb
|
73
79
|
- lib/seven_zip_ruby/entry_info.rb
|
74
80
|
- lib/seven_zip_ruby/exception.rb
|
@@ -79,8 +85,6 @@ files:
|
|
79
85
|
- seven_zip_ruby.gemspec
|
80
86
|
- spec/seven_zip_ruby_spec.rb
|
81
87
|
- spec/seven_zip_ruby_spec_helper.rb
|
82
|
-
- lib/seven_zip_ruby/2.0/seven_zip_archive.so
|
83
|
-
- lib/seven_zip_ruby/2.1/seven_zip_archive.so
|
84
88
|
homepage: https://github.com/masamitsu-murase/seven_zip_ruby
|
85
89
|
licenses:
|
86
90
|
- LGPL + unRAR
|
@@ -93,7 +97,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
97
|
requirements:
|
94
98
|
- - '>='
|
95
99
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
100
|
+
version: 2.0.0
|
101
|
+
- - <
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.4.0
|
97
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
105
|
requirements:
|
99
106
|
- - '>='
|
@@ -101,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
108
|
version: '0'
|
102
109
|
requirements: []
|
103
110
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.6.8
|
105
112
|
signing_key:
|
106
113
|
specification_version: 4
|
107
114
|
summary: This is a ruby gem library to read and write 7zip files.
|