archive-zip 0.6.0 → 0.7.0

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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/LICENSE +22 -57
  4. data/{NEWS → NEWS.md} +29 -16
  5. data/README.md +250 -0
  6. data/Rakefile +119 -76
  7. data/lib/archive/support/binary_stringio.rb +9 -2
  8. data/lib/archive/support/time.rb +2 -2
  9. data/lib/archive/zip.rb +1 -1
  10. data/lib/archive/zip/entry.rb +2 -2
  11. data/lib/archive/zip/version.rb +1 -1
  12. data/spec/archive/zip/archive_spec.rb +54 -0
  13. data/spec/archive/zip/codec/deflate/compress/checksum_spec.rb +8 -6
  14. data/spec/archive/zip/codec/deflate/compress/close_spec.rb +13 -12
  15. data/spec/archive/zip/codec/deflate/compress/crc32_spec.rb +6 -4
  16. data/spec/archive/zip/codec/deflate/compress/data_descriptor_spec.rb +17 -10
  17. data/spec/archive/zip/codec/deflate/compress/new_spec.rb +7 -5
  18. data/spec/archive/zip/codec/deflate/compress/open_spec.rb +9 -7
  19. data/spec/archive/zip/codec/deflate/compress/write_spec.rb +15 -15
  20. data/spec/archive/zip/codec/deflate/decompress/checksum_spec.rb +6 -4
  21. data/spec/archive/zip/codec/deflate/decompress/close_spec.rb +10 -9
  22. data/spec/archive/zip/codec/deflate/decompress/crc32_spec.rb +6 -4
  23. data/spec/archive/zip/codec/deflate/decompress/data_descriptor_spec.rb +17 -10
  24. data/spec/archive/zip/codec/deflate/decompress/new_spec.rb +5 -3
  25. data/spec/archive/zip/codec/deflate/decompress/open_spec.rb +7 -5
  26. data/spec/archive/zip/codec/null_encryption/decrypt/close_spec.rb +10 -9
  27. data/spec/archive/zip/codec/null_encryption/decrypt/new_spec.rb +6 -4
  28. data/spec/archive/zip/codec/null_encryption/decrypt/open_spec.rb +8 -6
  29. data/spec/archive/zip/codec/null_encryption/decrypt/read_spec.rb +8 -6
  30. data/spec/archive/zip/codec/null_encryption/decrypt/rewind_spec.rb +9 -7
  31. data/spec/archive/zip/codec/null_encryption/decrypt/seek_spec.rb +15 -13
  32. data/spec/archive/zip/codec/null_encryption/decrypt/tell_spec.rb +8 -6
  33. data/spec/archive/zip/codec/null_encryption/encrypt/close_spec.rb +10 -9
  34. data/spec/archive/zip/codec/null_encryption/encrypt/new_spec.rb +5 -3
  35. data/spec/archive/zip/codec/null_encryption/encrypt/open_spec.rb +9 -5
  36. data/spec/archive/zip/codec/null_encryption/encrypt/rewind_spec.rb +9 -7
  37. data/spec/archive/zip/codec/null_encryption/encrypt/seek_spec.rb +15 -13
  38. data/spec/archive/zip/codec/null_encryption/encrypt/tell_spec.rb +11 -9
  39. data/spec/archive/zip/codec/null_encryption/encrypt/write_spec.rb +12 -10
  40. data/spec/archive/zip/codec/store/compress/close_spec.rb +10 -9
  41. data/spec/archive/zip/codec/store/compress/data_descriptor_spec.rb +19 -10
  42. data/spec/archive/zip/codec/store/compress/new_spec.rb +5 -3
  43. data/spec/archive/zip/codec/store/compress/open_spec.rb +7 -5
  44. data/spec/archive/zip/codec/store/compress/rewind_spec.rb +9 -7
  45. data/spec/archive/zip/codec/store/compress/seek_spec.rb +15 -13
  46. data/spec/archive/zip/codec/store/compress/tell_spec.rb +11 -9
  47. data/spec/archive/zip/codec/store/compress/write_spec.rb +10 -10
  48. data/spec/archive/zip/codec/store/decompress/close_spec.rb +10 -9
  49. data/spec/archive/zip/codec/store/decompress/data_descriptor_spec.rb +17 -10
  50. data/spec/archive/zip/codec/store/decompress/new_spec.rb +5 -3
  51. data/spec/archive/zip/codec/store/decompress/open_spec.rb +7 -5
  52. data/spec/archive/zip/codec/store/decompress/read_spec.rb +8 -6
  53. data/spec/archive/zip/codec/store/decompress/rewind_spec.rb +9 -7
  54. data/spec/archive/zip/codec/store/decompress/seek_spec.rb +15 -13
  55. data/spec/archive/zip/codec/store/decompress/tell_spec.rb +8 -6
  56. data/spec/archive/zip/codec/traditional_encryption/decrypt/close_spec.rb +13 -24
  57. data/spec/archive/zip/codec/traditional_encryption/decrypt/new_spec.rb +6 -4
  58. data/spec/archive/zip/codec/traditional_encryption/decrypt/open_spec.rb +10 -6
  59. data/spec/archive/zip/codec/traditional_encryption/decrypt/read_spec.rb +12 -13
  60. data/spec/archive/zip/codec/traditional_encryption/decrypt/rewind_spec.rb +10 -12
  61. data/spec/archive/zip/codec/traditional_encryption/decrypt/seek_spec.rb +16 -18
  62. data/spec/archive/zip/codec/traditional_encryption/decrypt/tell_spec.rb +8 -6
  63. data/spec/archive/zip/codec/traditional_encryption/encrypt/close_spec.rb +13 -24
  64. data/spec/archive/zip/codec/traditional_encryption/encrypt/new_spec.rb +5 -3
  65. data/spec/archive/zip/codec/traditional_encryption/encrypt/open_spec.rb +7 -5
  66. data/spec/archive/zip/codec/traditional_encryption/encrypt/rewind_spec.rb +10 -12
  67. data/spec/archive/zip/codec/traditional_encryption/encrypt/seek_spec.rb +16 -18
  68. data/spec/archive/zip/codec/traditional_encryption/encrypt/tell_spec.rb +12 -14
  69. data/spec/archive/zip/codec/traditional_encryption/encrypt/write_spec.rb +8 -23
  70. data/spec/binary_stringio/new_spec.rb +18 -12
  71. data/spec/binary_stringio/set_encoding_spec.rb +10 -7
  72. data/spec/ioextensions/read_exactly_spec.rb +14 -12
  73. data/spec/zlib/zreader/checksum_spec.rb +10 -8
  74. data/spec/zlib/zreader/close_spec.rb +5 -3
  75. data/spec/zlib/zreader/compressed_size_spec.rb +6 -4
  76. data/spec/zlib/zreader/new_spec.rb +7 -5
  77. data/spec/zlib/zreader/open_spec.rb +9 -7
  78. data/spec/zlib/zreader/read_spec.rb +10 -8
  79. data/spec/zlib/zreader/rewind_spec.rb +7 -5
  80. data/spec/zlib/zreader/seek_spec.rb +13 -11
  81. data/spec/zlib/zreader/tell_spec.rb +8 -6
  82. data/spec/zlib/zreader/uncompressed_size_spec.rb +6 -4
  83. data/spec/zlib/zwriter/checksum_spec.rb +10 -8
  84. data/spec/zlib/zwriter/close_spec.rb +5 -3
  85. data/spec/zlib/zwriter/compressed_size_spec.rb +6 -4
  86. data/spec/zlib/zwriter/new_spec.rb +10 -8
  87. data/spec/zlib/zwriter/open_spec.rb +12 -10
  88. data/spec/zlib/zwriter/rewind_spec.rb +9 -7
  89. data/spec/zlib/zwriter/seek_spec.rb +15 -17
  90. data/spec/zlib/zwriter/tell_spec.rb +11 -9
  91. data/spec/zlib/zwriter/uncompressed_size_spec.rb +6 -4
  92. data/spec/zlib/zwriter/write_spec.rb +9 -9
  93. metadata +268 -217
  94. data/CONTRIBUTORS +0 -13
  95. data/GPL +0 -676
  96. data/HACKING +0 -105
  97. data/LEGAL +0 -8
  98. data/README +0 -151
  99. data/TODO +0 -5
  100. data/default.mspec +0 -8
  101. data/spec_helper.rb +0 -49
