archive_r_ruby 0.1.21 → 0.1.22

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -21
  3. data/NOTICE +116 -116
  4. data/README.md +106 -106
  5. data/VERSION +1 -1
  6. data/ext/archive_r/archive_r_ext.cc +1098 -1098
  7. data/ext/archive_r/extconf.rb +125 -125
  8. data/ext/archive_r/vendor/archive_r/LICENSE +21 -21
  9. data/ext/archive_r/vendor/archive_r/NOTICE +116 -116
  10. data/ext/archive_r/vendor/archive_r/include/archive_r/data_stream.h +42 -42
  11. data/ext/archive_r/vendor/archive_r/include/archive_r/entry.h +180 -180
  12. data/ext/archive_r/vendor/archive_r/include/archive_r/entry_fault.h +34 -34
  13. data/ext/archive_r/vendor/archive_r/include/archive_r/entry_metadata.h +56 -56
  14. data/ext/archive_r/vendor/archive_r/include/archive_r/multi_volume_stream_base.h +46 -46
  15. data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy.h +92 -92
  16. data/ext/archive_r/vendor/archive_r/include/archive_r/path_hierarchy_utils.h +36 -36
  17. data/ext/archive_r/vendor/archive_r/include/archive_r/platform_compat.h +34 -34
  18. data/ext/archive_r/vendor/archive_r/include/archive_r/traverser.h +156 -156
  19. data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.cc +300 -300
  20. data/ext/archive_r/vendor/archive_r/src/archive_stack_cursor.h +110 -110
  21. data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.cc +161 -161
  22. data/ext/archive_r/vendor/archive_r/src/archive_stack_orchestrator.h +53 -53
  23. data/ext/archive_r/vendor/archive_r/src/archive_type.cc +545 -545
  24. data/ext/archive_r/vendor/archive_r/src/archive_type.h +77 -77
  25. data/ext/archive_r/vendor/archive_r/src/data_stream.cc +35 -35
  26. data/ext/archive_r/vendor/archive_r/src/entry.cc +238 -238
  27. data/ext/archive_r/vendor/archive_r/src/entry_fault.cc +26 -26
  28. data/ext/archive_r/vendor/archive_r/src/entry_fault_error.cc +54 -54
  29. data/ext/archive_r/vendor/archive_r/src/entry_fault_error.h +32 -32
  30. data/ext/archive_r/vendor/archive_r/src/entry_impl.h +56 -56
  31. data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.cc +76 -76
  32. data/ext/archive_r/vendor/archive_r/src/multi_volume_manager.h +39 -39
  33. data/ext/archive_r/vendor/archive_r/src/multi_volume_stream_base.cc +208 -208
  34. data/ext/archive_r/vendor/archive_r/src/path_hierarchy.cc +127 -127
  35. data/ext/archive_r/vendor/archive_r/src/path_hierarchy_utils.cc +251 -251
  36. data/ext/archive_r/vendor/archive_r/src/simple_profiler.h +109 -109
  37. data/ext/archive_r/vendor/archive_r/src/system_file_stream.cc +294 -294
  38. data/ext/archive_r/vendor/archive_r/src/system_file_stream.h +46 -46
  39. data/ext/archive_r/vendor/archive_r/src/traverser.cc +295 -295
  40. data/lib/archive_r.rb +120 -120
  41. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3a9201c0294653eaf8ee15988ef7a7a9015b0a404dc1a8d600efa5461ade522
4
- data.tar.gz: '008d6102ea80a64c3aa79d5343552789b026786f09fdc347fa05d3060d0fc42d'
3
+ metadata.gz: bafb1f948efc655aa395aa0ee4b2dc0d6ab950185c9e41b9e8fd8136e952d74d
4
+ data.tar.gz: cbcd183a938ba16f17117eeafb78c0ca4492f60b23b4a12761b5be47c3eb6bb6
5
5
  SHA512:
