zip-container 4.0.2 → 5.0.0.rc2

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: d56e4e0c34e786a2c40592c5162bd45ca4cb642e43a78af15d06a8ce0c6aa827
4
+ data.tar.gz: 67fe6c6ad79a1d462ad54496c27f80607d0eb5e92f31a8468a01129ced633d58
5
5
  SHA512:
6
- metadata.gz: ebe9848aaa420c00e28ed4223d43ca1e186b1905ac6e3102b1ee7661f8edee5e07a68960577651d5206aa98530ea253590e9b25618b2f0aca2655bac98954b23
7
- data.tar.gz: fec65830abe5391d805cfa2c3a417cfcc52cb47f1c99e5affebfb91b6262d3cd3292a39f4af5eea689cee4f4ff91568db0a797ee7dd706874e011b1e7798b297
6
+ metadata.gz: 64bd83f999efa1b885b99d3a29f01aea5cf078cf4d5ce3d232cf0dbe342e61602c5fb8339af87e9f57d41c4e7e13bf64359889389cbc38a87d3d242f67079f28
7
+ data.tar.gz: e70fb9bfb934c24148b3ec88b1c6a9665ed760e2f5bfc6325c6231704e4538ce4214f9fa85ceb32515b6f9ddbb0e40a787cdda7f2a127c123d11b1ace3d55376
@@ -1,14 +1,52 @@
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
+ * Ensure 'managed_directory' is required at the top-level.
13
+ * Add note README about ruby and RubyZip versions.
14
+ * Apply frozen_string_literal magic comment to all files.
15
+
16
+ ### Internal/tooling:
17
+
18
+ * Update Rake version.
19
+ * Update and add metadata in the gemspec.
20
+ * Just use a constant for the gem version string.
21
+ * Add a script to start IRB with ZipContainer loaded.
22
+ * Switch from Coveralls to Simplecov.
23
+ * Switch to use minitest for unit tests.
24
+ * Switch from Travis CI to GitHub Actions.
25
+ * Update Rubocop.
26
+ * Skip certain tests in non-POSIX environments.
27
+ * Fix managed directory test on Windows.
28
+ * Ensure simplecov is required first with MiniTest.
29
+
30
+ ## Version 4.0.2
31
+
32
+ * Bump rubyzip version again.
33
+
34
+ ## Version 4.0.1
35
+
36
+ * Don't package test files in the gem.
37
+ * Add rubocop configuration.
38
+ * Configure and fix many rubocop issues.
39
+ * Updated rubyzip to fix vulnerability.
40
+
41
+ ## Version 3.0.2
4
42
 
5
43
  * Update rubyzip dependency to fix security vulnerability.
6
44
 
7
- == Version 3.0.1
45
+ ## Version 3.0.1
8
46
 
9
47
  * Fix deep content verification bug.
10
48
 
11
- == Version 3.0.0
49
+ ## Version 3.0.0
12
50
 
13
51
  * Refactor the malformed container error constructor.
14
52
  * Verifying entries only raises errors at the last moment.
@@ -22,7 +60,7 @@
22
60
  * Add a compatibility note about ContainerError.
23
61
  * Improve the Usage information in the ReadMe.
24
62
 
25
- == Version 2.2.0
63
+ ## Version 2.2.0
26
64
 
27
65
  * Fix pathname bug in ZipContainer::Dir.
28
66
  * Fixup docs to refer to containers rather than documents.
@@ -30,7 +68,7 @@
30
68
  * Add an internal compatibility method Dir#entries.
31
69
  * Add a compatibility method Dir#read.
32
70
 
33
- == Version 2.1.0
71
+ ## Version 2.1.0
34
72
 
35
73
  * Set up the Container superclass.
36
74
  * Open the container from the superclass.
@@ -47,7 +85,7 @@
47
85
  * Update dependencies.
48
86
  * Disambiguate the two test classes for File and Dir.
49
87
 
50
- == Version 2.0.0
88
+ ## Version 2.0.0
51
89
 
52
90
  * Change API: Container => File.
53
91
  * Refactor exceptions so we can shadow rubyzip exceptions.
@@ -70,25 +108,25 @@
70
108
  * Document removal of ZipContainer::Container in the ReadMe.
71
109
  * Update rubyzip version to latest (1.1.6).
72
110
 
73
- == Version 1.1.0
111
+ ## Version 1.1.0
74
112
 
75
113
  * Bump version of rubyzip to 1.1.4.
76
114
 
77
- == Version 1.0.0
115
+ ## Version 1.0.0
78
116
 
79
117
  * Update to use version 1.0.0 of rubyzip.
80
118
 
81
- == Version 0.9.0
119
+ ## Version 0.9.0
82
120
 
83
121
  * Generalize the Container Error class names.
84
122
  * Polish example scripts.
85
123
 
86
- == Version 0.8.0
124
+ ## Version 0.8.0
87
125
 
88
126
  * Abstract out all the underlying zip functionality and turn this library
89
127
  into a basic ZIP Container provider.
90
128
 
91
- == Version 0.5.0
129
+ ## Version 0.5.0
92
130
 
93
131
  * Add support for managed entries in the container.