data/Rakefile CHANGED
@@ -1,27 +1,73 @@
1
1
  # encoding: UTF-8
2
+ # -*- ruby -*-
2
3
 
3
4
  require 'rubygems'
4
- gem 'rdoc'
5
5
 
6
+ require 'erb'
7
+ require 'rake/testtask'
6
8
  require 'rubygems/package_task'
7
9
  require 'rake/clean'
8
- require 'rdoc/task'
9
-
10
- # The path to the version.rb file and a string to eval to find the version.
11
- VERSION_RB = 'lib/archive/zip/version.rb'
12
- VERSION_REF = 'Archive::Zip::VERSION'
10
+ require 'yard'
13
11
 
14
12
  # Load the gemspec file for this project.
15
- GEMSPEC = 'archive-zip.gemspec'
13
+ GEMSPEC = Dir['*.gemspec'].first
16
14
  SPEC = eval(File.read(GEMSPEC), nil, GEMSPEC)
17
15
 
16
+ # The path to the version.rb file and a string to eval to find the version.
17
+ VERSION_RB = "lib/#{SPEC.name.gsub('-', '/')}/version.rb"
18
+ VERSION_REF =
19
+ SPEC.name.split('-').map do |subname|
20
+ subname.split('_').map(&:capitalize).join
21
+ end.join('::') + "::VERSION"
22
+
23
+ # A dynamically generated list of files that should match the manifest (the
24
+ # combined contents of SPEC.files and SPEC.test_files). The idea is for this
25
+ # list to contain all project files except for those that have been explicitly
26
+ # excluded. This list will be compared with the manifest from the SPEC in order
27
+ # to help catch the addition or removal of files to or from the project that
28
+ # have not been accounted for either by an exclusion here or an inclusion in the
29
+ # SPEC manifest.
30
+ #
31
+ # NOTE:
32
+ # It is critical that the manifest is *not* automatically generated via globbing
33
+ # and the like; otherwise, this will yield a simple comparison between
34
+ # redundantly generated lists of files that probably will not protect the
35
+ # project from the unintentional inclusion or exclusion of files in the
36
+ # distribution.
37
+ PKG_FILES = FileList.new(Dir.glob('**/*', File::FNM_DOTMATCH)) do |files|
38
+ # Exclude anything that doesn't exist as well as directories.
39
+ files.exclude {|file| ! File.exist?(file) || File.directory?(file)}
40
+ # Exclude Git administrative files.
41
+ files.exclude(%r{(^|[/\\])\.git(ignore|modules|keep)?([/\\]|$)})
42
+ # Exclude editor swap/temporary files.
43
+ files.exclude('**/.*.sw?')
44
+ # Exclude gemspec files.
45
+ files.exclude('*.gemspec')
46
+ # Exclude the README template file.
47
+ files.exclude('README.md.erb')
48
+ # Exclude resources for bundler.
49
+ files.exclude('Gemfile', 'Gemfile.lock')
50
+ files.exclude(%r{^.bundle([/\\]|$)})
51
+ files.exclude(%r{^vendor/bundle([/\\]|$)})
52
+ # Exclude generated content, except for the README file.
53
+ files.exclude(%r{^(pkg|doc|.yardoc)([/\\]|$)})
54
+ # Exclude Rubinius compiled Ruby files.
55
+ files.exclude('**/*.rbc')
56
+ files.exclude('.rbx/**/*')
57
+ end
58
+
59
+ # Make sure that :clean and :clobber will not whack the repository files.
60
+ CLEAN.exclude('.git/**')
61
+ # Vim swap files are fair game for clean up.
62
+ CLEAN.include('**/.*.sw?')
63
+
18
64
  # Returns the value of the VERSION environment variable as a Gem::Version object
