zip-container 4.0.2 → 5.0.0.rc1

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
  SHA256:
3
- metadata.gz: 840b4e7e6338a773a393a94e42f87c7bff876ab520e0361e3378ac11fd8e4741
4
- data.tar.gz: c441f69cb0988145551c09f837dc0d9a287c55452b1737ec4a43bf3740939ce8
3
+ metadata.gz: e3202589c6171c22a5a5ada78a4288c54b26df4af389370057ea91ad4cc67de9
4
+ data.tar.gz: 5e89d3760a90c36cf7ce9d18a9065bf6194eddfe8b07b4604b20362155d158a7
5
5
  SHA512:
6
- metadata.gz: ebe9848aaa420c00e28ed4223d43ca1e186b1905ac6e3102b1ee7661f8edee5e07a68960577651d5206aa98530ea253590e9b25618b2f0aca2655bac98954b23
7
- data.tar.gz: fec65830abe5391d805cfa2c3a417cfcc52cb47f1c99e5affebfb91b6262d3cd3292a39f4af5eea689cee4f4ff91568db0a797ee7dd706874e011b1e7798b297
6
+ metadata.gz: 271646c409d64c6b6286f79c00fae83ff354025d475f90f362365b6d862e204113a23f75a01d5a28e87ffc0938870af95c3868a013abee80bb5b79bf3957e5d2
7
+ data.tar.gz: 6cfb0c5f7a97f9b19a6f5e88c53de07dacbbe2facd1144b530c337e4eb360468cb2b8198d59850637974de9de37388d9d013a76df4f6661ae8f9fc22e075182f
@@ -1,14 +1,48 @@
1
- = Changes log for the ZIP Container Ruby Gem
1
+ # Changes log for the ZIP Container Ruby Gem
2
2
 
3
- == Version 3.0.2
3
+ ## Version 5.0.0
4
+
5
+ * Fix warnings about uninitialized instance variables.
6
+ * Set ManagedEntries#all_managed_entries to private.
7
+ * Add a code of conduct.
8
+ * Add contributing guidelines.
9
+ * Move to README.md (and update).
10
+ * Update minimum ruby version required to 2.7.
11
+ * Update RubyZip version to v2.4.
12
+
13
+ ### Internal/tooling:
14
+
15
+ * Update Rake version.
16
+ * Update and add metadata in the gemspec.
17
+ * Just use a constant for the gem version string.
18
+ * Add a script to start IRB with ZipContainer loaded.
19
+ * Switch from Coveralls to Simplecov.
20
+ * Switch to use minitest for unit tests.
21
+ * Switch from Travis CI to GitHub Actions.
22
+ * Update Rubocop.
23
+ * Skip certain tests in non-POSIX environments.
24
+ * Fix managed directory test on Windows.
25
+
26
+ ## Version 4.0.2
27
+
28
+ * Bump rubyzip version again.
29
+
30
+ ## Version 4.0.1
31
+
32
+ * Don't package test files in the gem.
33
+ * Add rubocop configuration.
34
+ * Configure and fix many rubocop issues.
35
+ * Updated rubyzip to fix vulnerability.
36
+
37
+ ## Version 3.0.2
4
38
 
5
39
  * Update rubyzip dependency to fix security vulnerability.
6
40
 
7
- == Version 3.0.1
41
+ ## Version 3.0.1
8
42
 
9
43
  * Fix deep content verification bug.
10
44
 
11
- == Version 3.0.0
45
+ ## Version 3.0.0
12
46
 
13
47
  * Refactor the malformed container error constructor.
14
48
  * Verifying entries only raises errors at the last moment.
@@ -22,7 +56,7 @@
22
56
  * Add a compatibility note about ContainerError.
23
57
  * Improve the Usage information in the ReadMe.
24
58
 
25
- == Version 2.2.0
59
+ ## Version 2.2.0
26
60
 
27
61
  * Fix pathname bug in ZipContainer::Dir.
28
62
  * Fixup docs to refer to containers rather than documents.