94
132
  * Verify and "optional" functionality for ManagedEntry.
@@ -99,7 +137,7 @@
99
137
  * Make file validation more flexible.
100
138
  * Fix the source of failing validation messages.
101
139
 
102
- == Version 0.1.0
140
+ ## Version 0.1.0
103
141
 
104
142
  * Improvements to the reserved names code to allow sub-classing.
105
143
  * Move exceptions to a new source file.
@@ -118,7 +156,7 @@
118
156
  * Separate the opening and checking of a UCF document.
119
157
  * Documentation improvements and cleanup.
120
158
 
121
- == Version 0.0.2
159
+ ## Version 0.0.2
122
160
 
123
161
  * Update the main ReadMe file.
124
162
  * Add support for multiple reserved names and fix checks.
@@ -128,15 +166,17 @@
128
166
  * Add an example program to list UCF contents.
129
167
  * Add a method to directly iterate over UCF entries.
130
168
 
131
- == Version 0.0.1
169
+ ## Version 0.0.1
132
170
 
133
171
  * Very basic UCF facilities complete (plus examples).
134
172
  * Two ways of verifying UCF files.
135
173
  * API documentation added.
136
174
  * Add tests.
137
175
 
138
- == About this Changes file
176
+ ## About this Changes file
139
177
 
140
178
  This file is, at least in part, generated by the following command:
141
179
 
142
- $ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
180
+ ```shell
181
+ $ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
182
+ ```
@@ -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
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2014 The University of Manchester, UK.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2014-2025 The University of Manchester, UK.
2
4
  #
3
5
  # All rights reserved.
4
6
  #
@@ -33,3 +35,10 @@
33
35
  source 'https://rubygems.org'
34
36
 
35
37
  gemspec
38
+
39
+ # TODO: remove when JRuby 9.4.12.0 will be released and available on CI
40
+ # Ref: https://github.com/jruby/jruby/issues/7262
41
+ if RUBY_PLATFORM.include?('java')
42
+ gem 'jar-dependencies', '0.4.1'
43
+ gem 'ruby-maven', '3.3.13'
44
+ 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,45 @@
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
+ #### Versions
32
+
33
+ Version 5 of this library will be the last to support Ruby 2.7 and the last to support RubyZip 2.4. Version 6 will require at least Ruby 3.0 and RubyZip 3.0.
34
+
35
+ ### What this library can not do yet
36
+
37
+ 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.
38
+
39
+ ### Developing ZIP Container Ruby Library
40
+
41
+ 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).
42
+
43
+ ### Licence
44
+
45
+ [3-Clause BSD Licence](https://opensource.org/license/bsd-3-clause). See LICENCE for details.
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2013-2018 The University of Manchester, UK.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2013-2025 The University of Manchester, UK.
2
4
  #
3
5
  # All rights reserved.
4
6
  #
@@ -31,25 +33,23 @@
31
33
  # Author: Robert Haines
32
34
 
33
35
  require 'bundler/gem_tasks'
34
- require 'rake/testtask'
36
+ require 'minitest/test_task'
35
37
  require 'rdoc/task'
36
38
  require 'rubocop/rake_task'
37
39
 
38
40
  task default: :test
39
41
 
40
- Rake::TestTask.new do |t|
41
- t.libs << 'test'
42
- t.test_files = FileList['test/ts_container.rb']
43
- t.verbose = true
42
+ Minitest::TestTask.create do |test|
43
+ test.framework = 'require "simplecov"'
44
+ test.test_globs = 'test/**/*_test.rb'
44
45
  end
45
46
 
46
47
  RDoc::Task.new do |r|
47
- r.main = 'ReadMe.rdoc'
48
+ r.main = 'README.md'
48
49
  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'
50
+ r.rdoc_files.include('README.md', 'LICENCE', 'CHANGES.md', lib)
51
+ r.options << "-t ZIP Container Format Ruby Library version #{ZipContainer::VERSION}"
52
+ r.options << '--markup=markdown'
53
53
  r.options << '--tab-width=2'
54
54
  end
55
55
 
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
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2013 The University of Manchester, UK.
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2013-2025 The University of Manchester, UK.
3
5
  #
4
6
  # All rights reserved.
5
7
  #
@@ -64,7 +66,7 @@ begin
64
66
  # Add a explanation of this file.
65
67
  c.comment = 'This is an example Container file!'
66
68
  end
67
- rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => err
68
- puts err.to_s
69
+ rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => e
70
+ puts e
69
71
  exit 1
70
72
  end
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2013 The University of Manchester, UK.
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2013-2025 The University of Manchester, UK.
3
5
  #
4
6
  # All rights reserved.
5
7
  #
@@ -45,7 +47,7 @@ container_file = ARGV[0]
45
47
 
46
48
  begin
47
49
  ZipContainer::File.verify!(container_file)
48
- rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => err
49
- puts err.to_s
50
+ rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => e
51
+ puts e
50
52
  exit 1
51
53
  end
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2013 The University of Manchester, UK.
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (c) 2013-2025 The University of Manchester, UK.
3
5
  #
4
6
  # All rights reserved.
5
7
  #
@@ -45,14 +47,14 @@ container_file = ARGV[0]
45
47
 
46
48
  begin
47
49
  container = ZipContainer::File.open(container_file)
48
- rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => err
49
- puts err.to_s
50
+ rescue ZipContainer::MalformedContainerError, ZipContainer::ZipError => e
51
+ puts e
50
52
  exit 1
51
53
  end
52
54
 
53
55
  puts "Archive: #{container}"
54
- puts "Container file size: #{File.size(container_file)} bytes, "\
55
- "number of entries: #{container.size}"
56
+ puts "Container file size: #{File.size(container_file)} bytes, " \
57
+ "number of entries: #{container.size}"
56
58
 
57
59
  total_size = 0
58
60
  total_comp = 0
@@ -66,5 +68,5 @@ container.each do |entry|
66
68
  end
67
69
 
68
70
  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)}%"