19
65
  # assuming it is set and a valid Gem version string. Otherwise, raises an
20
66
  # exception.
21
67
  def get_version_argument
22
68
  version = ENV['VERSION']
23
- if version.nil? || version.empty?
24
- raise "No version specified: Add VERSION=... to the command line"
69
+ if version.to_s.empty?
70
+ raise "No version specified: Add VERSION=X.Y.Z to the command line"
25
71
  end
26
72
  begin
27
73
  Gem::Version.create(version.dup)
@@ -48,57 +94,34 @@ end
48
94
  # Updates the version string in the gemspec file and a version.rb file it to the
49
95
  # string in _version_.
50
96
  def set_version(version)
51
- file_sub(GEMSPEC, /(\.version\s*=\s*).*/, "\\1\"#{version}\"")
52
- file_sub(VERSION_RB, /^(\s*VERSION\s*=\s*).*/, "\\1\"#{version}\"")
97
+ file_sub(GEMSPEC, /(\.version\s*=\s*).*/, "\\1'#{version}'")
98
+ file_sub(VERSION_RB, /^(\s*VERSION\s*=\s*).*/, "\\1'#{version}'")
53
99
  end
54
100
 
55
- # A dynamically generated list of files that should match the manifest (the
56
- # combined contents of SPEC.files and SPEC.test_files). The idea is for this
57
- # list to contain all project files except for those that have been explicitly
58
- # excluded. This list will be compared with the manifest from the SPEC in order
59
- # to help catch the addition or removal of files to or from the project that
60
- # have not been accounted for either by an exclusion here or an inclusion in the
61
- # SPEC manifest.
101
+ # Returns a string that is line wrapped at word boundaries, where each line is
102
+ # no longer than _line_width_ characters.
62
103
  #
