ucf 2.0.2 → 3.0.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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/latest-docs.yml +29 -0
  3. data/.github/workflows/lint.yml +19 -0
  4. data/.github/workflows/tests.yml +89 -0
  5. data/.gitignore +3 -0
  6. data/.rubocop.yml +63 -0
  7. data/{test/tc_read_dir.rb → .simplecov} +19 -21
  8. data/{Changes.rdoc → CHANGES.md} +41 -14
  9. data/CODE_OF_CONDUCT.md +74 -0
  10. data/CONTRIBUTING.md +67 -0
  11. data/Gemfile +4 -2
  12. data/{Licence.rdoc → LICENCE} +1 -1
  13. data/README.md +57 -0
  14. data/Rakefile +21 -18
  15. data/bin/console +15 -0
  16. data/bin/setup +6 -0
  17. data/examples/create-ucf +11 -10
  18. data/examples/ucfinfo +11 -7
  19. data/examples/verify-ucf +5 -3
  20. data/lib/ucf/dir.rb +7 -8
  21. data/lib/ucf/file.rb +7 -8
  22. data/lib/ucf/{meta-inf.rb → meta_inf.rb} +24 -23
  23. data/lib/ucf/version.rb +6 -13
  24. data/lib/ucf.rb +4 -2
  25. data/ucf.gemspec +46 -31
  26. metadata +108 -83
  27. data/.ruby-env +0 -1
  28. data/.ruby-gemset +0 -1
  29. data/.ruby-version +0 -1
  30. data/.travis.yml +0 -19
  31. data/ReadMe.rdoc +0 -90
  32. data/test/data/META-INF/container.xml +0 -13
  33. data/test/data/META-INF/manifest.xml +0 -26
  34. data/test/data/compressed_mimetype.ucf +0 -0
  35. data/test/data/dirs/empty/mimetype +0 -1
  36. data/test/data/dirs/managed/greeting.txt +0 -1
  37. data/test/data/dirs/managed/mimetype +0 -1
  38. data/test/data/dirs/null/.gitkeep +0 -1
  39. data/test/data/empty.ucf +0 -0
  40. data/test/data/empty.zip +0 -0
  41. data/test/data/example.ucf +0 -0
  42. data/test/data/null.file +0 -0
  43. data/test/tc_create_file.rb +0 -142
  44. data/test/tc_managed_entries.rb +0 -238
  45. data/test/tc_read_file.rb +0 -119
  46. data/test/tc_reserved_names.rb +0 -357
  47. data/test/ts_ucf.rb +0 -52
  48. data/version.yml +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f267e62b0019f1239fcee77be2f5ca2f5ebe49b0937faa7c2288d40dd381ab4b
4
- data.tar.gz: 29f4f89813f92d56a5f73601a3c7c44156df4757c7047992380abe8769381964
3
+ metadata.gz: 45e68bb0b3234a7d195436ae50355f48dd1a328dddf9006abe332aae2ce9e581
4
+ data.tar.gz: 9dd69431276430cd0e21b6b957c5bfb74b6de73ef331e785db7aac85a7378480
5
5
  SHA512:
