ruby-xz 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 820fac81115af7c562998d1c80cce241d045c210
4
- data.tar.gz: 31823023e5de3c452f8d0b82b643732ff0294658
2
+ SHA256:
3
+ metadata.gz: efe7c4ed9a4c30ce23e8328060b458e36a29b7b31d17528a4acb842c461a6b11
4
+ data.tar.gz: f8c55ee6bf356b87d8511ff45bfcc481b17bc8475477a7dd9df56b69c7185a6b
5
5
  SHA512:
6
- metadata.gz: 35aa3ebe08c3e82b4cc81339c23af1d78073ffb4d174f56079808f482ae60061c329aeed2fcbec56eb34e81102ed30bb3f32240f85436d5b99142df48e925f29
7
- data.tar.gz: a83b6fc3ca7b397af5695877fde63ff8642fa60a689d36b505cbf08717ea2b4c22b182e484bd55aa66a49f90fb132da17e7cd7a2caf1250175590127fb7f0565
6
+ metadata.gz: b61b2e26837ce216cdc03286e3c52d4fd38a01f95d158556d0ed9ed4f347d289e575f6bdd5da236265ba4a37ee9c779f98db37f663edce2308a874e6cedd9a16
7
+ data.tar.gz: a93055f9f309a7adf464b392cd9e5ac2bce97ae9f97bf37fec16d5f537ac2cd6d590d88a9ab6e6786be586eed841137bba29946de90bbf601124c695556af003
data/AUTHORS CHANGED
@@ -2,5 +2,6 @@
2
2
 
3
3
  All the people who worked on this project, in alphabetical order.
4
4
 
5
- * Marvin Gülker (Quintus) <m-guelker@phoenixmail.de>
6
- * Christoph Plank (chrisistuff)
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,5 +1,20 @@
1
1
  = Version history
2
2
 