63
- # NOTE:
64
- # It is critical that the manifest is *not* automatically generated via globbing
65
- # and the like; otherwise, this will yield a simple comparison between
66
- # redundantly generated lists of files that probably will not protect the
67
- # project from the unintentional inclusion or exclusion of files in the
68
- # distribution.
69
- PKG_FILES = FileList.new('**/*', '**/.[^.][^.]*') do |files|
70
- # Exclude the gemspec file.
71
- files.exclude('*.gemspec')
72
- # Exclude anything that doesn't exist and directories.
73
- files.exclude {|file| ! File.exist?(file) || File.directory?(file)}
74
- # Exclude Vim swap files.
75
- files.exclude('**/.*.sw?')
76
- # Exclude Git administrative files and directories.
77
- files.exclude(%r{(^|[/\\])\.git(ignore|modules)?([/\\]|$)})
78
- # Exclude Rubunius compiled Ruby files.
79
- files.exclude('**/*.rbc')
80
-
81
- # Exclude the top level pkg, doc, and examples directories and their contents.
82
- files.exclude(%r{^(pkg|doc|examples)([/\\]|$)})
104
+ # This is mostly lifted directly from ActionView::Helpers::TextHelper.
105
+ def word_wrap(text, line_width = 80)
106
+ text.split("\n").collect do |line|
107
+ line.length > line_width ?
108
+ line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip :
109
+ line
110
+ end * "\n"
83
111
  end
84
112
 
85
- # Make sure that :clean and :clobber will not whack the repository files.
86
- CLEAN.exclude('.git/**')
87
- # Vim swap files are fair game for clean up.
88
- CLEAN.include('**/.*.sw?')
89
-
90
113
  desc 'Alias for build:gem'
91
114
  task :build => 'build:gem'
92
115
 
93
116
  # Build related tasks.
94
117
  namespace :build do
95
- # Create the gem and package tasks.
96
- Gem::PackageTask.new(SPEC).define
97
-
98
- # Ensure that the manifest is consulted after building the gem. Any
118
+ # Ensure that the manifest is consulted when building the gem. Any
99
119
  # generated/compiled files should be available at that time.
100
120
  task :gem => :check_manifest
101
121
 
122
+ # Create the gem and package tasks.
123
+ Gem::PackageTask.new(SPEC).define
124
+
102
125
  desc 'Verify the manifest'
103
126
  task :check_manifest do
104
127
  manifest_files = (SPEC.files + SPEC.test_files).sort.uniq
@@ -117,18 +140,26 @@ namespace :build do
117
140
  raise message.join("\n")
118
141
  end
119
142
  end
143
+
144
+ # Creates the README.md file from a template, the license file and the gemspec
145
+ # contents.
146
+ file 'README.md' => ['README.md.erb', 'LICENSE', GEMSPEC] do
147
+ spec = SPEC
148
+ File.open('README.md', 'w') do |readme|
149
+ readme.write(
150
+ ERB.new(File.read('README.md.erb'), nil, '-').result(binding)
151
+ )
152
+ end
153
+ end
120
154
  end
