ruby-xz 0.2.2 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 28c451853871a094353485f28db08d64c5a5effa
4
- data.tar.gz: 93ef5cba40e6a6330364206caf86dbcca6f95a7e
2
+ SHA256:
3
+ metadata.gz: c92bf36556e0297676ad48820dc2ba25243e897ac3d4401d4a8ec89d695e77e4
4
+ data.tar.gz: 77a1b46d9158f80b6ad28c68483a02835fcecb9ae5fa85f9dcda296630238ea2
5
5
  SHA512:
6
- metadata.gz: 75552a3ee976a8441ff397953bd608a8e9e6e5508b9c7cae73eb05278f509475c00fcea7ade557f758520c5b06b42711d96c162e9e5f2f5cc7ebed05e810a99f
7
- data.tar.gz: 11b58af7569d56fe0c7486945a9e5ef87bfb0bf9579d29a82c3f7f21f8aa9ae2d03e118927bdc295585e857b82d5d536ddb9012393646591dc4a58585462587e
6
+ metadata.gz: 7830929d9fea616430f554cb2a2ae2ef95095b8cf5d90c19e70e5bba697f301a059071c9da83a926ed7654506ccbe317009147c11d444822a47f78f3592dbfbc
7
+ data.tar.gz: fea094736b25633859b303a17402a59cd673c3fafa80614dd096f5053c92d09604a2e06fbf3a1d75e11e04a34b336a54ffe4bb8ae4231f4766417a49d4cec5c7
data/AUTHORS CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  All the people who worked on this project, in alphabetical order.
4
4
 
5
- * Lars Christensen (larsch)
6
- * Marvin Gülker (Quintus) <quintus ät quintilianus döt eu>
7
- * Christoph Plank (chrisistuff)
8
- * Nana Sakisaka (saki7)
5
+ * Marvin Gülker (github.com/Quintus) <m-guelker@phoenixmail.de>
6
+ * Alex Gittemeier (github.com/win93) <me@a.lexg.dev>
7
+ * Christoph Plank (github.com/chrisistuff)
data/HISTORY.rdoc CHANGED
@@ -1,15 +1,75 @@
1
1
  = Version history
2
2
 