@@ -30,7 +64,7 @@
30
64
  * Add an internal compatibility method Dir#entries.
31
65
  * Add a compatibility method Dir#read.
32
66
 
33
- == Version 2.1.0
67
+ ## Version 2.1.0
34
68
 
35
69
  * Set up the Container superclass.
36
70
  * Open the container from the superclass.
@@ -47,7 +81,7 @@
47
81
  * Update dependencies.
48
82
  * Disambiguate the two test classes for File and Dir.
49
83
 
50
- == Version 2.0.0
84
+ ## Version 2.0.0
51
85
 
52
86
  * Change API: Container => File.
53
87
  * Refactor exceptions so we can shadow rubyzip exceptions.
@@ -70,25 +104,25 @@
70
104
  * Document removal of ZipContainer::Container in the ReadMe.
71
105
  * Update rubyzip version to latest (1.1.6).
72
106
 
73
- == Version 1.1.0
107
+ ## Version 1.1.0
74
108
 
75
109
  * Bump version of rubyzip to 1.1.4.
76
110
 
77
- == Version 1.0.0
111
+ ## Version 1.0.0
78
112
 
79
113
  * Update to use version 1.0.0 of rubyzip.
80
114
 
81
- == Version 0.9.0
115
+ ## Version 0.9.0
82
116
 
83
117
  * Generalize the Container Error class names.
84
118
  * Polish example scripts.
85
119
 
86
- == Version 0.8.0
120
+ ## Version 0.8.0
87
121
 
88
122
  * Abstract out all the underlying zip functionality and turn this library
89
123
  into a basic ZIP Container provider.
90
124
 
91
- == Version 0.5.0
125
+ ## Version 0.5.0
92
126
 
93
127
  * Add support for managed entries in the container.
94
128
  * Verify and "optional" functionality for ManagedEntry.
@@ -99,7 +133,7 @@
99
133
  * Make file validation more flexible.
100
134
  * Fix the source of failing validation messages.
101
135
 
102
- == Version 0.1.0
136
+ ## Version 0.1.0
103
137
 
104
138
  * Improvements to the reserved names code to allow sub-classing.
105
139
  * Move exceptions to a new source file.
@@ -118,7 +152,7 @@
118
152
  * Separate the opening and checking of a UCF document.
119
153
  * Documentation improvements and cleanup.
120
154
 
121
- == Version 0.0.2
155
+ ## Version 0.0.2
122
156
 
123
157
  * Update the main ReadMe file.
124
158
  * Add support for multiple reserved names and fix checks.
@@ -128,15 +162,17 @@
128
162
  * Add an example program to list UCF contents.
129
163
  * Add a method to directly iterate over UCF entries.
130
164
 
131
- == Version 0.0.1
165
+ ## Version 0.0.1
132
166
 
133
167
  * Very basic UCF facilities complete (plus examples).
134
168
  * Two ways of verifying UCF files.
135
169
  * API documentation added.
136
170
  * Add tests.
137
171
 
138
- == About this Changes file
172
+ ## About this Changes file
139
173
 
140
174
  This file is, at least in part, generated by the following command:
141
175
 
