seven_zip_ruby 1.0.0-x86-mswin32-100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +39 -0
- data/README.md +176 -0
- data/Rakefile +47 -0
- data/lib/seven_zip_ruby.rb +16 -0
- data/lib/seven_zip_ruby/7z.dll +0 -0
- data/lib/seven_zip_ruby/7z64.dll +0 -0
- data/lib/seven_zip_ruby/archive_info.rb +21 -0
- data/lib/seven_zip_ruby/entry_info.rb +45 -0
- data/lib/seven_zip_ruby/exception.rb +7 -0
- data/lib/seven_zip_ruby/seven_zip_archive.so +0 -0
- data/lib/seven_zip_ruby/seven_zip_reader.rb +180 -0
- data/lib/seven_zip_ruby/seven_zip_writer.rb +143 -0
- data/lib/seven_zip_ruby/update_info.rb +116 -0
- data/lib/seven_zip_ruby/version.rb +3 -0
- data/seven_zip_ruby.gemspec +28 -0
- data/spec/seven_zip_ruby_spec.rb +490 -0
- data/spec/seven_zip_ruby_spec_helper.rb +122 -0
- metadata +109 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require("fileutils")
|
4
|
+
require("rbconfig")
|
5
|
+
|
6
|
+
module SevenZipRubySpecHelper
|
7
|
+
DETAIL_CHECK = true
|
8
|
+
|
9
|
+
BASE_DIR = __dir__
|
10
|
+
TEMP_DIR = File.expand_path("../tmp", __dir__)
|
11
|
+
|
12
|
+
SAMPLE_FILE_DIR_RELATIVE = "sample_file"
|
13
|
+
SAMPLE_FILE_DIR = File.expand_path(SAMPLE_FILE_DIR_RELATIVE, TEMP_DIR)
|
14
|
+
|
15
|
+
EXTRACT_DIR_RELATIVE = "extract"
|
16
|
+
EXTRACT_DIR = File.expand_path(EXTRACT_DIR_RELATIVE, TEMP_DIR)
|
17
|
+
|
18
|
+
SAMPLE_DATA = [
|
19
|
+
{ name: "ascii_file.txt", data: "ASCII Files", directory: false },
|
20
|
+
{ name: "empty_file.txt", data: "", directory: false },
|
21
|
+
{ name: "directory", directory: true },
|
22
|
+
{ name: "directory/utf8_file.txt", data: "日本語のファイル".force_encoding("ASCII-8BIT"), directory: false },
|
23
|
+
{ name: "directory/utf8_name®.txt", data: "日本語のファイル".force_encoding("ASCII-8BIT"), directory: false },
|
24
|
+
{ name: "empty_directory", directory: true }
|
25
|
+
]
|
26
|
+
|
27
|
+
SAMPLE_LARGE_RANDOM_DATA = (0...100000).to_a.pack("L*")
|
28
|
+
SAMPLE_LARGE_RANDOM_DATA_TIMESTAMP = Time.utc(2013, 10, 22)
|
29
|
+
|
30
|
+
SEVEN_ZIP_FILE = File.expand_path("seven_zip.7z", TEMP_DIR)
|
31
|
+
SEVEN_ZIP_PASSWORD_FILE = File.expand_path("seven_zip_password.7z", TEMP_DIR)
|
32
|
+
SEVEN_ZIP_PASSWORD = "123 456"
|
33
|
+
|
34
|
+
|
35
|
+
class << self
|
36
|
+
def my_system(str)
|
37
|
+
`#{str}`
|
38
|
+
raise "System failed: #{str}" unless ($?.exitstatus == 0)
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def prepare_each
|
43
|
+
cleanup_each
|
44
|
+
end
|
45
|
+
|
46
|
+
def cleanup_each
|
47
|
+
FileUtils.rmtree(EXTRACT_DIR) if (File.exist?(EXTRACT_DIR))
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def prepare_all
|
52
|
+
cleanup_all
|
53
|
+
|
54
|
+
prepare_sample_file
|
55
|
+
prepare_seven_zip_file
|
56
|
+
end
|
57
|
+
|
58
|
+
def prepare_sample_file
|
59
|
+
FileUtils.mkpath(SAMPLE_FILE_DIR)
|
60
|
+
Dir.chdir(SAMPLE_FILE_DIR) do
|
61
|
+
SAMPLE_DATA.each do |item|
|
62
|
+
if (item[:directory])
|
63
|
+
FileUtils.mkpath(item[:name])
|
64
|
+
else
|
65
|
+
File.open(item[:name], "wb"){ |file| file.write(item[:data]) }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def prepare_seven_zip_file
|
72
|
+
Dir.chdir(SAMPLE_FILE_DIR) do
|
73
|
+
my_system("7z a -bd \"#{SEVEN_ZIP_FILE}\" *")
|
74
|
+
my_system("7z a -bd \"-p#{SEVEN_ZIP_PASSWORD}\" \"#{SEVEN_ZIP_PASSWORD_FILE}\" *")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def cleanup_all
|
80
|
+
cleanup_seven_zip_file
|
81
|
+
cleanup_sample_file
|
82
|
+
end
|
83
|
+
|
84
|
+
def cleanup_sample_file
|
85
|
+
FileUtils.rmtree(SAMPLE_FILE_DIR) if (File.exist?(SAMPLE_FILE_DIR))
|
86
|
+
end
|
87
|
+
|
88
|
+
def cleanup_seven_zip_file
|
89
|
+
FileUtils.rmtree(SEVEN_ZIP_FILE) if (File.exist?(SEVEN_ZIP_FILE))
|
90
|
+
FileUtils.rmtree(SEVEN_ZIP_PASSWORD_FILE) if (File.exist?(SEVEN_ZIP_PASSWORD_FILE))
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def processor_count
|
95
|
+
return @processor_count unless (@processor_count.nil?)
|
96
|
+
|
97
|
+
if (RbConfig::CONFIG["target_os"].match(/mingw|mswin/))
|
98
|
+
# Windows
|
99
|
+
require("win32ole")
|
100
|
+
@processor_count = WIN32OLE.connect("winmgmts://")
|
101
|
+
.ExecQuery("SELECT NumberOfLogicalProcessors from Win32_Processor")
|
102
|
+
.to_enum(:each).map(&:NumberOfLogicalProcessors).reduce(:+)
|
103
|
+
elsif (File.exist?("/proc/cpuinfo"))
|
104
|
+
# Linux
|
105
|
+
@processor_count = File.open("/proc/cpuinfo", &:read).scan(/^processor/).size
|
106
|
+
elsif (RbConfig::CONFIG["target_os"].include?("darwin"))
|
107
|
+
# Mac
|
108
|
+
begin
|
109
|
+
@processor_count = `sysctl hw.ncpu`.split(":").last.to_i
|
110
|
+
rescue
|
111
|
+
@processor_count = false
|
112
|
+
end
|
113
|
+
else
|
114
|
+
# Unknown
|
115
|
+
@processor_count = false
|
116
|
+
end
|
117
|
+
|
118
|
+
return @processor_count
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: seven_zip_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: x86-mswin32-100
|
6
|
+
authors:
|
7
|
+
- Masamitsu MURASE
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: SevenZipRuby is a gem library to read and write 7zip archives. This gem
|
56
|
+
library calls official 7z.dll internally.
|
57
|
+
email:
|
58
|
+
- masamitsu.murase@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- lib/seven_zip_ruby.rb
|
70
|
+
- lib/seven_zip_ruby/7z.dll
|
71
|
+
- lib/seven_zip_ruby/7z64.dll
|
72
|
+
- lib/seven_zip_ruby/archive_info.rb
|
73
|
+
- lib/seven_zip_ruby/entry_info.rb
|
74
|
+
- lib/seven_zip_ruby/exception.rb
|
75
|
+
- lib/seven_zip_ruby/seven_zip_reader.rb
|
76
|
+
- lib/seven_zip_ruby/seven_zip_writer.rb
|
77
|
+
- lib/seven_zip_ruby/update_info.rb
|
78
|
+
- lib/seven_zip_ruby/version.rb
|
79
|
+
- seven_zip_ruby.gemspec
|
80
|
+
- spec/seven_zip_ruby_spec.rb
|
81
|
+
- spec/seven_zip_ruby_spec_helper.rb
|
82
|
+
- lib/seven_zip_ruby/seven_zip_archive.so
|
83
|
+
homepage: https://github.com/masamitsu-murase/seven_zip_ruby
|
84
|
+
licenses:
|
85
|
+
- LGPL + unRAR
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.0.3
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: This is a gem library to read and write 7-Zip files.
|
107
|
+
test_files:
|
108
|
+
- spec/seven_zip_ruby_spec.rb
|
109
|
+
- spec/seven_zip_ruby_spec_helper.rb
|