6
- metadata.gz: 3fc0af5f72c78a58659bf93be2e73f0981ec0b332ba17015aa147ceb8c63a129b789168c071e5e3160b48301a97db1356e1e8a40ac77721805465d0ab6680b36
7
- data.tar.gz: 86aa40b6a057b141f34b62cf01af8f17842488d3f8ff84d0595d0e85bd0c0993ada43c4d51f450b8e68316d10ee33691a462090f8444c58419906a6533ee83df
6
+ metadata.gz: 18c8ebeeb0bff5e112e202f52ee6823d0e3672549455c5113f503cbeda08568187444067a789c2b09eccadf1cbdc18a88f19404642fea173a8a47346b146d8f9
7
+ data.tar.gz: 9e51cacb95be6e8b871998e8cbc7fd5a588260b7a5b77d21615ba2410626fe54f2dd4b9773ddb8e697819bd81ce94a5598b8eae7ce7d49c8731bfc34bde4178e
@@ -0,0 +1,29 @@
1
+ name: Latest documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ docs:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout UCF code
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Install and set up ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: '3.1'
19
+ bundler-cache: true
20
+
21
+ - name: Run RDoc
22
+ run: bundle exec rake rdoc
23
+
24
+ - name: Deploy
25
+ uses: JamesIves/github-pages-deploy-action@v4
26
+ with:
27
+ branch: gh-pages
28
+ folder: html
29
+ target-folder: latest
@@ -0,0 +1,19 @@
1
+ name: Linter
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - name: Checkout rubyzip code
10
+ uses: actions/checkout@v3
11
+
12
+ - name: Install and set up ruby
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: '3.1'
16
+ bundler-cache: true
17
+
18
+ - name: Rubocop
19
+ run: bundle exec rubocop -f github
@@ -0,0 +1,89 @@
1
+ name: Tests
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ os: [ubuntu]
11
+ ruby: ['3.1', '3.2', '3.3', '3.4', head, jruby, jruby-head, truffleruby, truffleruby-head]
12
+ include:
13
+ - os: macos
14
+ ruby: '3.1'
15
+ - os: windows
16
+ ruby: '3.1'
17
+ runs-on: ${{ matrix.os }}-latest
18
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.os == 'windows' || matrix.ruby == 'truffleruby' }}
19
+ steps:
20
+ - name: Checkout rubyzip code
21
+ uses: actions/checkout@v3
22
+
23
+ - name: Install and set up ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby }}
27
+ bundler-cache: true
28
+
29
+ - name: Run the tests
30
+ env:
31
+ RUBYOPT: -v
32
+ JRUBY_OPTS: --debug
33
+ run: bundle exec rake
34
+
35
+ - name: Coveralls
36
+ if: matrix.os == 'ubuntu' && !endsWith(matrix.ruby, 'head')
37
+ uses: coverallsapp/github-action@master
38
+ with:
39
+ github-token: ${{ secrets.github_token }}
40
+ flag-name: ${{ matrix.ruby }}
41
+ parallel: true
42
+
43
+ test-isolated:
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - name: Checkout rubyzip code
47
+ uses: actions/checkout@v3
48
+
49
+ - name: Install and set up ruby
50
+ uses: ruby/setup-ruby@v1
51
+ with:
52
+ ruby-version: '3.1'
53
+ bundler-cache: true
54
+
55
+ - name: Run isolated tests
56
+ run: bundle exec rake test:isolated
57
+
58
+ test-yjit:
59
+ strategy:
60
+ fail-fast: false
61
+ matrix:
62
+ os: [ubuntu, macos]
63
+ ruby: ['3.1', '3.2', '3.3', '3.4', head]
64
+ runs-on: ${{ matrix.os }}-latest
65
+ continue-on-error: true
66
+ steps:
67
+ - name: Checkout rubyzip code
68
+ uses: actions/checkout@v3
69
+
70
+ - name: Install and set up ruby
71
+ uses: ruby/setup-ruby@v1
72
+ with:
73
+ ruby-version: ${{ matrix.ruby }}
74
+ bundler-cache: true
75
+
76
+ - name: Run the tests
77
+ env:
78
+ RUBYOPT: --enable-yjit -v
79
+ run: bundle exec rake
80
+
81
+ finish:
82
+ needs: test
83
+ runs-on: ubuntu-latest
84
+ steps:
85
+ - name: Coveralls Finished
86
+ uses: coverallsapp/github-action@master
87
+ with:
88
+ github-token: ${{ secrets.github_token }}
89
+ parallel-finished: true
data/.gitignore CHANGED
@@ -7,3 +7,6 @@ coverage/
7
7
  .rvmrc
8
8
  Gemfile.lock
9
9
  example.zip