3
- == 0.2.2 (unreleased)
3
+ == 1.0.2 (2021-11-28)
4
+ * Fix a deprecation warning and some other gemspec concerns (PR win93#6 by Alex Gittemeier)
4
5
 
5
- * *Add* XZ.disable_deprecation_notes
6
+ == 1.0.1 (2021-11-13)
7
+ * Fix a buffer overflow error in XZ::Stream (PR Quintus#17 by genail)
8
+ * Fix an issue with transcode_options that was introduced by Ruby 3 (PR win93#1 by Alex Gittemeier)
9
+ * Update project README, gemspec, and other metadata to reflect a change in
10
+ maintainership. All prior releases were released by Marvin Gülker.
11
+
12
+ == 1.0.0 (2018-05-20)
13
+
14
+ * *BreakingChange* The XZ module's methods now take any parameters
15
+ beyond the IO object as real Ruby keyword arguments rather than
16
+ a long argument list.
17
+ * *BreakingChange* XZ.decompress_stream now honours Ruby's
18
+ external and internal encoding concept instead of just
19
+ returning BINARY-tagged strings.
20
+ * *BreakingChange* Remove deprecated API on stream reader/writer
21
+ class and instead sync the API with Ruby's zlib library
22
+ (Ticket Quintus#12 by Quintus).
23
+ * *BreakingChange* StreamWriter.new and StreamReader.new do not accept
24
+ a block anymore. This is part of syncing with Ruby's zlib API.
25
+ * *BreakingChange* StreamReader.open and StreamWriter.open always
26
+ return the new instance, even if a block is given to the method
27
+ (previous behaviour was to return the return value of the block).
28
+ This is part of the syncing with Ruby's zlib API.
29
+ * *BreakingChange* StreamReader.new and StreamWriter.new as well as
30
+ the ::open variants take additional arguments as real Ruby keyword
31
+ arguments now instead of a long parameter list plus options hash.
32
+ This is different from Ruby's own zlib API as that one takes both
33
+ a long parameter list and a hash of additional options. ruby-xz
34
+ is meant to follow zlib's semantics mostly, but not as a drop-in
35
+ replacement, so this divergence from zlib's API is okay (also
36
+ given that it isn't possible to replicate all possible options
37
+ 1:1 anyway, since liblzma simply accepts different options as
38
+ libz). If you've never used these methods' optional arguments,
39
+ you should be fine.
40
+ * *BreakingChange* Stream#close now returns nil instead of the
41
+ number of bytes written. This syncs Stream#close with Ruby's
42
+ own IO#close, which also returns nil.
43
+ * *BreakingChange* Remove Stream#pos=, Stream#seek, Stream#stat. These
44
+ methods irritated the minitar gem, which doesn't expect them to
45
+ raise NotImplementedError, but directly to be missing if the object
46
+ does not support seeking.
47
+ * *BreakingChange* StreamReader and StreamWriter now honour Ruby's
48
+ encoding system instead of returning only BINARY-tagged strings.
49
+ * *Dependency* Remove dependency on ffi. ruby-xz now uses fiddle from
50
+ the stdlib instead.
51
+ * *Dependency* Remove dependency on io-like. ruby-xz now implements
52
+ all the IO mechanics itself. (Ticket Quintus#10 by Quintus)
53
+ * *Dependency* Bump required Ruby version to 2.3.0.
54
+ * *Fix* libzlma.dylib not being found on OS X (Ticket Quintus#15 by
55
+ s0nspark).
56
+
57
+ == 0.2.3 (2015-12-29)
58
+
59
+ * *Fix* documentation of XZ module (a :nodoc: was causing havoc
60
+ in the XZ module so it appeared to have no methods).
61
+ * No other changes this release.
62
+
63
+ == 0.2.2 (2015-12-27)
64
+
65
+ * *Add* XZ.disable_deprecation_notices
6
66
  * *Deprecate* use of XZ::StreamReader.open with an IO argument
7
67
  * *Deprecate* use of XZ::StreamReader.new with a filename argument
8
68
  * *Deprecate* use of XZ::StreamWriter.open with an IO argument
9
69
  * *Deprecate* use of XZ::StreamWriter.new with a filename argument
10
70
  * *Deprecate* nonautomatic IO close in XZ::StreamReader#close
11
71
  * *Deprecate* nonautomatic IO close in XZ::StreamWriter#close
12
- * *Fix* incompatibility with Resolv.getaddress() in Ruby 2.2 (Ticket #13
72
+ * *Fix* incompatibility with Resolv.getaddress() in Ruby 2.2 (Ticket Quintus#13
13
73
  by Ken Simon)
14
74
  * Goal of these deprecations is to sync the API with Ruby’s own
15
75
  Zlib::GzipWriter and Zlib::GzipReader mostly.
@@ -20,12 +80,12 @@
20
80
 
21
81
  == 0.2.1 (2014-02-08)
22
82
 
23
- * Build the gem properly on Ruby 2.0+ (PR #8 by Nana Sakisaka (saki7))
24
- * Release the GIL when interfacing with liblzma (PR #7 by Lars Christensen (larsch))
83
+ * Build the gem properly on Ruby 2.0+ (PR Quintus#8 by Nana Sakisaka (saki7))
84
+ * Release the GIL when interfacing with liblzma (PR Quintus#7 by Lars Christensen (larsch))
25
85
 
26
86
  == 0.2.0 (2013-06-23)
27
87
 
28
- * Fix #6 (errors on JRuby) by Ben Nagy
88
+ * Fix Quintus#6 (errors on JRuby) by Ben Nagy
29
89
  * <b>Remove 1.8 compatibility</b>
30
90
 
31
91
  == 0.1.0 (2013-02-17)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright © 2011-2018 Marvin Gülker et al.
2
+
3
+ See AUTHORS for the full list of contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a
6
+ copy of this software and associated documentation files (the ‘Software’),
7
+ to deal in the Software without restriction, including without limitation
8
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
+ and/or sell copies of the Software, and to permit persons to whom the Software
10
+ is 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
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,67 +1,66 @@
1
- ruby-xz
2
- =======
1
+ # ruby-xz
3
2
 
4
- **ruby-xz** is a basic binding to the famous [liblzma library][1],
5
- best known for the extreme compression-ratio it's native *XZ* format
6
- achieves. ruby-xz gives you the possibility of creating and extracting
7
- XZ archives on any platform where liblzma is installed. No compilation
8
- is needed, because ruby-xz is written ontop of
9
- [ffi][2].
3
+ **ruby-xz** is a basic binding to the famous [liblzma] library,
4
+ best known for the extreme compression-ratio it's native *XZ* format achieves.
5
+ ruby-xz gives you the possibility of creating and extracting XZ archives on any
6
+ platform where liblzma is installed.
7
+ No compilation is needed, because ruby-xz is written on top of Ruby's [fiddle]
8
+ library (part of the standard library).
9
+ ruby-xz does not have any dependencies other than Ruby itself.
10
10
 
11
- ruby-xz supports both "intuitive" (de)compression by providing methods to
12
- directly operate on strings and files, but also allows you to operate
13
- directly on IO streams (see the various methods of the XZ module). On top
14
- of that, ruby-xz offers an advanced interface that allows you to treat
15
- XZ-compressed data as IO streams, both for reading and for writing. See the
16
- XZ::StreamReader and XZ::StreamWriter classes for more information on this.
11
+ rubv-xz supports compression and decompression via methods that operate on
12
+ strings and files, and it also supports compression and decompression on IO
13
+ streams.
14
+ the XZ::StreamReader and XZ::StreamWriter offer advanced interfaces that allow
15
+ you to treat XZ-compressed data as IO streams, both for reading and for writing.
16
+ <!-- TODO: link to relevant parts of the source code and/or documentation -->
17
17
 
18
- Installation
19
- ------------
18
+ **Note**: Version 1.0.0 breaks the API quite heavily.
19
+ Refer to HISTORY.rdoc for details.
20
20
 
21
- Install it the way you install all your gems.
21
+ ## Installation
22
22
 
23
- ```
24
- $ gem install ruby-xz
23
+ Install with `gem` from your Ruby installation:
24
+
25
+ ```sh
26
+ gem install ruby-xz
25
27
  ```
26
28
 
27
- Alternatively, you can clone the repository and build the most recent
28
- code yourself:
29
+ Alternatively, add it to your Gemfile via:
29
30
 
30
- ```
31
- $ git clone git://github.com/Quintus/ruby-xz.git
32
- $ cd ruby-xz
33
- $ rake gem
34
- $ gem install pkg/ruby-xz-*.gem
31
+ ```sh
32
+ bundle add ruby-xz
35
33
  ```
36
34
 
37
- Usage
38
- -----
35
+ If you want to be on the bleeding edge, you can clone the repository and build
36
+ the most recent code yourself:
39
37
 
40
- The documentation of the XZ module is well and you should be able to find
41
- everything you need to use ruby-xz. As said, it's not big, but powerful:
42
- You can create and extract whole archive files, compress or decompress
43
- streams of data or just plain strings.
38
+ ```sh
39
+ git clone https://github.com/win93/ruby-xz.git
40
+ cd ruby-xz
41
+ rake gem
42
+ gem install pkg/ruby-xz-*.gem
43
+ ```
44
44
 
45
- You can read the documentation on your local gemserver, or browse it [online][3].
45
+ ## Usage
46
46
 
47
- ### First step ###
47
+ You should be able to find everything you need to use ruby-xz in the
48
+ documentation.
49
+ It's small but powerful: You can create and extract whole archive files,
50
+ compress or decompress whole files, strings, or streams of data.
48
51
 
49
- You have to require ruby-xz. Note the file you have to require is named
50
- "xz.rb", so do
52
+ You can read the documentation on your local gemserver, or browse it [online][rubydoc].
53
+ <!-- TODO how do I read the docs on my local gemserver? -->
51
54
 
52
- ``` ruby
53
- require "xz"
54
- ```
55
-
56
- to get it.
57
-
58
- ### Examples ###
55
+ ### Examples
59
56
 
60
57
  ``` ruby
61
- # Compress a TAR archive
62
- XZ.compress_file("myfile.tar", "myfile.tar.xz")
58
+ require 'xz'
59
+
60
+ # Compress a file
61
+ XZ.compress_file("myfile.txt", "myfile.txt.xz")
63
62
  # Decompress it
64
- XZ.decompress_file("myfile.tar.xz", "myfile.tar")
63
+ XZ.decompress_file("myfile.txt.xz", "myfile.txt")
65
64
 
66
65
  # Compress everything you get from a socket (note that there HAS to be a EOF
67
66
  # sometime, otherwise this will run infinitely)
@@ -73,45 +72,68 @@ comp = XZ.compress("Mydata")
73
72
  data = XZ.decompress(comp)
74
73
  ```
75
74
 
76
- Have a look at the XZ module's documentation for an in-depth description of
77
- what is possible.
75
+ Have a look at the XZ module's documentation for an in-depth description of what
76
+ is possible.
77
+ <!-- TODO link to such documentation -->
78
+
79
+ ### Usage with the minitar gem
80
+
81
+ ruby-xz can be used together with the [minitar] library (formerly
82
+ “archive-tar-minitar”) to create XZ-compressed tarballs.
83
+ This works by employing the IO-like classes XZ::StreamReader and
84
+ XZ::StreamWriter analogous to how one would use Ruby's “zlib” library together
85
+ with “minitar”:
86
+
87
+ ``` ruby
88
+ require "xz"
89
+ require "minitar"
90
+
91
+ # Create an XZ-compressed tarball
92
+ XZ::StreamWriter.open("tarball.tar.xz") do |txz|
93
+ Minitar.pack("path/to/directory", txz)
94
+ end
95
+
96
+ # Unpack it again
97
+ XZ::StreamReader.open("tarball.tar.xz") do |txz|
98
+ Minitar.unpack(txz, "path/to/target/directory")
99
+ end
100
+ ```
101
+
102
+ ## Development
103
+
104
+ After checking out the repo, run `bundle install` to install dependencies.
105
+
106
+ To install this gem onto your local machine, run `rake install`.
78
107
 
79
- Links
80
- -----
108
+ To release a new version:
81
109
 
82
- * Code repository: https://github.com/Quintus/ruby-xz
83
- * Issue tracker: https://github.com/Quintus/ruby-xz/issues
84
- * Online documentation: http://quintus.github.io/ruby-xz
110
+ - Switch to the `development` branch.
111
+ - Bump `lib/xz/version.rb`, run `bundle install`, then commit the result.
112
+ - Switch to the `stable` branch.
113
+ - Run `git merge --no-ff development`
114
+ - Run `rake release`, which will create/push a git tag and publish the `.gem`
115
+ file to [rubygems.org].
85
116
 
86
- License
87
- -------
117
+ [rubygems.org]: https://rubygems.org
88
118
 
89
- (The MIT License)
119
+ ## Links
90
120
 
91
- Basic liblzma-bindings for Ruby.
121
+ * Online documentation: <https://rubydoc.info/gems/ruby-xz>
122
+ * Code repository: <https://github.com/win93/ruby-xz>
123
+ * Issue tracker: <https://github.com/win93/ruby-xz/issues>
92
124
 
93
- Copyright © 2011-2015 Marvin Gülker et al.
125
+ ## License
94
126
 
95
- See AUTHORS for the full list of contributors.
127
+ MIT license; see LICENSE for the full license text.
96
128
 
97
- Permission is hereby granted, free of charge, to any person obtaining a
98
- copy of this software and associated documentation files (the ‘Software’),
99
- to deal in the Software without restriction, including without limitation
100
- the rights to use, copy, modify, merge, publish, distribute, sublicense,
101
- and/or sell copies of the Software, and to permit persons to whom the Software
102
- is furnished to do so, subject to the following conditions:
129
+ ## Acknowledgements
103
130
 
104
- The above copyright notice and this permission notice shall be included in all
105
- copies or substantial portions of the Software.
131
+ On November 2021, I volunteered to take over maintenance of this project, which
132
+ was forked from <https://github.com/Quintus/ruby-xz>.
133
+ @Quintus maintained this project until 1.0.0, see HISTORY.rdoc for more details.
106
134
 
107
- THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
108
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
109
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
110
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
111
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
112
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
113
- THE SOFTWARE.
114
135
 
115
- [1]: http://tukaani.org/xz/
116
- [2]: https://github.com/ffi/ffi
117
- [3]: http://quintus.github.io/ruby-xz
136
+ [fiddle]: https://github.com/ruby/fiddle
137
+ [liblzma]: https://tukaani.org/xz/
138
+ [rubydoc]: https://www.rubydoc.info/gems/ruby-xz
139
+ [minitar]: https://github.com/halostatue/minitar
@@ -0,0 +1,91 @@
1
+ # -*- coding: utf-8 -*-
2
+ #--
3
+ # Basic liblzma-bindings for Ruby.
4
+ #
5
+ # Copyright © 2011-2018 Marvin Gülker et al.
6
+ #
7
+ # See AUTHORS for the full list of contributors.
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining a
10
+ # copy of this software and associated documentation files (the ‘Software’),
11
+ # to deal in the Software without restriction, including without limitation
12
+ # the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
+ # and/or sell copies of the Software, and to permit persons to whom the Software
14
+ # is furnished to do so, subject to the following conditions:
15
+ #
16
+ # The above copyright notice and this permission notice shall be included in all
17
+ # copies or substantial portions of the Software.
18
+ #
19
+ # THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ # THE SOFTWARE.
26
+ #++
27
+
28
+ module XZ
29
+
30
+ # This is an internal API not meant for users of ruby-xz.
31
+ # This mixin modules defines some helper functions on top
32
+ # of Fiddle's functionality.
33
+ module FiddleHelper # :nodoc:
34
+
35
+ # Define constants that have numeric constants assigned as if
36
+ # it was a C enum definition. You can specificy values explicitely
37
+ # or rely on the implicit incrementation; the first implicit value
38
+ # is zero.
39
+ #
40
+ # Example:
41
+ #
42
+ # enum :FOO, :BAR, 5, :BAZ
43
+ #
44
+ # This defines a constant FOO with value 0, BAR with value 5, BAZ
45
+ # with value 6.
46
+ def enum(*args)
47
+ @next_enum_val = 0 # First value of an enum is 0 in C
48
+
49
+ args.each_cons(2) do |val1, val2|
50
+ next if val1.respond_to?(:to_int)
51
+
52
+ if val2.respond_to?(:to_int)
53
+ const_set(val1, val2.to_int)
54
+ @next_enum_val = val2.to_int + 1
55
+ else
56
+ const_set(val1, @next_enum_val)
57
+ @next_enum_val += 1
58
+ end
59
+ end
60
+
61
+ # Cater for the last element in case it is not an explicit
62
+ # value that has already been assigned above.
63
+ unless args.last.respond_to?(:to_int)
64
+ const_set(args.last, @next_enum_val)
65
+ end
66
+
67
+ @next_enum_val = 0
68
+ nil
69
+ end
70
+
71
+ # Try loading any of the given names as a shared
72
+ # object. Raises Fiddle::DLError if none can
73
+ # be opened.
74
+ def dlloadanyof(*names)
75
+ names.each do |name|
76
+ begin
77
+ dlload(name)
78
+ rescue Fiddle::DLError
79
+ # Continue with next one
80
+ else
81
+ # Success
82
+ return name
83
+ end
84
+ end
85
+
86
+ raise Fiddle::DLError, "Failed to open any of these shared object files: #{names.join(', ')}"
87
+ end
88
+
89
+ end
90
+
91
+ end