142
- $ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
176
+ ```shell
177
+ $ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
178
+ ```
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at rhaines@manchester.ac.uk. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,67 @@
1
+ # Contributing to the Ruby ZIP Container Library
2
+ ## Introduction
3
+
4
+ **Thank you** for considering a contribution to the **Ruby ZIP Container Library**!
5
+
6
+ **Please follow these guidelines.** Their purpose is to make both contributing and accepting contributions easier for all parties involved.
7
+
8
+ There are many ways to contribute, e.g.:
9
+
10
+ * Tell a friend or colleague about Ruby ZIP Container, or tweet about it
11
+ * Write blog posts, tutorials, etc. about Ruby ZIP Container
12
+ * Improve wording in any prose output
13
+ * Improve automated tests, continuous integration, documentation, etc.
14
+
15
+ ## Ground Rules
16
+
17
+ Your contribution to Ruby ZIP Container is valued, and it should be an enjoyable experience. To ensure this there is the Ruby ZIP Container
18
+ [Code of Conduct](https://github.com/hainesr/ruby-zip-container/blob/main/CODE_OF_CONDUCT.md) which you are required to follow.
19
+
20
+ Please always start any contribution that will change the contents of this repository from [an issue](https://github.com/hainesr/ruby-zip-container/issues). This may mean [creating a new issue](https://github.com/hainesr/ruby-zip-container/issues/new) if it's something that hasn't been requested so far. This way,
21
+
22
+ * you can make sure that you don't invest your valuable time in something that may not be merged; and
23
+ * we can make sure that your contribution is something that will improve Ruby ZIP Container, is in scope, and aligns with the roadmap for the Ruby ZIP Container and the Citation File Format.
24
+
25
+ ## Your First Contribution
26
+
27
+ If you are unsure where to begin with your contribution to Ruby ZIP Container, have a look at the [open issues in this repository](https://github.com/hainesr/ruby-zip-container/issues), and see if you can identify one that you would like to work on.
28
+
29
+ If you have never contributed to an open source project, you may find this tutorial helpful: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
30
+
31
+ ## Getting started
32
+
33
+ This is the workflow for contributions to this repository:
34
+
35
+ 1. Take note of the [code of conduct](https://github.com/hainesr/ruby-zip-container/blob/main/CODE_OF_CONDUCT.md)
36
+ 1. [Create a new issue](https://github.com/hainesr/ruby-zip-container/issues/new) if needs be, and discuss the changes you want to make with the maintainers and community
37
+ 1. Fork the repository
38
+ 1. Create a branch in your fork of the repository
39
+ 1. Make changes in the new branch in your fork
40
+ * Please don't forget tests!
41
+ * If you add any classes, modules, methods, attributes, or constants, please document them
42
+ 1. Create a pull request
43
+ 1. Address any comments that come up during review
44
+ 1. If and when your pull request has been merged, you can delete your branch (or the whole forked repository)
45
+
46
+ This workflow is loosely based on GitHub flow, and you can find more information in the [GitHub flow documentation](https://docs.github.com/en/get-started/quickstart/github-flow).
47
+
48
+ ### Working with tests and documentation
49
+
50
+ There is a comprehensive test suite for Ruby ZIP Container, which also contains a collection of test ZIP Container files - both valid and invalid. Please add tests (and new test ZIP Container files if appropriate) for any new features you add, or bugs you squash. It is advised to run these tests locally on your computer prior to submitting a pull request. However, if that's not possible, you still can submit the pull request and later check the status of the tests for your pull request on GitHub.
51
+
52
+ To run the tests, assuming that you have all the dependencies installed, simply run:
53
+ ```shell
54
+ $ rake
55
+ ```
56
+
57
+ To rebuild the documentation, if you have added to it or changed it:
58
+ ```shell
59
+ $ rake rdoc
60
+ ```
61
+ Then load `html/index.html` into a Web browser and double check it.
62
+
63
+ ## FAQ
64
+
65
+ - **These guidelines do not address aspect XYZ! What should I do now?**
66
+
67
+ Please [submit an issue](https://github.com/hainesr/ruby-zip-container/issues/new), asking for clarification of and/or an addition to the guidelines.
data/Gemfile CHANGED
@@ -33,3 +33,10 @@
33
33
  source 'https://rubygems.org'
34
34
 
35
35
  gemspec
36
+
37
+ # TODO: remove when JRuby 9.4.12.0 will be released and available on CI
38
+ # Ref: https://github.com/jruby/jruby/issues/7262
39
+ if RUBY_PLATFORM.include?('java')
40
+ gem 'jar-dependencies', '0.4.1'
41
+ gem 'ruby-maven', '3.3.13'
42
+ end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2018 The University of Manchester, UK.
1
+ Copyright (c) 2013-2025 The University of Manchester, UK.
2
2
 
3
3
  All rights reserved.
4
4
 
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # ZIP Container Ruby Library
2
+ ## Robert Haines
3
+
4
+ A Ruby library for creating, editing and validating ZIP Container files.
5
+
6
+ [![Gem Version](https://badge.fury.io/rb/zip-container.svg)](https://badge.fury.io/rb/zip-container)
7
+ [![Tests](https://github.com/hainesr/ruby-zip-container/actions/workflows/tests.yml/badge.svg)](https://github.com/hainesr/ruby-zip-container/actions/workflows/tests.yml)
8
+ [![Linter](https://github.com/hainesr/ruby-zip-container/actions/workflows/lint.yml/badge.svg)](https://github.com/hainesr/ruby-zip-container/actions/workflows/lint.yml)
9
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
10
+ [![Maintainability](https://api.codeclimate.com/v1/badges/208195ace7c8f86e98d8/maintainability)](https://codeclimate.com/github/hainesr/ruby-zip-container/maintainability)
11
+ [![Coverage Status](https://coveralls.io/repos/github/hainesr/ruby-zip-container/badge.svg)](https://coveralls.io/github/hainesr/ruby-zip-container)
12
+
13
+ ### Synopsis
14
+
15
+ This is a Ruby library for working with ZIP Container files. See the [ODF](http://www.idpf.org/epub/30/spec/epub30-ocf.html) and [UCF](https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format) specifications for more details.
16
+
17
+ If you are wanting to work with UCF files in particular, there is a Ruby Gem that builds on this one specifically for that. Please see:
18
+ * [GitHub](https://github.com/hainesr/ruby-ucf)
19
+ * [Rubygems](https://rubygems.org/gems/ucf)
20
+
21
+ ### Usage
22
+
23
+ This library has two entry points.
24
+
25
+ The main `ZipContainer::File` class largely mimics the rubyzip [`Zip::File`](https://www.rubydoc.info/gems/rubyzip/2.4.1/Zip/File) and [`Zip::FileSystem`](https://www.rubydoc.info/gems/rubyzip/2.4.1/Zip/FileSystem) APIs so much of what you can do with them are supported for ZIP Containers. There is also [API documentation](http://hainesr.github.io/ruby-zip-container/) with much more detail and any differences explained.
26
+
27
+ The `ZipContainer::Dir` class mimics, where possible, the core ruby [`Dir` API](http://ruby-doc.org/core-1.9.3/Dir.html).
28
+
29
+ There are some examples of how to use the library provided in the examples directory. See the contents of the tests directory for even more.
30
+
31
+ ### What this library can not do yet
32
+
33
+ The basic requirements of a ZIP Container are all implemented but memory resident ZIP Container files are not yet supported. Presently all operations are performed on files that are resident on disk.
34
+
35
+ ### Developing ZIP Container Ruby Library
36
+
37
+ Please see our [Code of Conduct](https://github.com/hainesr/ruby-zip-container/blob/main/CODE_OF_CONDUCT.md) and our [contributor guidelines](https://github.com/hainesr/ruby-zip-container/blob/main/CONTRIBUTING.md).
38
+
39
+ ### Licence
40
+
41
+ [3-Clause BSD Licence](https://opensource.org/license/bsd-3-clause). See LICENCE for details.
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2018 The University of Manchester, UK.
1
+ # Copyright (c) 2013-2024 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -31,25 +31,22 @@
31
31
  # Author: Robert Haines
32
32
 
33
33
  require 'bundler/gem_tasks'
34
- require 'rake/testtask'
34
+ require 'minitest/test_task'
35
35
  require 'rdoc/task'
36
36
  require 'rubocop/rake_task'
37
37
 
38
38
  task default: :test
39
39
 
40
- Rake::TestTask.new do |t|
41
- t.libs << 'test'
42
- t.test_files = FileList['test/ts_container.rb']
43
- t.verbose = true
40
+ Minitest::TestTask.create do |test|
41
+ test.test_globs = 'test/**/*_test.rb'
44
42
  end
45
43
 
46
44
  RDoc::Task.new do |r|
47
- r.main = 'ReadMe.rdoc'
45
+ r.main = 'README.md'
48
46
  lib = Dir.glob('lib/**/*.rb')
49
- r.rdoc_files.include('ReadMe.rdoc', 'Licence.rdoc', 'Changes.rdoc', lib)
50
- r.options << '-t ZIP Container Format Ruby Library version ' \
51
- "#{ZipContainer::Version::STRING}"
52
- r.options << '-N'
47
+ r.rdoc_files.include('README.md', 'LICENCE', 'CHANGES.md', lib)
48
+ r.options << "-t ZIP Container Format Ruby Library version #{ZipContainer::VERSION}"
49
+ r.options << '--markup=markdown'
53
50
  r.options << '--tab-width=2'
54
51
  end
55
52
 
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'zip-container'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -64,7 +64,7 @@ begin
64
64
  # Add a explanation of this file.
65
65
  c.comment = 'This is an example Container file!'
66
66
  end
67
- rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => err
68
- puts err.to_s
67
+ rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => e
68
+ puts e
69
69
  exit 1
70
70
  end
@@ -45,7 +45,7 @@ container_file = ARGV[0]
45
45
 
46
46
  begin
47
47
  ZipContainer::File.verify!(container_file)
48
- rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => err
49
- puts err.to_s
48
+ rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => e
49
+ puts e
50
50
  exit 1
51
51
  end
@@ -45,14 +45,14 @@ container_file = ARGV[0]
45
45
 
46
46
  begin
47
47
  container = ZipContainer::File.open(container_file)
48
- rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => err
49
- puts err.to_s
48
+ rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => e
49
+ puts e
50
50
  exit 1
51
51
  end
52
52
 
53
53
  puts "Archive: #{container}"
54
- puts "Container file size: #{File.size(container_file)} bytes, "\
55
- "number of entries: #{container.size}"
54
+ puts "Container file size: #{File.size(container_file)} bytes, " \
55
+ "number of entries: #{container.size}"
56
56
 
57
57
  total_size = 0
58
58
  total_comp = 0
@@ -66,5 +66,5 @@ container.each do |entry|
66
66
  end
67
67
 
68
68
  ratio = ((total_size - total_comp) / total_size.to_f) * 100
69
- puts "#{container.size} files, #{total_size} bytes uncompressed, "\
70
- "#{total_comp} bytes compressed: #{ratio.round(1)}%"
69
+ puts "#{container.size} files, #{total_size} bytes uncompressed, " \
70
+ "#{total_comp} bytes compressed: #{ratio.round(1)}%"
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014, 2015 The University of Manchester, UK.
1
+ # Copyright (c) 2014-2024 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -30,14 +30,16 @@
30
30
  #
31
31
  # Author: Robert Haines
32
32
 
33
+ require_relative 'errors'
34
+ require_relative 'managed_entries'
35
+ require_relative 'reserved_names'
36
+
33
37
  ##
34
38
  module ZipContainer
35
-
36
39
  # The superclass of anything that represents a Zip Container. That
37
40
  # representation could be as a Zip file (most commonly), as a directory or
38
41
  # something else.
39
42
  class Container
40
-
41
43
  include ReservedNames
42
44
  include ManagedEntries
43
45
 
@@ -111,9 +113,8 @@ module ZipContainer
111
113
  # verify!(filename)
112
114
  #
113
115
  # Verify that the specified ZipContainer conforms to the specification.
114
- # This method raises exceptions when errors are found or if there is
115
- # something fundamental wrong with the container itself (e.g. it cannot be
116
- # found).
116
+ # This method raises an error if there is something fundamental wrong
117
+ # with the container itself (e.g. it cannot be found).
117
118
  def self.verify!(filename)
118
119
  new(filename).verify!
119
120
  end
@@ -136,7 +137,7 @@ module ZipContainer
136
137
  # This method returns +false+ if there are any problems at all with the
137
138
  # container.
138
139
  def verify?
139
- verify.empty? ? true : false
140
+ verify.empty?
140
141
  end
141
142
 
142
143
  # :call-seq:
@@ -153,5 +154,4 @@ module ZipContainer
153
154
  verify_managed_entries!
154
155
  end
155
156
  end
156
-
157
157
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014 The University of Manchester, UK.
1
+ # Copyright (c) 2014-2024 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -30,10 +30,11 @@
30
30
  #
31
31
  # Author: Robert Haines
32
32
 
33
+ require_relative 'container'
34
+
33
35
  require 'forwardable'
34
36
 
35
37
  module ZipContainer
36
-
37
38
  # This class represents a ZipContainer in directory format. See the
38
39
  # {OCF}[http://www.idpf.org/epub/30/spec/epub30-ocf.html] and
39
40
  # {UCF}[https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format]
@@ -46,19 +47,12 @@ module ZipContainer
46
47
  #
47
48
  # There are code examples available with the source code of this library.
48
49
  class Dir < Container
49
-
50
50
  extend Forwardable
51
51
  def_delegators :@container, :close, :each, :path, :pos, :pos=, :rewind,
52
52
  :seek, :tell
53
53
 
54
54
  private_class_method :new
55
55
 
56
- # :stopdoc:
57
- def initialize(location)
58
- super(location)
59
- end
60
- # :startdoc:
61
-
62
56
  # :call-seq:
63
57
  # create(pathname, mimetype) -> container
64
58
  # create(pathname, mimetype) {|container| ...}
@@ -109,7 +103,6 @@ module ZipContainer
109
103
  end
110
104
 
111
105
  class Entries # :nodoc:
112
-
113
106
  include Enumerable
114
107
 
115
108
  Entry = Struct.new(:name, :ftype)
@@ -123,10 +116,8 @@ module ZipContainer
123
116
  end
124
117
  end
125
118
 
126
- def each
127
- @entries.each do |entry|
128
- yield entry
129
- end
119
+ def each(&block)
120
+ @entries.each(&block)
130
121
  end
131
122
  end
132
123
  # :startdoc:
@@ -224,5 +215,4 @@ module ZipContainer
224
215
  # Equal to
225
216
  # {::Dir.tell}[http://ruby-doc.org/core-1.9.3/Dir.html#method-i-tell]
226
217
  end
227
-
228
218
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2013-2015 The University of Manchester, UK.
1
+ # Copyright (c) 2013-2024 The University of Manchester, UK.
2
2
  #
3
3
  # All rights reserved.
4
4
  #
@@ -30,20 +30,20 @@
30
30
  #
31
31
  # Author: Robert Haines
32
32
 
33
+ require 'zip/errors'
34
+
33
35
  ##
34
36
  module ZipContainer
35
-
36
- # The base of all exceptions raised by this library.
37
+ # The base of all errors raised by this library.
37
38
  module Error
38
39
  end
39
40
 
40
41
  # Shadow Zip::Error so the rubyzip API doesn't leak out.
41
42
  ZipError = ::Zip::Error
42
- ZipError.send(:include, Error)
43
+ ZipError.include Error
43
44
 
44
- # This exception is raised when a bad Container is detected.
45
+ # This error is raised when a bad Container is detected.
45
46
  class MalformedContainerError < RuntimeError
46
-
47
47
  include Error
48
48
 
49
49
  # :call-seq:
@@ -65,10 +65,9 @@ module ZipContainer
65
65
  end
66
66
  end
67
67
 
68
- # This exception is raised when a clash occurs with a reserved or managed
68
+ # This error is raised when a clash occurs with a reserved or managed
69
69
  # name.
70
70
  class ReservedNameClashError < RuntimeError
71
-
72
71
  include Error
73
72
 
74
73
  # :call-seq:
@@ -79,5 +78,4 @@ module ZipContainer
79
78
  super("'#{name}' is reserved for internal use in this ZipContainer.")
80
79
  end
81
80
  end
82
-
83
81
  end