10
+ .ruby-env
11
+ .ruby-gemset
12
+ .ruby-version
data/.rubocop.yml ADDED
@@ -0,0 +1,63 @@
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-performance
4
+ - rubocop-rake
5
+
6
+ # Set our base version of ruby and enable all cops.
7
+ AllCops:
8
+ TargetRubyVersion: 3.0
9
+ NewCops: enable
10
+
11
+ # I think 'has_key?' looks better than 'key?'.
12
+ Style/PreferredHashMethods:
13
+ EnforcedStyle: verbose
14
+
15
+ # Allow long lines in the tests.
16
+ Layout/LineLength:
17
+ Max: 100
18
+ Exclude:
19
+ - 'test/**/*.rb'
20
+
21
+ # Force ruby19 style hash keys, but be consistent within a hash.
22
+ Style/HashSyntax:
23
+ EnforcedStyle: ruby19_no_mixed_keys
24
+
25
+ # Enforce %w notation in the library code, but be less strict in tests.
26
+ Style/WordArray:
27
+ Exclude:
28
+ - 'test/**/*.rb'
29
+
30
+ # Ignore ABC failures in the tests.
31
+ Metrics/AbcSize:
32
+ Exclude:
33
+ - 'test/**/*.rb'
34
+
35
+ # Ignore block length failures in the tests.
36
+ Metrics/BlockLength:
37
+ Exclude:
38
+ - 'ucf.gemspec'
39
+ - 'test/**/*.rb'
40
+
41
+ # Set a more reasonable method length and ignore failures in the tests.
42
+ Metrics/MethodLength:
43
+ Max: 20
44
+ Exclude:
45
+ - 'test/**/*.rb'
46
+
47
+ # Set a more reasonable class length and ignore failures in the tests.
48
+ Metrics/ClassLength:
49
+ Max: 150
50
+ Exclude:
51
+ - 'test/**/*.rb'
52
+
53
+ # This is still too high, but we'll get there.
54
+ Minitest/MultipleAssertions:
55
+ Max: 10
56
+
57
+ Style/Documentation:
58
+ Exclude:
59
+ - 'test/**/*.rb'
60
+ - 'examples/*'
61
+
62
+ Style/DocumentDynamicEvalDefinition:
63
+ Enabled: true
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2014, 2015 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
  #
@@ -30,27 +32,23 @@
30
32
  #
31
33
  # Author: Robert Haines
32
34
 
33
- require 'test/unit'
34
- require 'ucf'
35
-
36
- class TestReadDir < Test::Unit::TestCase
37
-
38
- # Check that the empty directory does not verify.
39
- def test_verify_empty_directory
40
- assert_raise(ZipContainer::MalformedContainerError) do
41
- UCF::Dir.verify!($dir_null)
42
- end
35
+ require 'simplecov-lcov'
43
36
 
44
- refute(UCF::Dir.verify?($dir_null))
45
- end
46
-
47
- # Check that the empty container directory does verify.
48
- def test_verify_empty_container
49
- assert_nothing_raised(ZipContainer::MalformedContainerError) do
50
- UCF::Dir.verify!($dir_empty)
51
- end
37
+ SimpleCov::Formatter::LcovFormatter.config do |c|
38
+ c.output_directory = 'coverage'
39
+ c.lcov_file_name = 'lcov.info'
40
+ c.report_with_single_file = true
41
+ c.single_report_path = 'coverage/lcov.info'
42
+ end
52
43
 
53
- assert(UCF::Dir.verify?($dir_empty))
54
- end
44
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
45
+ [
46
+ SimpleCov::Formatter::HTMLFormatter,
47
+ SimpleCov::Formatter::LcovFormatter
48
+ ]
49
+ )
55
50
 
51
+ SimpleCov.start do
52
+ enable_coverage :branch
53
+ add_filter '/test/'
56
54
  end