3
+ == 1.0.3 (2022-03-28)
4
+ * *Fix* a number of memory leaks by freeing allocated liblzma data structures
5
+ (Issue Quintus#20 reported by xTRiM, PR win93#7 by Alex Gittemeier)
6
+
7
+ == 1.0.2 (2021-11-28)
8
+ * *Fix* a deprecation warning and some other gemspec concerns
9
+ (Issue win93#5, PR win93#6 by Alex Gittemeier)
10
+
11
+ == 1.0.1 (2021-11-13)
12
+ * *Fix* a buffer overflow error in XZ::Stream (PR Quintus#17 by genail)
13
+ * *Fix* an issue with transcode_options that was introduced by Ruby 3
14
+ (PR win93#1 by Alex Gittemeier)
15
+ * Update project README, gemspec, and other metadata to reflect a change in
16
+ maintainership. All prior releases were released by Marvin Gülker.
17
+
3
18
  == 1.0.0 (2018-05-20)
4
19
 
5
20
  * *BreakingChange* The XZ module's methods now take any parameters
@@ -10,7 +25,7 @@
10
25
  returning BINARY-tagged strings.
11
26
  * *BreakingChange* Remove deprecated API on stream reader/writer
12
27
  class and instead sync the API with Ruby's zlib library
13
- (Ticket #12 by me).
28
+ (Ticket Quintus#12 by Quintus).
14
29
  * *BreakingChange* StreamWriter.new and StreamReader.new do not accept
15
30
  a block anymore. This is part of syncing with Ruby's zlib API.
16
31
  * *BreakingChange* StreamReader.open and StreamWriter.open always
@@ -40,9 +55,9 @@
40
55
  * *Dependency* Remove dependency on ffi. ruby-xz now uses fiddle from
41
56
  the stdlib instead.
42
57
  * *Dependency* Remove dependency on io-like. ruby-xz now implements
43
- all the IO mechanics itself. (Ticket #10 by me)
58
+ all the IO mechanics itself. (Ticket Quintus#10 by Quintus)
44
59
  * *Dependency* Bump required Ruby version to 2.3.0.
45
- * *Fix* libzlma.dylib not being found on OS X (Ticket #15 by
60
+ * *Fix* libzlma.dylib not being found on OS X (Ticket Quintus#15 by
46
61
  s0nspark).
47
62
 
48
63
  == 0.2.3 (2015-12-29)
@@ -60,7 +75,7 @@
60
75
  * *Deprecate* use of XZ::StreamWriter.new with a filename argument
61
76
  * *Deprecate* nonautomatic IO close in XZ::StreamReader#close
62
77
  * *Deprecate* nonautomatic IO close in XZ::StreamWriter#close
63
- * *Fix* incompatibility with Resolv.getaddress() in Ruby 2.2 (Ticket #13
78
+ * *Fix* incompatibility with Resolv.getaddress() in Ruby 2.2 (Ticket Quintus#13
64
79
  by Ken Simon)
65
80
  * Goal of these deprecations is to sync the API with Ruby’s own
66
81
  Zlib::GzipWriter and Zlib::GzipReader mostly.
@@ -71,12 +86,12 @@
71
86
 
72
87
  == 0.2.1 (2014-02-08)
73
88
 
74
- * Build the gem properly on Ruby 2.0+ (PR #8 by Nana Sakisaka (saki7))
75
- * Release the GIL when interfacing with liblzma (PR #7 by Lars Christensen (larsch))
89
+ * Build the gem properly on Ruby 2.0+ (PR Quintus#8 by Nana Sakisaka (saki7))
90
+ * Release the GIL when interfacing with liblzma (PR Quintus#7 by Lars Christensen (larsch))
76
91
 
77
92
  == 0.2.0 (2013-06-23)
78
93
 
79
- * Fix #6 (errors on JRuby) by Ben Nagy
94
+ * Fix Quintus#6 (errors on JRuby) by Ben Nagy
80
95
  * <b>Remove 1.8 compatibility</b>
81
96
 
82
97
  == 0.1.0 (2013-02-17)
data/README.md CHANGED
@@ -1,64 +1,62 @@
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 on top of Ruby's fiddle” library
9
- (part of the standard libary). ruby-xz does not have any dependencies
10
- other than Ruby itself.
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.
11
10
 
12
- ruby-xz supports both “intuitive” (de)compression by providing methods to
13
- directly operate on strings and files, but also allows you to operate
14
- directly on IO streams (see the various methods of the XZ module). On top
15
- of that, ruby-xz offers an advanced interface that allows you to treat
16
- XZ-compressed data as IO streams, both for reading and for writing. See the
17
- 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 -->
18
17
 
19
- **Note**: Version 1.0.0 breaks the API quite heavily. Refer to
20
- HISTORY.rdoc for details.
18
+ **Note**: Version 1.0.0 breaks the API quite heavily.
19
+ Refer to HISTORY.rdoc for details.
21
20
 
22
- Installation
23
- ------------
21
+ ## Installation
24
22
 
25
- Install it the way you install all your gems.
23
+ Install with `gem` from your Ruby installation:
26
24
 
27
- ```
28
- $ gem install ruby-xz
25
+ ```sh
26
+ gem install ruby-xz
29
27
  ```
30
28
 
31
- Alternatively, you can clone the repository and build the most recent
32
- code yourself:
29
+ Alternatively, add it to your Gemfile via:
33
30
 
34
- ```
35
- $ git clone git://git.guelker.eu/ruby-xz.git
36
- $ cd ruby-xz
37
- $ rake gem
38
- $ gem install pkg/ruby-xz-*.gem
31
+ ```sh
32
+ bundle add ruby-xz
39
33
  ```
40
34
 
41
- Usage
42
- -----
35
+ If you want to be on the bleeding edge, you can clone the repository and build
36
+ the most recent code yourself:
43
37
 
44
- The documentation of the XZ module is well and you should be able to find
45
- everything you need to use ruby-xz. As said, it's not big, but powerful:
46
- You can create and extract whole archive files, compress or decompress
47
- 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
+ ```
48
44
 
49
- You can read the documentation on your local gemserver, or browse it [online][2].
45
+ ## Usage
50
46
 
51
- ### Require ###
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.
52
51
 
53
- You have to require the “xz.rb” file:
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? -->
54
54
 
55
- ``` ruby
56
- require "xz"
57
- ```
58
-
59
- ### Examples ###
55
+ ### Examples
60
56
 
61
57
  ``` ruby
58
+ require 'xz'
59
+
62
60
  # Compress a file
63
61
  XZ.compress_file("myfile.txt", "myfile.txt.xz")
64
62
  # Decompress it
@@ -74,16 +72,17 @@ comp = XZ.compress("Mydata")
74
72
  data = XZ.decompress(comp)
75
73
  ```
76
74
 
77
- Have a look at the XZ module's documentation for an in-depth description of
78
- 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 -->
79
78
 
80
- ### Usage with the minitar gem ###
79
+ ### Usage with the minitar gem
81
80
 
82
- ruby-xz can be used together with the [minitar][3] library (formerly
83
- “archive-tar-minitar”) to create XZ-compressed tarballs. This works by
84
- employing the IO-like classes XZ::StreamReader and XZ::StreamWriter
85
- analogous to how one would use Ruby's “zlib” library together with
86
- “minitar”. Example:
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”:
87
86
 
88
87
  ``` ruby
89
88
  require "xz"
@@ -100,19 +99,41 @@ XZ::StreamReader.open("tarball.tar.xz") do |txz|
100
99
  end
101
100
  ```
102
101
 
103
- Links
104
- -----
102
+ ## Development
103
+
104
+ After checking out the repo, run `bundle install` to install dependencies.
105
105
 
106
- * Website: https://mg.guelker.eu/projects/ruby-xz/
107
- * Online documentation: https://mg.guelker.eu/projects/ruby-xz/doc
108
- * Code repository: https://git.guelker.eu/?p=ruby-xz.git;a=summary
109
- * Issue tracker: https://github.com/Quintus/ruby-xz/issues
106
+ To install this gem onto your local machine, run `rake install`.
110
107
 
111
- License
112
- -------
108
+ To release a new version:
109
+
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 development`
114
+ - Run `rake release`, which will create/push a git tag and publish the `.gem`
115
+ file to [rubygems.org].
116
+
117
+ [rubygems.org]: https://rubygems.org
118
+
119
+ ## Links
120
+
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>
124
+
125
+ ## License
113
126
 
114
127
  MIT license; see LICENSE for the full license text.
115
128
 
116
- [1]: https://tukaani.org/xz/
117
- [2]: https://mg.guelker.eu/projects/ruby-xz/doc
118
- [3]: https://github.com/halostatue/minitar
129
+ ## Acknowledgements
130
+
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.
134
+
135
+
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
data/lib/xz/stream.rb CHANGED
@@ -118,7 +118,7 @@ class XZ::Stream
118
118
  pos = 0
119
119
  until pos > str.bytesize # Do not use >=, that conflicts with #lzma_finish
120
120
  substr = str[pos, XZ::CHUNK_SIZE]
121
- @input_buffer_p[0, str.bytesize] = substr
121
+ @input_buffer_p[0, substr.bytesize] = substr
122
122
  pos += XZ::CHUNK_SIZE
123
123
 
124
124
  @lzma_stream.next_in = @input_buffer_p
@@ -155,9 +155,9 @@ class XZ::Stream
155
155
  # Reset internal state
156
156
  @pos = @lineno = 0
157
157
  @finished = false
158
-
159
- # Allocate a new lzma stream (subclasses will configure it).
160
158
  @lzma_stream = XZ::LibLZMA::LZMAStream.malloc
159
+ @input_buffer_p = Fiddle::Pointer.malloc(XZ::CHUNK_SIZE)
160
+ @output_buffer_p = Fiddle::Pointer.malloc(XZ::CHUNK_SIZE)
161
161
  XZ::LibLZMA::LZMA_STREAM_INIT(@lzma_stream)
162
162
 
163
163
  0 # Mimic IO#rewind's return value
@@ -211,6 +211,9 @@ class XZ::Stream
211
211
  # Clean up the lzma_stream structure's internal memory.
212
212
  # This would belong into a destructor if Ruby had that.
213
213
  XZ::LibLZMA.lzma_end(@lzma_stream)
214
+ Fiddle.free @lzma_stream.to_ptr
215
+ Fiddle.free @input_buffer_p
216
+ Fiddle.free @output_buffer_p
214
217
  @finished = true
215
218
 
216
219
  @delegate_io
@@ -250,7 +250,7 @@ class XZ::StreamReader < XZ::Stream
250
250
  # Now, transcode it to the internal encoding if that was requested.
251
251
  # Otherwise return it with the external encoding as-is.
252
252
  if @internal_encoding
253
- @readbuf.encode!(@internal_encoding, @transcode_options)
253
+ @readbuf.encode!(@internal_encoding, **@transcode_options)
254
254
  outbuf.force_encoding(@internal_encoding)
255
255
  else
256
256
  outbuf.force_encoding(@external_encoding)
data/lib/xz/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # -*- coding: utf-8 -*-
2
3
  #--
3
4
  # Basic liblzma-bindings for Ruby.
@@ -26,8 +27,6 @@
26
27
  #++
27
28
 
28
29
  module XZ
29
-
30
30
  # The version of this library.
31
- VERSION = "1.0.0".freeze
32
-
31
+ VERSION = '1.0.3'
33
32
  end
data/lib/xz.rb CHANGED
@@ -218,8 +218,10 @@ module XZ
218
218
  end
219
219
 
220
220
  LibLZMA.lzma_end(stream.to_ptr)
221
+ res = stream.total_out if block_given?
221
222
 
222
- block_given? ? stream.total_out : res
223
+ Fiddle.free stream.to_ptr
224
+ res
223
225
  end
224
226
  alias decode_stream decompress_stream
225
227
 
@@ -317,8 +319,10 @@ module XZ
317
319
  end
318
320
 
319
321
  LibLZMA.lzma_end(stream.to_ptr)
322
+ res = stream.total_out if block_given?
320
323
 
321
- block_given? ? stream.total_out : res
324
+ Fiddle.free stream.to_ptr
325
+ res
322
326
  end
323
327
  alias encode_stream compress_stream
324
328
 
@@ -458,8 +462,8 @@ module XZ
458
462
  # time--this is needed to allow (de-)compressing of very large
459
463
  # files that can't be loaded fully into memory.
460
464
  def lzma_code(io, stream)
461
- input_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE) # automatically freed by fiddle on GC
462
- output_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE) # automatically freed by fiddle on GC
465
+ input_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE)
466
+ output_buffer_p = Fiddle::Pointer.malloc(CHUNK_SIZE)
463
467
 
464
468
  while str = io.read(CHUNK_SIZE)
465
469
  input_buffer_p[0, str.bytesize] = str
@@ -502,6 +506,9 @@ module XZ
502
506
  break unless stream.avail_out == 0
503
507
  end #loop
504
508
  end #while
509
+
510
+ Fiddle.free input_buffer_p
511
+ Fiddle.free output_buffer_p
505
512
  end #lzma_code
506
513
 
507
514
  # Checks for errors and warnings that can be derived from the
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-xz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Gülker
8
- autorequire:
8
+ - Alex Gittemeier
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2018-05-20 00:00:00.000000000 Z
12
+ date: 2022-03-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: minitar
@@ -24,13 +25,41 @@ dependencies:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
27
  version: '0.6'
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '5.14'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '5.14'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '13.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '13.0'
27
56
  description: |
28
57
  These are simple Ruby bindings for the liblzma library
29
58
  (http://tukaani.org/xz/), which is best known for the
30
59
  extreme compression ratio its native XZ format achieves.
31
60
  Since fiddle is used to implement the bindings, no compilation
32
61
  is needed.
33
- email: m-guelker@phoenixmail.de
62
+ email: me@a.lexg.dev
34
63
  executables: []
35
64
  extensions: []
36
65
  extra_rdoc_files:
@@ -50,10 +79,16 @@ files:
50
79
  - lib/xz/stream_reader.rb
51
80
  - lib/xz/stream_writer.rb
52
81
  - lib/xz/version.rb
53
- homepage: https://mg.guelker.eu/projects/ruby-xz/
82
+ homepage: https://github.com/win93/ruby-xz
54
83
  licenses:
55
84
  - MIT
56
- metadata: {}
85
+ metadata:
86
+ homepage_uri: https://github.com/win93/ruby-xz
87
+ source_code_uri: https://github.com/win93/ruby-xz/tree/stable
88
+ documentation_uri: https://www.rubydoc.info/gems/ruby-xz
89
+ bug_tracker_uri: https://github.com/win93/ruby-xz/issues
90
+ changelog_uri: https://github.com/win93/ruby-xz/blob/stable/HISTORY.rdoc
91
+ rubygems_mfa_required: 'true'
57
92
  post_install_message: Version 1.0.0 of ruby-xz breaks the API. Read HISTORY.rdoc and
58
93
  adapt your code to the new API.
59
94
  rdoc_options:
@@ -74,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
109
  - !ruby/object:Gem::Version
75
110
  version: '0'
76
111
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.5.2.1
79
- signing_key:
112
+ rubygems_version: 3.3.7
113
+ signing_key:
80
114
  specification_version: 4
81
115
  summary: XZ compression via liblzma for Ruby, using fiddle.
82
116
  test_files: []