121
155
 
122
156
  # Ensure that the clobber task also clobbers package files.
123
157
  task :clobber => 'build:clobber_package'
124
158
 
125
- # Create the rdoc task.
126
- RDoc::Task.new do |rdoc|
127
- rdoc.rdoc_dir = 'doc'
128
- rdoc.title = 'Archive::Zip Documentation'
129
- rdoc.rdoc_files = SPEC.files - SPEC.test_files
130
- rdoc.main = 'README'
131
- end
159
+ # Create the documentation task.
160
+ YARD::Rake::YardocTask.new
161
+ # Ensure that the README file is (re)generated first.
162
+ task :yard => 'README.md'
132
163
 
133
164
  # Gem related tasks.
134
165
  namespace :gem do
@@ -141,9 +172,8 @@ namespace :gem do
141
172
  end
142
173
  end
143
174
 
144
- desc 'Run tests'
145
- task :test do
146
- sh "mspec"
175
+ Rake::TestTask.new do |t|
176
+ t.pattern = 'spec/**/*_spec.rb'
147
177
  end
148
178
 
149
179
  # Version string management tasks.
@@ -158,31 +188,44 @@ namespace :version do
158
188
  set_version('0.0.0')
159
189
  end
160
190
 
161
- desc 'Checks that all version strings are correctly set'
162
- task :check do
163
- version = get_version_argument
164
- if version != SPEC.version
165
- raise "The given version `#{version}' does not match the gemspec version `#{SPEC.version}'"
191
+ desc 'Check that all version strings are correctly set'
192
+ task :check => ['version:check:spec', 'version:check:version_rb', 'version:check:news']
193
+
194
+ namespace :check do
195
+ desc 'Check that the version in the gemspec is correctly set'
196
+ task :spec do
197
+ version = get_version_argument
198
+ if version != SPEC.version
199
+ raise "The given version `#{version}' does not match the gemspec version `#{SPEC.version}'"
200
+ end
166
201
  end
167
202
 
168
- begin
169
- load VERSION_RB
170
- internal_version = Gem::Version.create(eval(VERSION_REF))
171
- if version != internal_version
172
- raise "The given version `#{version}' does not match the version.rb version `#{internal_version}'"
203
+ desc 'Check that the version in the version.rb file is correctly set'
204
+ task :version_rb do
205
+ version = get_version_argument
206
+ begin
207
+ load VERSION_RB
208
+ internal_version = Gem::Version.create(eval(VERSION_REF))
209
+ if version != internal_version
210
+ raise "The given version `#{version}' does not match the version.rb version `#{internal_version}'"
211
+ end
212
+ rescue ArgumentError
213
+ raise "Invalid version specified in `#{VERSION_RB}'"
173
214
  end
174
- rescue ArgumentError
175
- raise "Invalid version specified in `#{VERSION_RB}'"
176
215
  end
177
216
 