@@ -1,17 +1,42 @@
1
- = Changes log for the UCF Ruby Gem
2
-
3
- == Version 2.0.1
1
+ # Changes log for the UCF Ruby Gem
2
+
3
+ ## Version 3.0.0
4
+
5
+ * Update minimum ruby version required to 3.0.
6
+ * Add a code of conduct.
7
+ * Add contributing guidelines.
8
+ * Update to use zip-container v6.
9
+ * Fix various links in the documentation.
10
+
11
+ ### Internal/tooling:
12
+
13
+ * Ensure CI tests are run with Ruby >=3.1 due to Nokogiri requirements.
14
+ * Update rdoc and convert some rdoc files to md.
15
+ * Update and add metadata in the gemspec.
16
+ * Just use a constant for the gem version string.
17
+ * Add a setup script.
18
+ * Add a script to start IRB with UCF loaded.
19
+ * Switch from Coveralls to Simplecov.
20
+ * Switch to use minitest for unit tests.
21
+ * Switch from Travis CI to GitHub Actions.
22
+ * Add Rubocop.
23
+ * Add a linting GitHub Action.
24
+ * Set Rubocop output to use GitHub format.
25
+ * Add an Action to build the latest documentation.
26
+ * Add a test to ensure our version numbers are sane.
27
+
28
+ ## Version 2.0.1
4
29
 
5
30
  * Update zip-container dependency to fix rubyzip security vulnerability.
6
31
 
7
- == Version 2.0.0
32
+ ## Version 2.0.0
8
33
 
9
34
  * Add ruby 2.2.0 to the Travis test matrix.
10
35
  * Update examples and tests to use the latest API.
11
36
  * Add some usage information to the ReadMe.
12
37
  * Update to version 3.0.1 of zip-container.
13
38
 
14
- == Version 1.1.0
39
+ ## Version 1.1.0
15
40
 
16
41
  * Tidy up gemspec and update dependency versions.
17
42
  * Add test-unit to the deps so we can test in ruby 2.2.
@@ -21,13 +46,13 @@
21
46
  * Update zip-container dependency to 2.2.
22
47
  * Add the UCF::Dir class to create exploded containers.
23
48
 
24
- == Version 1.0.0
49
+ ## Version 1.0.0
25
50
 
26
51
  * Rename UCF::Container to UCF::File.
27
52
  * Use released zip-container 2.0 gem.
28
53
  * Remove UCF::Container compatibility.
29
54
 
30
- == Version 0.7.0
55
+ ## Version 0.7.0
31
56
 
32
57
  * Update to be able to use the newer zip-container gem.
33
58
  * Add ability to use a custom mimetype.
@@ -35,12 +60,12 @@
35
60
  * Verify META-INF/manifest.xml against its schema.
36
61
  * Add META-INF content to the example ucf file.
37
62
 
38
- == Version 0.6.0
63
+ ## Version 0.6.0
39
64
 
40
65
  * Move to use version 0.9.0 of the zip-container library.
41
66
  * Update and polish the example scripts.
42
67
 
43
- == Version 0.5.0
68
+ ## Version 0.5.0
44
69
 
45
70
  * Add support for managed entries in the container.
46
71
  * Verify and "optional" functionality for ManagedEntry.
@@ -51,7 +76,7 @@
51
76
  * Make file validation more flexible.
52
77
  * Fix the source of failing validation messages.
53
78
 
54
- == Version 0.1.0
79
+ ## Version 0.1.0
55
80
 
56
81
  * Improvements to the reserved names code to allow sub-classing.
57
82
  * Move exceptions to a new source file.
@@ -70,7 +95,7 @@
70
95
  * Separate the opening and checking of a UCF document.
71
96
  * Documentation improvements and cleanup.
72
97
 
73
- == Version 0.0.2
98
+ ## Version 0.0.2
74
99
 
75
100
  * Update the main ReadMe file.
76
101
  * Add support for multiple reserved names and fix checks.
@@ -80,15 +105,17 @@
80
105
  * Add an example program to list UCF contents.
81
106
  * Add a method to directly iterate over UCF entries.
82
107
 
83
- == Version 0.0.1
108
+ ## Version 0.0.1
84
109
 
85
110
  * Very basic UCF facilities complete (plus examples).
86
111
  * Two ways of verifying UCF files.