71
+ puts "#{container.size} files, #{total_size} bytes uncompressed, " \
72
+ "#{total_comp} bytes compressed: #{ratio.round(1)}%"
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2014, 2015 The University of Manchester, UK.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2014-2025 The University of Manchester, UK.
2
4
  #
3
5
  # All rights reserved.
4
6
  #
@@ -30,14 +32,16 @@
30
32
  #
31
33
  # Author: Robert Haines
32
34
 
35
+ require_relative 'errors'
36
+ require_relative 'managed_entries'
37
+ require_relative 'reserved_names'
38
+
33
39
  ##
34
40
  module ZipContainer
35
-
36
41
  # The superclass of anything that represents a Zip Container. That
37
42
  # representation could be as a Zip file (most commonly), as a directory or
38
43
  # something else.
39
44
  class Container
40
-
41
45
  include ReservedNames
42
46
  include ManagedEntries
43
47
 
@@ -48,7 +52,7 @@ module ZipContainer
48
52
 
49
53
  # :stopdoc:
50
54
  # The reserved mimetype file name for standard ZipContainers.
51
- MIMETYPE_FILE = 'mimetype'.freeze
55
+ MIMETYPE_FILE = 'mimetype'
52
56
 
53
57
  def initialize(location)
54
58
  @container = open_container(location)
@@ -111,9 +115,8 @@ module ZipContainer
111
115
  # verify!(filename)
112
116
  #
113
117
  # 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).
118
+ # This method raises an error if there is something fundamental wrong
119
+ # with the container itself (e.g. it cannot be found).
117
120
  def self.verify!(filename)
118
121
  new(filename).verify!
119
122
  end
@@ -136,7 +139,7 @@ module ZipContainer
136
139
  # This method returns +false+ if there are any problems at all with the
137
140
  # container.
138
141
  def verify?
139
- verify.empty? ? true : false
142
+ verify.empty?
140
143
  end
141
144
 
142
145
  # :call-seq:
@@ -153,5 +156,4 @@ module ZipContainer
153
156
  verify_managed_entries!
154
157
  end
155
158
  end
156
-
157
159
  end
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2014 The University of Manchester, UK.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2014-2025 The University of Manchester, UK.
2
4
  #
3
5
  # All rights reserved.
4
6
  #
@@ -30,10 +32,11 @@
30
32
  #
31
33
  # Author: Robert Haines
32
34
 
35
+ require_relative 'container'
36
+
33
37
  require 'forwardable'
34
38
 
35
39
  module ZipContainer
36
-
37
40
  # This class represents a ZipContainer in directory format. See the
38
41
  # {OCF}[http://www.idpf.org/epub/30/spec/epub30-ocf.html] and
39
42
  # {UCF}[https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format]
@@ -46,19 +49,12 @@ module ZipContainer
46
49
  #
47
50
  # There are code examples available with the source code of this library.
48
51
  class Dir < Container
49
-
50
52
  extend Forwardable
51
53
  def_delegators :@container, :close, :each, :path, :pos, :pos=, :rewind,
52
54
  :seek, :tell
53
55
 
54
56
  private_class_method :new
55
57
 
56
- # :stopdoc:
57
- def initialize(location)
58
- super(location)
59
- end
60
- # :startdoc:
61
-
62
58
  # :call-seq:
63
59
  # create(pathname, mimetype) -> container
64
60
  # create(pathname, mimetype) {|container| ...}
@@ -109,7 +105,6 @@ module ZipContainer
109
105
  end
110
106
 
111
107
  class Entries # :nodoc:
112
-
113
108
  include Enumerable
114
109
 
115
110
  Entry = Struct.new(:name, :ftype)
@@ -123,10 +118,8 @@ module ZipContainer
123
118
  end
124
119
  end
125
120
 
126
- def each
127
- @entries.each do |entry|
128
- yield entry
129
- end
121
+ def each(&block)
122
+ @entries.each(&block)
130
123
  end
131
124
  end
132
125
  # :startdoc:
@@ -224,5 +217,4 @@ module ZipContainer
224
217
  # Equal to
225
218
  # {::Dir.tell}[http://ruby-doc.org/core-1.9.3/Dir.html#method-i-tell]
226
219
  end
227
-
228
220
  end