ruzip 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +1 -2
- data/.rdoc_options +9 -0
- data/CHANGELOG.md +6 -0
- data/README.md +21 -15
- data/Rakefile +4 -5
- data/ext/Cargo.lock +102 -220
- data/ext/Cargo.toml +4 -3
- data/ext/src/lib.rs +114 -100
- data/ruzip.gemspec +8 -5
- data/sig/ruzip.rbs +24 -2
- data/test/fixtures/.gitkeep +0 -0
- data/test/test_file.rb +8 -0
- data/test/test_package.rb +33 -0
- data/test/test_writer.rb +44 -0
- metadata +56 -20
- data/CODE_OF_CONDUCT.md +0 -84
- data/test/test_ruzip.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a3933d33701a2ef5266034395c9d150def3302051cc5e58cfec95e0c8781f26
|
|
4
|
+
data.tar.gz: 483047dd80f31be198c1123ee28f93c316d7041ea48c640936fe584d9573b9c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de64677667aabcf0f6d6246af4bb7ff0653f8c49b26f2b0b412ba68590c211865e64af5bf64ff2ebd18030c8d93aeb575e2963e3c3df5943a4bb295cb66f5090
|
|
7
|
+
data.tar.gz: 8fca9556da607ca7661457baf087c5f9063855538051142aad32452f770074d9879389ff8a1479a8d2ebb0fe8c16809ee12f30a6febee2d447b1e5d6ba190ec6
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
default:
|
|
2
|
-
image: ruby:
|
|
2
|
+
image: ruby:4.0.0
|
|
3
3
|
|
|
4
4
|
before_script:
|
|
5
5
|
- apt-get update && apt-get install -y clang
|
|
6
6
|
- curl https://sh.rustup.rs -sSf | sh -s -- -y
|
|
7
7
|
- . "$HOME/.cargo/env"
|
|
8
8
|
- gem update --system
|
|
9
|
-
- gem install bundler
|
|
10
9
|
- bundle install
|
|
11
10
|
|
|
12
11
|
test:
|
data/.rdoc_options
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
1
|
# RuZip
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruzip`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
3
|
+
Library to support the reading and writing of zip files. A wrapper of Rust's [zip](https://github.com/zip-rs/zip2?tab=readme-ov-file) crate.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
|
10
|
-
|
|
11
7
|
Install the gem and add to the application's Gemfile by executing:
|
|
12
8
|
|
|
13
|
-
$ bundle add
|
|
9
|
+
$ bundle add ruzip
|
|
14
10
|
|
|
15
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
16
12
|
|
|
17
|
-
$ gem install
|
|
13
|
+
$ gem install ruzip
|
|
18
14
|
|
|
19
15
|
## Usage
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
require "ruzip"
|
|
18
|
+
|
|
19
|
+
archive = RuZip::Archive.new("path/to/archive.zip")
|
|
20
|
+
archive.length #=> Integer, the number of files the archive holds
|
|
21
|
+
|
|
22
|
+
archive.length.times do |i|
|
|
23
|
+
file = archive.by_index(i) #=> RuZip::File
|
|
24
|
+
file.name # => String
|
|
25
|
+
file.size # => Integer, the size of decompressed file
|
|
26
|
+
file.last_modified # => Time
|
|
27
|
+
content = file.read # => ASCII-8BIT String (BINARY)
|
|
28
|
+
content.force_encoding("UTF-8") # If it's text, it is in UTF-8.
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
archive.by_name("path/in/zip/archive") # => RuZip::File
|
|
22
32
|
|
|
23
33
|
## Development
|
|
24
34
|
|
|
25
|
-
After checking out the repo, run `
|
|
35
|
+
After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bundle exec rake console` for an interactive prompt that will allow you to experiment.
|
|
26
36
|
|
|
27
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `
|
|
37
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `ext/Cargo.toml`, run `cargo update --manifest-path=ext/Cargo.toml`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
28
38
|
|
|
29
39
|
## Contributing
|
|
30
40
|
|
|
31
|
-
Bug reports and pull requests are welcome on
|
|
32
|
-
|
|
33
|
-
## Code of Conduct
|
|
34
|
-
|
|
35
|
-
Everyone interacting in the RuZip project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruzip/blob/main/CODE_OF_CONDUCT.md).
|
|
41
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/KitaitiMakoto/ruzip. This project is intended to be a safe, welcoming space for collaboration.
|
data/Rakefile
CHANGED
|
@@ -3,19 +3,18 @@ require "rake/testtask"
|
|
|
3
3
|
require "rubygems/ext"
|
|
4
4
|
require "rubygems/tasks"
|
|
5
5
|
require "kar/dsl"
|
|
6
|
+
require "rdoc/task"
|
|
6
7
|
|
|
7
8
|
cargo "ruzip"
|
|
8
9
|
|
|
9
10
|
Gem::Tasks.new
|
|
10
11
|
task build: "cargo:check"
|
|
11
12
|
|
|
12
|
-
Rake::TestTask.new
|
|
13
|
-
|
|
14
|
-
directory "test/fixtures"
|
|
15
13
|
TEST_FIXTURE = "test/fixtures/accessible_epub_3.epub"
|
|
16
|
-
file TEST_FIXTURE => "test/fixtures"
|
|
17
14
|
download TEST_FIXTURE => "https://github.com/IDPF/epub3-samples/releases/download/20230704/accessible_epub_3.epub"
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
Rake::TestTask.new test: [:cargo, TEST_FIXTURE]
|
|
17
|
+
|
|
18
|
+
RDoc::Task.new
|
|
20
19
|
|
|
21
20
|
task default: :test
|