178
- begin
179
- File.open('NEWS') do |news|
180
- unless news.lines.any? {|l| l =~ /^== v#{Regexp.escape(version.to_s)} /}
181
- raise "The NEWS file does not mention version `#{version}'"
217
+ desc 'Check that the NEWS.md file mentions the version'
218
+ task :news do
219
+ version = get_version_argument
220
+ begin
221
+ File.open('NEWS.md') do |news|
222
+ unless news.each_line.any? {|l| l =~ /^## v#{Regexp.escape(version.to_s)} /}
223
+ raise "The NEWS.md file does not mention version `#{version}'"
224
+ end
182
225
  end
226
+ rescue Errno::ENOENT
227
+ raise 'No NEWS.md file found'
183
228
  end
184
- rescue Errno::ENOENT
185
- raise 'No NEWS file found'
186
229
  end
187
230
  end
188
231
  end
@@ -196,7 +239,7 @@ namespace :repo do
196
239
  end
197
240
 
198
241
  desc 'Ensure the workspace is fully committed and clean'
199
- task :check_workspace do
242
+ task :check_workspace => ['README.md'] do
200
243
  unless `git status --untracked-files=all --porcelain`.empty?
201
244
  raise 'Workspace has been modified. Commit pending changes and try again.'
202
245
  end
@@ -14,10 +14,17 @@ class BinaryStringIO < StringIO
14
14
 
15
15
  # Force a binary encoding when possible.
16
16
  if respond_to?(:set_encoding, true)
17
+ @encoding_locked = false
17
18
  set_encoding('binary')
18
19
  end
19
20
  end
20
21
 
21
- # Hide #set_encoding so that the encoding cannot be changed later.
22
- private :set_encoding if instance_methods.include?(:set_encoding)
22
+ if instance_methods.include?(:set_encoding)
23
+ # Raise an exception on attempts to change the encoding.
24
+ def set_encoding(*args)
25
+ raise 'Changing encoding is not allowed' if @encoding_locked
26
+ @encoding_locked = true
27
+ super
28
+ end
29
+ end
23
30
  end
@@ -25,9 +25,9 @@ class Time
25
25
  end
26
26
  end
27
27
 
28
- # A representation of the DOS time structure which can be converted into
29
- # instances of Time.
30
28
  module Archive
29
+ # A representation of the DOS time structure which can be converted into
30
+ # instances of Time.
31
31
  class DOSTime
32
32
  include Comparable
33
33
 
@@ -726,7 +726,7 @@ module Archive # :nodoc:
726
726
  @entries.length,
727
727
  central_directory_length,
728
728
  central_directory_offset,
729
- comment.length
729
+ comment.bytesize
730
730
  ].pack('vvvvVVv')
731
731
  )
732
732
  bytes_written += io.write(comment)
@@ -643,7 +643,7 @@ module Archive; class Zip
643
643
  0,
644
644
  0,
645
645
  0,
646
- zip_path.length,
646
+ zip_path.bytesize,
647
647
  extra_field_data.length
648
648
  ].pack('vvvVVVVvv')
649
649
  )
@@ -742,7 +742,7 @@ module Archive; class Zip
742
742
  extra_field_data = central_extra_field_data
743
743
  bytes_written += io.write(
744
744
  [
745
- zip_path.length,
745
+ zip_path.bytesize,
746
746
  extra_field_data.length,
747
747
  comment.length,
748
748
  0,
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Archive; class Zip
4
4
  # The current version of this gem.
5
- VERSION = "0.6.0"
5
+ VERSION = '0.7.0'
6
6
  end; end
@@ -0,0 +1,54 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'minitest/autorun'
4
+ require 'tmpdir'
5
+
6
+ require 'archive/zip'
7
+
8
+ describe 'Archive::Zip#archive' do
9
+ it 'adds file entries' do
10
+ file_name = 'file'
11
+ Dir.mktmpdir('archive_zip#archive') do |dir|
12
+ file_path = File.join(dir, file_name)
13
+ File.open(file_path, 'wb') { |f| f.write('data') }
14
+ archive_file_path = File.join(dir, 'archive.zip')
15
+
16
+ Archive::Zip.open(archive_file_path, 'w') do |a|
17
+ a.archive(file_path)
18
+ end
19
+
20
+ Archive::Zip.open(archive_file_path, 'r') do |a|
21
+ entry = a.first
22
+ entry.wont_be_nil
23
+ entry.zip_path.must_equal(file_name)
24
+ entry.file?.must_equal(true)
25
+ entry.file_data.read.must_equal('data')
26
+ end
27
+ end
28
+ end
29
+
30
+ it 'adds entries with multibyte names' do
31
+ unless Object.const_defined?(:Encoding)
32
+ skip("String encodings are not supported on current Ruby (#{RUBY_DESCRIPTION})")
33
+ end
34
+
35
+ mb_file_name = '☂file☄'
36
+ Dir.mktmpdir('archive_zip#archive') do |dir|
37
+ mb_file_path = File.join(dir, mb_file_name)
38
+ File.open(mb_file_path, 'wb') { |f| f.write('data') }
39
+ archive_file_path = File.join(dir, 'archive.zip')
40
+
41
+ Archive::Zip.open(archive_file_path, 'w') do |a|
42
+ a.archive(mb_file_path)
43
+ end
44
+
45
+ Archive::Zip.open(archive_file_path, 'r') do |a|
46
+ entry = a.first
47
+ entry.wont_be_nil
48
+ entry.zip_path.must_equal(mb_file_name.dup.force_encoding('binary'))
49
+ entry.file?.must_equal(true)
50
+ entry.file_data.read.must_equal('data')
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/deflate'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -13,10 +15,10 @@ describe "Archive::Zip::Codec::Deflate::Compress#checksum" do
13
15
  ) do |compressor|
14
16
  compressor.write(DeflateSpecs.test_data)
15
17
  compressor.flush
16
- compressor.checksum.should == Zlib.crc32(DeflateSpecs.test_data)
18
+ compressor.checksum.must_equal Zlib.crc32(DeflateSpecs.test_data)
17
19
  compressor
18
20
  end
19
- closed_compressor.checksum.should == Zlib.crc32(DeflateSpecs.test_data)
21
+ closed_compressor.checksum.must_equal Zlib.crc32(DeflateSpecs.test_data)
20
22
  end
21
23
 
22
24
  it "computes the CRC32 checksum even when the delegate performs partial writes" do
@@ -34,9 +36,9 @@ describe "Archive::Zip::Codec::Deflate::Compress#checksum" do
34
36
  ) do |compressor|