6
- metadata.gz: cda14a8907238f74b896ff1a06edcad6cda8d7e5f6079236d3a54db32ba7380885d9a928b7e207c52b6187eb3ce3941b90c6dd42fcbe7826bb9ff8e14bbd9b2c
7
- data.tar.gz: e4e865062b7dfcab1a2662fd31e1048143af1b2726be3732f917160322ccefefab2adfc688ae2254834aee5cd75f98eefe11a02c8b4c5163daecb9fbd57879b0
6
+ metadata.gz: 1c3727a9d1a66336b5d434cc903ba79ff21214980583bd39ce72e84f558660ef6376e3b650f5df84f404d99386553d99627e57ad56580a19cf66d679b251ec7c
7
+ data.tar.gz: e02a6f140f3315c7570feb64ce5f3907691cf0db8318c285ccee9432607ed7f6cd5302c631363122155a17fa67ba004000f806c982c04f59ac3414ff844da797
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 archive_r Team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 archive_r Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/NOTICE CHANGED
@@ -1,116 +1,116 @@
1
- archive_r Notices
2
-
3
- This file contains third-party notices and licensing information for bundled or
4
- linked components. It does not replace the project license.
5
-
6
- For full license texts, see the files under the LICENSES/ directory in this
7
- repository. Python wheels include these texts under the *.dist-info/licenses/
8
- directory.
9
-
10
- ----------------------------------------
11
- Third-Party Notices
12
- ----------------------------------------
13
-
14
- This distribution (notably the Python wheels) bundles and/or dynamically links
15
- against the following third-party components. Their respective license terms
16
- apply in addition to the MIT License.
17
-
18
- 1. libarchive
19
- - Purpose: core archive reading and writing functionality for the C++
20
- library and language bindings.
21
- - Version (manylinux wheels): 3.7.5
22
- - License: New BSD License (https://www.libarchive.org/)
23
- - Full license text and notices: LICENSES/libarchive-COPYING
24
-
25
- 2. pybind11
26
- - Purpose: header-only binding generator for the Python extension module.
27
- - License: BSD-style License (https://github.com/pybind/pybind11)
28
- - Notes: used at build time; not redistributed as a runtime library.
29
-
30
- The following components are redistributed only because libarchive (bundled in
31
- some artifacts such as Python wheels) depends on them at runtime:
32
-
33
- 3. zlib
34
- - Purpose: libarchive dependency providing DEFLATE compression.
35
- - License: zlib License (https://zlib.net/zlib_license.html)
36
- - Notes: typically provided by the platform runtime (not bundled in wheels).
37
-
38
- 4. bzip2
39
- - Purpose: libarchive dependency providing bzip2 compression support; distributed with archive_r artifacts.
40
- - Version (manylinux wheels): 1.0.8
41
- - License: BSD-style license (https://sourceware.org/bzip2/)
42
- - Full license text and notices: LICENSES/bzip2-LICENSE
43
-
44
- 5. liblzma (XZ Utils)
45
- - Purpose: libarchive dependency providing LZMA/XZ compression; included with archive_r packages.
46
- - Version (manylinux wheels): 5.6.2
47
- - License: BSD Zero Clause License (0BSD) for liblzma (https://tukaani.org/xz/)
48
- - Full license texts and notices: LICENSES/xz-COPYING, LICENSES/xz-COPYING.0BSD
49
-
50
- 6. libxml2
51
- - Purpose: libarchive dependency used for archive formats such as xar; distributed alongside archive_r.
52
- - Version (manylinux wheels): 2.13.4
53
- - License: MIT-style License (http://xmlsoft.org/)
54
- - Full license text and notices: LICENSES/libxml2-Copyright
55
-
56
- 7. zstd
57
- - Purpose: libarchive dependency providing Zstandard compression; shipped within archive_r binaries.
58
- - Version (manylinux wheels): 1.5.5
59
- - License: BSD License (https://github.com/facebook/zstd)
60
- - Full license text and notices: LICENSES/zstd-LICENSE
61
-
62
- 8. Nettle
63
- - Purpose: libarchive dependency providing cryptographic support (macOS/Linux); bundled with archive_r binaries.
64
- - Version (manylinux wheels): 3.9.1
65
- - License: GNU LGPLv3+ or GNU GPLv2+ (https://www.lysator.liu.se/~nisse/nettle/)
66
- - Full license texts and notices: LICENSES/nettle-COPYING.LESSERv3, LICENSES/nettle-COPYINGv2
67
-
68
- 9. mini-gmp
69
- - Purpose: Nettle dependency for arithmetic operations (macOS/Linux); bundled with archive_r binaries.
70
- - License: GNU LGPLv3+ or GNU GPLv2+ (https://gmplib.org/)
71
-
72
- 10. OpenSSL 3
73
- - Purpose: libarchive dependency providing cryptographic support (Windows); bundled with archive_r Windows wheels.
74
- - License: Apache License 2.0 with OpenSSL exception (https://www.openssl.org/source/license.html)
75
-
76
- 11. lz4
77
- - Purpose: libarchive dependency providing LZ4 compression; shipped with archive_r artifacts when required.
78
- - Version (manylinux wheels): 1.10.0
79
- - License: BSD 2-Clause (https://github.com/lz4/lz4)
80
- - Full license text and notices: LICENSES/lz4-LICENSE
81
-
82
- 12. libb2 (BLAKE2)
83
- - Purpose: libarchive dependency providing BLAKE2 hashing; bundled when archive formats require it.
84
- - Version (manylinux wheels): 0.98.1
85
- - License: CC0 1.0 Universal (https://github.com/BLAKE2/libb2)
86
- - Full license text and notices: LICENSES/libb2-COPYING
87
-
88
- 13. libattr
89
- - Purpose: libarchive dependency providing extended attribute support on POSIX platforms; included in POSIX builds only.
90
- - Version (manylinux wheels): 2.5.2
91
- - License: LGPL-2.1-or-later for the library (https://savannah.nongnu.org/projects/attr)
92
- - Full license text and notices: LICENSES/attr-COPYING.LGPL
93
-
94
- 14. libacl
95
- - Purpose: libarchive dependency providing POSIX ACL support; included in POSIX builds only.
96
- - Version (manylinux wheels): 2.3.2
97
- - License: LGPL-2.1-or-later for the library (https://savannah.nongnu.org/projects/acl)
98
- - Full license text and notices: LICENSES/acl-COPYING.LGPL
99
-
100
- 15. LLVM OpenMP runtime (libomp)
101
- - Purpose: runtime dependency that can be bundled into Linux wheels depending on toolchain and binary dependencies.
102
- - License: Apache License 2.0 with LLVM Exceptions (https://llvm.org/)
103
- - Full license text and notices: LICENSES/libomp-LICENSE.TXT
104
-
105
- ----------------------------------------
106
- Source Availability
107
- ----------------------------------------
108
-
109
- For the components redistributed in binary form, the corresponding source code
110
- can be obtained from the upstream project release pages listed above.
111
-
112
- For the manylinux wheel build, exact dependency versions are recorded in:
113
- - bindings/python/tools/build-deps-manylinux.sh
114
-
115
- Full license texts copied from upstream release archives are stored under:
116
- - LICENSES/
1
+ archive_r Notices
2
+
3
+ This file contains third-party notices and licensing information for bundled or
4
+ linked components. It does not replace the project license.
5
+
6
+ For full license texts, see the files under the LICENSES/ directory in this
7
+ repository. Python wheels include these texts under the *.dist-info/licenses/
8
+ directory.
9
+
10
+ ----------------------------------------
11
+ Third-Party Notices
12
+ ----------------------------------------
13
+
14
+ This distribution (notably the Python wheels) bundles and/or dynamically links
15
+ against the following third-party components. Their respective license terms
16
+ apply in addition to the MIT License.
17
+
18
+ 1. libarchive
19
+ - Purpose: core archive reading and writing functionality for the C++
20
+ library and language bindings.
21
+ - Version (manylinux wheels): 3.7.5
22
+ - License: New BSD License (https://www.libarchive.org/)
23
+ - Full license text and notices: LICENSES/libarchive-COPYING
24
+
25
+ 2. pybind11
26
+ - Purpose: header-only binding generator for the Python extension module.
27
+ - License: BSD-style License (https://github.com/pybind/pybind11)
28
+ - Notes: used at build time; not redistributed as a runtime library.
29
+
30
+ The following components are redistributed only because libarchive (bundled in
31
+ some artifacts such as Python wheels) depends on them at runtime:
32
+
33
+ 3. zlib
34
+ - Purpose: libarchive dependency providing DEFLATE compression.
35
+ - License: zlib License (https://zlib.net/zlib_license.html)
36
+ - Notes: typically provided by the platform runtime (not bundled in wheels).
37
+
38
+ 4. bzip2
39
+ - Purpose: libarchive dependency providing bzip2 compression support; distributed with archive_r artifacts.
40
+ - Version (manylinux wheels): 1.0.8
41
+ - License: BSD-style license (https://sourceware.org/bzip2/)
42
+ - Full license text and notices: LICENSES/bzip2-LICENSE
43
+
44
+ 5. liblzma (XZ Utils)
45
+ - Purpose: libarchive dependency providing LZMA/XZ compression; included with archive_r packages.
46
+ - Version (manylinux wheels): 5.6.2
47
+ - License: BSD Zero Clause License (0BSD) for liblzma (https://tukaani.org/xz/)
48
+ - Full license texts and notices: LICENSES/xz-COPYING, LICENSES/xz-COPYING.0BSD
49
+
50
+ 6. libxml2
51
+ - Purpose: libarchive dependency used for archive formats such as xar; distributed alongside archive_r.
52
+ - Version (manylinux wheels): 2.13.4
53
+ - License: MIT-style License (http://xmlsoft.org/)
54
+ - Full license text and notices: LICENSES/libxml2-Copyright
55
+
56
+ 7. zstd
57
+ - Purpose: libarchive dependency providing Zstandard compression; shipped within archive_r binaries.
58
+ - Version (manylinux wheels): 1.5.5
59
+ - License: BSD License (https://github.com/facebook/zstd)
60
+ - Full license text and notices: LICENSES/zstd-LICENSE
61
+
62
+ 8. Nettle
63
+ - Purpose: libarchive dependency providing cryptographic support (macOS/Linux); bundled with archive_r binaries.
64
+ - Version (manylinux wheels): 3.9.1
65
+ - License: GNU LGPLv3+ or GNU GPLv2+ (https://www.lysator.liu.se/~nisse/nettle/)
66
+ - Full license texts and notices: LICENSES/nettle-COPYING.LESSERv3, LICENSES/nettle-COPYINGv2
67
+
68
+ 9. mini-gmp
69
+ - Purpose: Nettle dependency for arithmetic operations (macOS/Linux); bundled with archive_r binaries.
70
+ - License: GNU LGPLv3+ or GNU GPLv2+ (https://gmplib.org/)
71
+
72
+ 10. OpenSSL 3
73
+ - Purpose: libarchive dependency providing cryptographic support (Windows); bundled with archive_r Windows wheels.
74
+ - License: Apache License 2.0 with OpenSSL exception (https://www.openssl.org/source/license.html)
75
+
76
+ 11. lz4
77
+ - Purpose: libarchive dependency providing LZ4 compression; shipped with archive_r artifacts when required.
78
+ - Version (manylinux wheels): 1.10.0
79
+ - License: BSD 2-Clause (https://github.com/lz4/lz4)
80
+ - Full license text and notices: LICENSES/lz4-LICENSE
81
+
82
+ 12. libb2 (BLAKE2)
83
+ - Purpose: libarchive dependency providing BLAKE2 hashing; bundled when archive formats require it.
84
+ - Version (manylinux wheels): 0.98.1
85
+ - License: CC0 1.0 Universal (https://github.com/BLAKE2/libb2)
86
+ - Full license text and notices: LICENSES/libb2-COPYING
87
+
88
+ 13. libattr
89
+ - Purpose: libarchive dependency providing extended attribute support on POSIX platforms; included in POSIX builds only.
90
+ - Version (manylinux wheels): 2.5.2
91
+ - License: LGPL-2.1-or-later for the library (https://savannah.nongnu.org/projects/attr)
92
+ - Full license text and notices: LICENSES/attr-COPYING.LGPL
93
+
94
+ 14. libacl
95
+ - Purpose: libarchive dependency providing POSIX ACL support; included in POSIX builds only.
96
+ - Version (manylinux wheels): 2.3.2
97
+ - License: LGPL-2.1-or-later for the library (https://savannah.nongnu.org/projects/acl)
98
+ - Full license text and notices: LICENSES/acl-COPYING.LGPL
99
+
100
+ 15. LLVM OpenMP runtime (libomp)
101
+ - Purpose: runtime dependency that can be bundled into Linux wheels depending on toolchain and binary dependencies.
102
+ - License: Apache License 2.0 with LLVM Exceptions (https://llvm.org/)
103
+ - Full license text and notices: LICENSES/libomp-LICENSE.TXT
104
+
105
+ ----------------------------------------
106
+ Source Availability
107
+ ----------------------------------------
108
+
109
+ For the components redistributed in binary form, the corresponding source code
110
+ can be obtained from the upstream project release pages listed above.
111
+
112
+ For the manylinux wheel build, exact dependency versions are recorded in:
113
+ - bindings/python/tools/build-deps-manylinux.sh
114
+
115
+ Full license texts copied from upstream release archives are stored under:
116
+ - LICENSES/
data/README.md CHANGED
@@ -1,106 +1,106 @@
1
- # archive_r Ruby Binding
2
-
3
- Ruby bindings for archive_r, a libarchive-based library for processing many archive formats.
4
- It streams entry data directly from the source to recursively read nested archives without extracting to temporary files or loading large in-memory buffers.
5
-
6
- 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.
7
-
8
- ## Requirements
9
-
10
- - Ruby 3.2 (same toolchain as the development environment)
11
- - libarchive 3.x (shared library and headers)
12
- - Build tools: `rake`, `minitest`, a C++17 compiler, and `make`
13
-
14
- ## Installing the Gem
15
-
16
- ### Recommended: build.sh workflow
17
-
18
- 1. From the repository root run:
19
- ```bash
20
- ./build.sh --with-ruby
21
- ```
22
- 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`.
23
- 2. Install the freshly built gem into your desired GEM_HOME:
24
- ```bash
25
- gem install --local build/bindings/ruby/archive_r-*.gem
26
- ```
27
- 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.
28
-
29
- ### Working inside bindings/ruby
30
-
31
- If you prefer to build from the `bindings/ruby` directory:
32
-
33
- ```bash
34
- cd bindings/ruby
35
- bundle install
36
- bundle exec rake compile # builds ext/archive_r
37
- bundle exec rake test # runs test/test_traverser.rb
38
- bundle exec rake build # creates archive_r-<version>.gem locally
39
- ```
40
-
41
- The `rake test` task compiles the extension, installs it into `lib/`, and executes the Minitest suite.
42
-
43
- ## Running the repository test suite
44
-
45
- From the repository root run `./bindings/ruby/run_binding_tests.sh`. The script prepares a clean GEM_HOME (`build/ruby_gem_home`), installs the gem produced in `build/bindings/ruby`, runs `bindings/ruby/test/test_traverser.rb`, and saves the install log to `build/logs/ruby_gem_install.log`. CI invokes this script after the core tests.
46
-
47
- ## Usage Example
48
-
49
- ```ruby
50
- require 'archive_r'
51
-
52
- SAFE_FORMATS = Archive_r::STANDARD_FORMATS
53
-
54
- def search_in_entry(entry, keyword)
55
- overlap = ''
56
- loop do
57
- chunk = entry.read(8192)
58
- break if chunk.nil? || chunk.empty?
59
-
60
- search_text = overlap + chunk
61
- return true if search_text.include?(keyword)
62
-
63
- overlap = if chunk.length >= keyword.length - 1
64
- chunk[-(keyword.length - 1)..-1]
65
- else
66
- chunk
67
- end
68
- end
69
- false
70
- end
71
-
72
- Archive_r.traverse('test.zip', formats: SAFE_FORMATS) do |entry|
73
- puts "#{entry.path} (depth=#{entry.depth})"
74
- next unless entry.file? && entry.path.end_with?('.txt')
75
- puts " Found keyword" if search_in_entry(entry, 'search_keyword')
76
- end
77
-
78
- Archive_r.traverse('protected.zip', passphrases: ['password123'], formats: SAFE_FORMATS) do |entry|
79
- puts entry.path
80
- end
81
- ```
82
-
83
- ## Thread Safety
84
-
85
- The Ruby bindings follow the same thread-safety rules as the C++ core library:
86
-
87
- **Safe:**
88
- - Each thread creates and uses its own `Traverser` instance
89
- - Concurrent traversal of different archives from different threads
90
-
91
- **Unsafe:**
92
- - Sharing a single `Traverser` instance across multiple threads
93
- - Calling `Archive_r.register_stream_factory` or `Archive_r.on_fault` from multiple threads (these modify process-wide global state)
94
-
95
- **Summary:** Create one `Traverser` per thread. Do not call global configuration methods (`register_stream_factory`, `on_fault`) concurrently.
96
-
97
- ## Environment Notes
98
-
99
- - 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.
100
- - 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.
101
-
102
- ## Further Help
103
-
104
- - Issue tracker: <https://github.com/raizo-tcs/archive_r/issues>
105
- - Releases / changelog: <https://github.com/raizo-tcs/archive_r/releases>
106
- - For C++/Python usage and overall project information, see the repository root `README.md`.
1
+ # archive_r Ruby Binding
2
+
3
+ Ruby bindings for archive_r, a libarchive-based library for processing many archive formats.
4
+ It streams entry data directly from the source to recursively read nested archives without extracting to temporary files or loading large in-memory buffers.
5
+
6
+ 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.
7
+
8
+ ## Requirements
9
+
10
+ - Ruby 3.2 (same toolchain as the development environment)
11
+ - libarchive 3.x (shared library and headers)
12
+ - Build tools: `rake`, `minitest`, a C++17 compiler, and `make`
13
+
14
+ ## Installing the Gem
15
+
16
+ ### Recommended: build.sh workflow
17
+
18
+ 1. From the repository root run:
19
+ ```bash
20
+ ./build.sh --with-ruby
21
+ ```
22
+ 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`.
23
+ 2. Install the freshly built gem into your desired GEM_HOME:
24
+ ```bash
25
+ gem install --local build/bindings/ruby/archive_r-*.gem
26
+ ```
27
+ 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.
28
+
29
+ ### Working inside bindings/ruby
30
+
31
+ If you prefer to build from the `bindings/ruby` directory:
32
+
33
+ ```bash
34
+ cd bindings/ruby
35
+ bundle install
36
+ bundle exec rake compile # builds ext/archive_r
37
+ bundle exec rake test # runs test/test_traverser.rb
38
+ bundle exec rake build # creates archive_r-<version>.gem locally
39
+ ```
40
+
41
+ The `rake test` task compiles the extension, installs it into `lib/`, and executes the Minitest suite.
42
+
43
+ ## Running the repository test suite
44
+
45
+ From the repository root run `./bindings/ruby/run_binding_tests.sh`. The script prepares a clean GEM_HOME (`build/ruby_gem_home`), installs the gem produced in `build/bindings/ruby`, runs `bindings/ruby/test/test_traverser.rb`, and saves the install log to `build/logs/ruby_gem_install.log`. CI invokes this script after the core tests.
46
+
47
+ ## Usage Example
48
+
49
+ ```ruby
50
+ require 'archive_r'
51
+
52
+ SAFE_FORMATS = Archive_r::STANDARD_FORMATS
53
+
54
+ def search_in_entry(entry, keyword)
55
+ overlap = ''
56
+ loop do
57
+ chunk = entry.read(8192)
58
+ break if chunk.nil? || chunk.empty?
59
+
60
+ search_text = overlap + chunk
61
+ return true if search_text.include?(keyword)
62
+
63
+ overlap = if chunk.length >= keyword.length - 1
64
+ chunk[-(keyword.length - 1)..-1]
65
+ else
66
+ chunk
67
+ end
68
+ end
69
+ false
70
+ end
71
+
72
+ Archive_r.traverse('test.zip', formats: SAFE_FORMATS) do |entry|
73
+ puts "#{entry.path} (depth=#{entry.depth})"
74
+ next unless entry.file? && entry.path.end_with?('.txt')
75
+ puts " Found keyword" if search_in_entry(entry, 'search_keyword')
76
+ end
77
+
78
+ Archive_r.traverse('protected.zip', passphrases: ['password123'], formats: SAFE_FORMATS) do |entry|
79
+ puts entry.path
80
+ end
81
+ ```
82
+
83
+ ## Thread Safety
84
+
85
+ The Ruby bindings follow the same thread-safety rules as the C++ core library:
86
+
87
+ **Safe:**
88
+ - Each thread creates and uses its own `Traverser` instance
89
+ - Concurrent traversal of different archives from different threads
90
+
91
+ **Unsafe:**
92
+ - Sharing a single `Traverser` instance across multiple threads
93
+ - Calling `Archive_r.register_stream_factory` or `Archive_r.on_fault` from multiple threads (these modify process-wide global state)
94
+
95
+ **Summary:** Create one `Traverser` per thread. Do not call global configuration methods (`register_stream_factory`, `on_fault`) concurrently.
96
+
97
+ ## Environment Notes
98
+
99
+ - 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.
100
+ - 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.
101
+
102
+ ## Further Help
103
+
104
+ - Issue tracker: <https://github.com/raizo-tcs/archive_r/issues>
105
+ - Releases / changelog: <https://github.com/raizo-tcs/archive_r/releases>
106
+ - For C++/Python usage and overall project information, see the repository root `README.md`.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.21
1
+ 0.1.22