archive_r_ruby 0.1.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 +7 -0
- data/LICENSE +56 -0
- data/README.md +103 -0
- data/ext/archive_r/archive_r_ext.cc +910 -0
- data/ext/archive_r/extconf.rb +90 -0
- data/ext/archive_r/vendor/archive_r/LICENSE.txt +56 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/data_stream.h +41 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry.h +161 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry_fault.h +34 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/entry_metadata.h +56 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/multi_volume_stream_base.h +46 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy.h +109 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy_utils.h +37 -0
- data/ext/archive_r/vendor/archive_r/include/archive_r/traverser.h +122 -0
- data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.cc +330 -0
- data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.h +98 -0
- data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.cc +162 -0
- data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.h +54 -0
- data/ext/archive_r/vendor/archive_r/src/archive_type.cc +552 -0
- data/ext/archive_r/vendor/archive_r/src/archive_type.h +76 -0
- data/ext/archive_r/vendor/archive_r/src/data_stream.cc +35 -0
- data/ext/archive_r/vendor/archive_r/src/entry.cc +253 -0
- data/ext/archive_r/vendor/archive_r/src/entry_fault.cc +26 -0
- data/ext/archive_r/vendor/archive_r/src/entry_fault_error.cc +54 -0
- data/ext/archive_r/vendor/archive_r/src/entry_fault_error.h +32 -0
- data/ext/archive_r/vendor/archive_r/src/entry_impl.h +58 -0
- data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.cc +81 -0
- data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.h +41 -0
- data/ext/archive_r/vendor/archive_r/src/multi_volume_stream_base.cc +199 -0
- data/ext/archive_r/vendor/archive_r/src/path_hierarchy.cc +151 -0
- data/ext/archive_r/vendor/archive_r/src/path_hierarchy_utils.cc +304 -0
- data/ext/archive_r/vendor/archive_r/src/simple_profiler.h +120 -0
- data/ext/archive_r/vendor/archive_r/src/system_file_stream.cc +263 -0
- data/ext/archive_r/vendor/archive_r/src/system_file_stream.h +46 -0
- data/ext/archive_r/vendor/archive_r/src/traverser.cc +314 -0
- data/lib/archive_r.rb +80 -0
- metadata +112 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1ef63ef41cb26313bcc87243183c84d78e9b8fbc14ae05dd76b3db70b8f0fa48
|
|
4
|
+
data.tar.gz: f4a2cb797ce90ee25cd95f033df55a71c52db54376931bdd6e531b2ba493baf1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 55ab5d4f7b2d7636bdf3fb46a0bc562dc1e445eed7c14a6b217888982d38cc59d68f0791b69911c47ba20ec482e2dac31504ee5a22189acb434c972868b81973
|
|
7
|
+
data.tar.gz: 32993a36c25247c88ff17d9b577fba22f5f75516964e2176f6dc6e25df4892eb5ea422df44d2b7da89b3c5095ee045805c67b137968838af70123b4d60364ece
|
data/LICENSE
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
archive_r License
|
|
2
|
+
Version: 0.1.0 (2025-10-25)
|
|
3
|
+
|
|
4
|
+
----------------------------------------
|
|
5
|
+
Primary License
|
|
6
|
+
----------------------------------------
|
|
7
|
+
|
|
8
|
+
MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2025 archive_r Team
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
----------------------------------------
|
|
31
|
+
Third-Party Notices
|
|
32
|
+
----------------------------------------
|
|
33
|
+
|
|
34
|
+
This distribution bundles or links against the following third-party
|
|
35
|
+
components. Their respective license terms apply in addition to the MIT
|
|
36
|
+
License shown above.
|
|
37
|
+
|
|
38
|
+
1. libarchive
|
|
39
|
+
- Purpose: core archive reading and writing functionality for the C++
|
|
40
|
+
library and language bindings.
|
|
41
|
+
- License: New BSD License (https://www.libarchive.org/)
|
|
42
|
+
|
|
43
|
+
2. pybind11
|
|
44
|
+
- Purpose: header-only binding generator for the Python extension module.
|
|
45
|
+
- License: BSD-style License (https://github.com/pybind/pybind11)
|
|
46
|
+
|
|
47
|
+
3. rake (development dependency for Ruby bindings)
|
|
48
|
+
- Purpose: build and release tasks for the Ruby gem.
|
|
49
|
+
- License: MIT License (https://github.com/ruby/rake)
|
|
50
|
+
|
|
51
|
+
4. minitest (development dependency for Ruby bindings)
|
|
52
|
+
- Purpose: unit testing framework for the Ruby gem.
|
|
53
|
+
- License: MIT License (https://github.com/minitest/minitest)
|
|
54
|
+
|
|
55
|
+
Users of archive_r should review the linked third-party licenses to ensure
|
|
56
|
+
compliance with their terms when redistributing this software.
|
data/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# archive_r Ruby Binding
|
|
2
|
+
|
|
3
|
+
Ruby bindings expose the archive_r traverser API with a natural, block-friendly interface. This document consolidates the Ruby-specific instructions that previously lived in the repository root README.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Ruby 3.2 (same toolchain as the development environment)
|
|
8
|
+
- libarchive 3.x (shared library and headers)
|
|
9
|
+
- Build tools: `rake`, `minitest`, a C++17 compiler, and `make`
|
|
10
|
+
|
|
11
|
+
## Installing the Gem
|
|
12
|
+
|
|
13
|
+
### Recommended: build.sh workflow
|
|
14
|
+
|
|
15
|
+
1. From the repository root run:
|
|
16
|
+
```bash
|
|
17
|
+
./build.sh --with-ruby
|
|
18
|
+
```
|
|
19
|
+
Ruby packaging is enabled by default, so the command above builds the core library, compiles the binding, and creates `build/bindings/ruby/archive_r-<version>.gem`.
|
|
20
|
+
2. Install the freshly built gem into your desired GEM_HOME:
|
|
21
|
+
```bash
|
|
22
|
+
gem install --local build/bindings/ruby/archive_r-*.gem
|
|
23
|
+
```
|
|
24
|
+
3. When developing inside this repository the tests automatically install the gem into `build/ruby_gem_home` and set `ARCHIVE_R_CORE_ROOT=build` so the native extension links against the just-built static library.
|
|
25
|
+
|
|
26
|
+
### Working inside bindings/ruby
|
|
27
|
+
|
|
28
|
+
If you prefer to build from the `bindings/ruby` directory:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cd bindings/ruby
|
|
32
|
+
bundle install
|
|
33
|
+
bundle exec rake compile # builds ext/archive_r
|
|
34
|
+
bundle exec rake test # runs test/test_traverser.rb
|
|
35
|
+
bundle exec rake build # creates archive_r-<version>.gem locally
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The `rake test` task compiles the extension, installs it into `lib/`, and executes the Minitest suite.
|
|
39
|
+
|
|
40
|
+
## Running the full repository test suite
|
|
41
|
+
|
|
42
|
+
`./run_tests.sh` prepares a clean GEM_HOME (`build/ruby_gem_home`), installs the gem produced in `build/bindings/ruby`, and runs `bindings/ruby/test/test_traverser.rb`. The script now streams the `gem install` log to the console and preserves it in `build/logs/ruby_gem_install.log` for later inspection.
|
|
43
|
+
|
|
44
|
+
## Usage Example
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
require 'archive_r'
|
|
48
|
+
|
|
49
|
+
SAFE_FORMATS = Archive_r::STANDARD_FORMATS
|
|
50
|
+
|
|
51
|
+
def search_in_entry(entry, keyword)
|
|
52
|
+
overlap = ''
|
|
53
|
+
loop do
|
|
54
|
+
chunk = entry.read(8192)
|
|
55
|
+
break if chunk.nil? || chunk.empty?
|
|
56
|
+
|
|
57
|
+
search_text = overlap + chunk
|
|
58
|
+
return true if search_text.include?(keyword)
|
|
59
|
+
|
|
60
|
+
overlap = if chunk.length >= keyword.length - 1
|
|
61
|
+
chunk[-(keyword.length - 1)..-1]
|
|
62
|
+
else
|
|
63
|
+
chunk
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
Archive_r.traverse('test.zip', formats: SAFE_FORMATS) do |entry|
|
|
70
|
+
puts "#{entry.path} (depth=#{entry.depth})"
|
|
71
|
+
next unless entry.file? && entry.path.end_with?('.txt')
|
|
72
|
+
puts " Found keyword" if search_in_entry(entry, 'search_keyword')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
Archive_r.traverse('protected.zip', passphrases: ['password123'], formats: SAFE_FORMATS) do |entry|
|
|
76
|
+
puts entry.path
|
|
77
|
+
end
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Thread Safety
|
|
81
|
+
|
|
82
|
+
The Ruby bindings follow the same thread-safety rules as the C++ core library:
|
|
83
|
+
|
|
84
|
+
**Safe:**
|
|
85
|
+
- Each thread creates and uses its own `Traverser` instance
|
|
86
|
+
- Concurrent traversal of different archives from different threads
|
|
87
|
+
|
|
88
|
+
**Unsafe:**
|
|
89
|
+
- Sharing a single `Traverser` instance across multiple threads
|
|
90
|
+
- Calling `Archive_r.register_stream_factory` or `Archive_r.on_fault` from multiple threads (these modify process-wide global state)
|
|
91
|
+
|
|
92
|
+
**Summary:** Create one `Traverser` per thread. Do not call global configuration methods (`register_stream_factory`, `on_fault`) concurrently.
|
|
93
|
+
|
|
94
|
+
## Environment Notes
|
|
95
|
+
|
|
96
|
+
- Set `ARCHIVE_R_CORE_ROOT` to the repository `build/` directory (or another archive_r build) if the gem needs to link against a pre-built static library instead of compiling the vendored core sources.
|
|
97
|
+
- When installing into a sandbox (e.g., CI), configure `GEM_HOME`/`GEM_PATH` before invoking `gem install` so that the extension picks up the correct core library.
|
|
98
|
+
|
|
99
|
+
## Further Help
|
|
100
|
+
|
|
101
|
+
- Issue tracker: <https://github.com/raizo-tcs/archive_r/issues>
|
|
102
|
+
- Releases / changelog: <https://github.com/raizo-tcs/archive_r/releases>
|
|
103
|
+
- For C++/Python usage and overall project information, see the repository root `README.md`.
|