35
37
  compressor.write(DeflateSpecs.test_data)
36
38
  compressor.flush
37
- compressor.checksum.should == Zlib.crc32(DeflateSpecs.test_data)
39
+ compressor.checksum.must_equal Zlib.crc32(DeflateSpecs.test_data)
38
40
  compressor
39
41
  end
40
- closed_compressor.checksum.should == Zlib.crc32(DeflateSpecs.test_data)
42
+ closed_compressor.checksum.must_equal Zlib.crc32(DeflateSpecs.test_data)
41
43
  end
42
44
  end
@@ -1,7 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.dirname(__FILE__) + '/../../../../../../spec_helper'
4
- require File.dirname(__FILE__) + '/../fixtures/classes'
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path('../../fixtures/classes', __FILE__)
6
+
5
7
  require 'archive/zip/codec/deflate'
6
8
  require 'archive/support/binary_stringio'
7
9
 
@@ -11,13 +13,13 @@ describe "Archive::Zip::Codec::Deflate::Compress#close" do
11
13
  BinaryStringIO.new, Zlib::DEFAULT_COMPRESSION
12
14
  )
13
15
  c.close
14
- c.closed?.should be_true
16
+ c.closed?.must_equal true
15
17
  end
16
18
 
17
19
  it "closes the delegate stream by default" do
18
- delegate = mock('delegate')
19
- delegate.should_receive(:close).and_return(nil)
20
- delegate.should_receive(:write).at_least(:once).and_return(1)
20
+ delegate = MiniTest::Mock.new
21
+ delegate.expect(:write, 8, [String])
22
+ delegate.expect(:close, nil)
21
23
  c = Archive::Zip::Codec::Deflate::Compress.new(
22
24
  delegate, Zlib::DEFAULT_COMPRESSION
23
25
  )
@@ -25,17 +27,16 @@ describe "Archive::Zip::Codec::Deflate::Compress#close" do
25
27
  end
26
28
 
27
29
  it "optionally leaves the delegate stream open" do
28
- delegate = mock('delegate')
29
- delegate.should_receive(:close).and_return(nil)
30
- delegate.should_receive(:write).at_least(:once).and_return(1)
30
+ delegate = MiniTest::Mock.new
31
+ delegate.expect(:write, 8, [String])
32
+ delegate.expect(:close, nil)
31
33
  c = Archive::Zip::Codec::Deflate::Compress.new(
32
34
  delegate, Zlib::DEFAULT_COMPRESSION
33
35
  )
34
36
  c.close(true)
35
37
 
36
- delegate = mock('delegate')
37
- delegate.should_not_receive(:close)
38
- delegate.should_receive(:write).at_least(:once).and_return(1)
38
+ delegate = MiniTest::Mock.new
39
+ delegate.expect(:write, 8, [String])
39
40
  c = Archive::Zip::Codec::Deflate::Compress.new(
40
41
  delegate, Zlib::DEFAULT_COMPRESSION
41
42
  )