87
112
  * API documentation added.
88
113
  * Add tests.
89
114
 
90
- == About this Changes file
115
+ ## About this Changes file
91
116
 
92
117
  This file is, at least in part, generated by the following command:
93
118
 
94
- $ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
119
+ ```shell
120
+ $ git log --pretty=format:"* %s" --reverse --no-merges <commit-hash>..
121
+ ```
@@ -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 UCF Library
2
+ ## Introduction
3
+
4
+ **Thank you** for considering a contribution to the **Ruby UCF 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 UCF, or tweet about it
11
+ * Write blog posts, tutorials, etc. about Ruby UCF
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 UCF is valued, and it should be an enjoyable experience. To ensure this there is the Ruby UCF
18
+ [Code of Conduct](https://github.com/hainesr/ruby-ucf/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-ucf/issues). This may mean [creating a new issue](https://github.com/hainesr/ruby-ucf/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 UCF, is in scope, and aligns with the roadmap for the Ruby UCF and the Citation File Format.
24
+
25
+ ## Your First Contribution
26
+
27
+ If you are unsure where to begin with your contribution to Ruby UCF, have a look at the [open issues in this repository](https://github.com/hainesr/ruby-ucf/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-ucf/blob/main/CODE_OF_CONDUCT.md)
36
+ 1. [Create a new issue](https://github.com/hainesr/ruby-ucf/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 UCF, which also contains a collection of test UCF files - both valid and invalid. Please add tests (and new test UCF 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-ucf/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
  #
@@ -30,6 +32,6 @@
30
32
  #
31
33
  # Author: Robert Haines
32
34
 
33
- source "https://rubygems.org"
35
+ source 'https://rubygems.org'
34
36
 
35
37
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2015 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,57 @@
1
+ # Universal Container Format (UCF) Ruby Library
2
+ ## Robert Haines
3
+
4
+ A Ruby library for creating, editing and validating UCF files.
5
+
6
+ [![Gem Version](https://badge.fury.io/rb/ucf.svg)](https://badge.fury.io/rb/ucf)
7
+ [![Tests](https://github.com/hainesr/ruby-ucf/actions/workflows/tests.yml/badge.svg)](https://github.com/hainesr/ruby-ucf/actions/workflows/tests.yml)
8
+ [![Linter](https://github.com/hainesr/ruby-ucf/actions/workflows/lint.yml/badge.svg)](https://github.com/hainesr/ruby-ucf/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/feb6586086c0151adadd/maintainability)](https://codeclimate.com/github/hainesr/ruby-ucf/maintainability)
11
+ [![Coverage Status](https://coveralls.io/repos/github/hainesr/ruby-ucf/badge.svg)](https://coveralls.io/github/hainesr/ruby-ucf)
12
+
13
+ ### Synopsis
14
+
15
+ This is a Ruby library for working with UCF documents. See [the specification](https://learn.adobe.com/wiki/display/PDFNAV/Universal+Container+Format) for more details. UCF is a type of EPUB and very similar to the [EPUB Open Container Format (OCF)](http://www.idpf.org/epub/30/spec/epub30-ocf.html).
16
+
17
+ Most of this library's API is provided by the underlying [zip-container gem](https://rubygems.org/gems/zip-container) so you will need to consult [that documentation as well](http://hainesr.github.io/ruby-zip-container/) in addition to this.
18
+
19
+ 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.
20
+
21
+ ### Usage
22
+
23
+ This library has two entry points.
24
+
25
+ The main `UCF::File` class is a specialization of [ZipContainer::File](https://hainesr.github.io/ruby-zip-container/latest/ZipContainer/File.html) which largely mimics the rubyzip [Zip::File](https://www.rubydoc.info/gems/rubyzip/3.0.1/Zip/File) and [Zip::FileSystem](http://www.rubydoc.info/gems/rubyzip/3.0.1/Zip/FileSystem) APIs.
26
+
27
+ The `UCF::Dir` class is a based upon the [ZipContainer::Dir](https://hainesr.github.io/ruby-zip-container/latest/ZipContainer/Dir.html) class which mimics, where possible, the core ruby [Dir API](https://rubyapi.org/3.0/o/dir).
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
+ ### Files in the META-INF directory
32
+
33
+ The UCF specification requires that files in the META-INF directory are validated against a schema if they are present. If the [nokogiri gem](https://rubygems.org/gems/nokogiri) is available then this library will use it to validate the contents of the `container.xml` and `manifest.xml` files. This functionality is not enforced on the user in case they are not using the META-INF directory and so would not need the extra dependency on nokogiri.
34
+
35
+ #### Ruby version requirements and nokogiri
36
+
37
+ When used on its own the UCF library requires Ruby version >=3.0, however, if you are using nokogiri for schema validation then you need to use Ruby version >=3.1 to satisfy its version constraints.
38
+
39
+ ### What this library can not do yet
40
+
41
+ The basic requirements of a UCF document are all implemented but there are a number of optional features that are not yet provided.
42
+
43
+ * Validation of all file contents in the META-INF directory. The `container.xml` and `manifest.xml` files are validated but others are not yet.
44
+ * Digital signatures (this feature has been deferred until a future revision of the UCF specification. It will be supported by this gem when it is added to the specification).
45
+ * Encryption (this feature has been deferred until a future revision of the UCF specification. It will be supported by this gem when it is added to the specification).
46
+
47
+ ### Library versions
48
+
49
+ From version 1.0.0 onwards, the principles of [semantic versioning](https://semver.org/) are applied when numbering releases with new features or breaking changes.
50
+
51
+ ### Developing Ruby UCF
52
+
53
+ Please see our [Code of Conduct](https://github.com/hainesr/ruby-ucf/blob/main/CODE_OF_CONDUCT.md) and our [contributor guidelines](https://github.com/hainesr/ruby-ucf/blob/main/CONTRIBUTING.md).
54
+
55
+ ### Licence
56
+
57
+ BSD (See LICENCE file or http://www.opensource.org/licenses/bsd-license.php).
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2013, 2014 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
  #
@@ -30,26 +32,27 @@
30
32
  #
31
33
  # Author: Robert Haines
32
34
 
33
- require "bundler/gem_tasks"
34
- require "rake/testtask"
35
- require "rdoc/task"
35
+ require 'bundler/gem_tasks'
36
+ require 'minitest/test_task'
37
+ require 'rdoc/task'
38
+ require 'rubocop/rake_task'
36
39
 
37
- task :default => [:test]
40
+ task default: :test
38
41
 
39
- Rake::TestTask.new do |t|
40
- t.libs << "test"
41
- t.test_files = FileList['test/ts_ucf.rb']
42
- t.verbose = true
42
+ Minitest::TestTask.create do |test|
43
+ test.framework = 'require "simplecov"'
44
+ test.test_globs = 'test/**/*_test.rb'
43
45
  end
44
46
 
45
47
  RDoc::Task.new do |r|
46
- r.main = "ReadMe.rdoc"
47
- lib = Dir.glob("lib/**/*.rb").delete_if do |item|
48
- item.include?("meta-inf.rb")
49
- end
50
- r.rdoc_files.include("ReadMe.rdoc", "Licence.rdoc", "Changes.rdoc", lib)
51
- r.options << "-t Universal Container Format Ruby Library version " +
52
- "#{UCF::Version::STRING}"
53
- r.options << "-N"
54
- r.options << "--tab-width=2"
48
+ r.main = 'README.md'
49
+ r.rdoc_files.include(
50
+ 'README.md', 'LICENCE', 'CODE_OF_CONDUCT.md',
51
+ 'CONTRIBUTING.md', 'CHANGES.md', 'lib/**/*.rb'
52
+ )
53
+ r.options << "-t Universal Container Format Ruby Library version #{UCF::VERSION}"
54
+ r.options << '--markup=markdown'
55
+ r.options << '--tab-width=2'
55
56
  end
57
+
58
+ RuboCop::RakeTask.new