ruby-xz 0.2.0 → 0.2.1

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
2
  SHA1:
3
- metadata.gz: 0c48419b0caefc3d26a50fa3e9e421f3b5d86301
4
- data.tar.gz: b69d305b6301a0520bf810b1e201026520a5b583
3
+ metadata.gz: 8c1956c341bfbdbb6a5b002b47f8c418fafe3c8c
4
+ data.tar.gz: 8af67a57895f50f871a4509fc94f57932be150a4
5
5
  SHA512:
6
- metadata.gz: 9b8e7ed6086ae03303cab824e1df92dc96b95e5d00d42c770ed29be325dfe4b87a458e37c33c7c33de781d44f0667f0abf2c9c43d5eb873f07c037301e3e8b74
7
- data.tar.gz: 6b5a55e8a3c16f4310b8fedca488edef9e99d9424064bccac16325e7de2f7e97aed1550b1716c365e6d807aa8259297bc5dd74f67ce4557dd00aae274217f3fb
6
+ metadata.gz: 2c04ff79076e081427e827e87fe489a882bf8b22674ebb3e0c3c8af26877c54b9b2140da1d61527da305bbcf062d4d5e687ce011a702a8300ce68a426bdba127
7
+ data.tar.gz: faac093525a0ab41c0fd35a2b3e39a95c70ca70c312dc6accf051343c17f770d2ed396b9266f93c7a67ff887bf450b9cc2b649cb69df7c074c03cc980054d455
data/COPYING CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Basic liblzma-bindings for Ruby.
4
4
 
5
- Copyright © 2011-2013 Marvin Gülker
5
+ Copyright © 2011-2013 Marvin Gülker et al.
6
6
 
7
- Copyright © 2011 Christoph Plank
7
+ See the file `AUTHORS' for the full list of contributors.
8
8
 
9
9
  Permission is hereby granted, free of charge, to any person obtaining
10
10
  a copy of this software and associated documentation files (the
@@ -1,3 +1,8 @@
1
+ == 0.2.1
2
+
3
+ * Build the gem properly on Ruby 2.0+ (PR #8 by Nana Sakisaka (saki7))
4
+ * Release the GIL when interfacing with liblzma (PR #7 by Lars Christensen (larsch))
5
+
1
6
  == 0.2.0
2
7
 
3
8
  * Fix #6 (errors on JRuby) by Ben Nagy
@@ -29,6 +29,9 @@ everything you need to use ruby-xz. As said, it's not big, but powerful:
29
29
  You can create and extract whole archive files, compress or decompress
30
30
  streams of data or just plain strings.
31
31
 
32
+ You can read the documentation on your local gemserver, or online at
33
+ http://quintus.github.io/ruby-xz/.
34
+
32
35
  === First step
33
36
 
34
37
  You have to require ruby-xz. Note the file you have to require is named
@@ -63,9 +66,9 @@ what is possible.
63
66
 
64
67
  Basic liblzma-bindings for Ruby.
65
68
 
66
- Copyright © 2011-2013 Marvin Gülker
69
+ Copyright © 2011-2013 Marvin Gülker et al.
67
70
 
68
- Copyright © 2011 Christoph Plank
71
+ See AUTHORS for the full list of contributors.
69
72
 
70
73
  Permission is hereby granted, free of charge, to any person obtaining a
71
74
  copy of this software and associated documentation files (the ‘Software’),
data/lib/xz.rb CHANGED
@@ -1,21 +1,21 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # (The MIT License)
3
- #
3
+ #
4
4
  # Basic liblzma-bindings for Ruby.
5
- #
5
+ #
6
6
  # Copyright © 2011,2012 Marvin Gülker
7
7
  # Copyright © 2011 Christoph Plank
8
- #
8
+ #
9
9
  # Permission is hereby granted, free of charge, to any person obtaining a
10
10
  # copy of this software and associated documentation files (the ‘Software’),
11
11
  # to deal in the Software without restriction, including without limitation
12
12
  # the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
13
  # and/or sell copies of the Software, and to permit persons to whom the Software
14
14
  # is furnished to do so, subject to the following conditions:
15
- #
15
+ #
16
16
  # The above copyright notice and this permission notice shall be included in all
17
17
  # copies or substantial portions of the Software.
18
- #
18
+ #
19
19
  # THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
20
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
21
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -40,15 +40,14 @@ require "io/like"
40
40
  #ruby-xz can’t handle this as compiled strings don’t come with encoding
41
41
  #information.
42
42
  module XZ
43
-
44
-
43
+ #The version of this library.
44
+ VERSION = "0.2.1"
45
+
45
46
  #Number of bytes read in one chunk.
46
47
  CHUNK_SIZE = 4096
47
- #The version of this library.
48
- VERSION = Pathname.new(__FILE__).dirname.expand_path.parent.join("VERSION").read.chomp.freeze
49
-
48
+
50
49
  class << self
51
-
50
+
52
51
  #call-seq:
53
52
  # decompress_stream(io [, memory_limit [, flags ] ] ) → a_string
54
53
  # decompress_stream(io [, memory_limit [, flags ] ] ){|chunk| ... } → an_integer
@@ -90,30 +89,30 @@ module XZ
90
89
  flags.each do |flag|
91
90
  raise(ArgumentError, "Unknown flag #{flag}!") unless [:tell_no_check, :tell_unsupported_check, :tell_any_check, :concatenated].include?(flag)
92
91
  end
93
-
92
+
94
93
  stream = LZMAStream.new
95
94
  res = LibLZMA.lzma_stream_decoder(
96
95
  stream.pointer,
97
96
  memory_limit,
98
97
  flags.inject(0){|val, flag| val | LibLZMA.const_get(:"LZMA_#{flag.to_s.upcase}")}
99
98
  )
100
-
99
+
101
100
  LZMAError.raise_if_necessary(res)
102
-
101
+
103
102
  res = ""
104
- res.encode!("BINARY")
103
+ res.encode!(Encoding::BINARY)
105
104
  if block_given?
106
105
  res = lzma_code(io, stream, &block)
107
106
  else
108
107
  lzma_code(io, stream){|chunk| res << chunk}
109
108
  end
110
-
109
+
111
110
  LibLZMA.lzma_end(stream.pointer)
112
-
111
+
113
112
  block_given? ? stream[:total_out] : res
114
113
  end
115
114
  alias decode_stream decompress_stream
116
-
115
+
117
116
  #call-seq:
118
117
  # compress_stream(io [, compression_level [, check [, extreme ] ] ] ) → a_string
119
118
  # compress_stream(io [, compression_level [, check [, extreme ] ] ] ){|chunk| ... } → an_integer
@@ -157,28 +156,28 @@ module XZ
157
156
  def compress_stream(io, compression_level = 6, check = :crc64, extreme = false, &block)
158
157
  raise(ArgumentError, "Invalid compression level!") unless (0..9).include?(compression_level)
159
158
  raise(ArgumentError, "Invalid checksum specified!") unless [:none, :crc32, :crc64, :sha256].include?(check)
160
-
159
+
161
160
  stream = LZMAStream.new
162
161
  res = LibLZMA.lzma_easy_encoder(stream.pointer,
163
162
  compression_level | (extreme ? LibLZMA::LZMA_PRESET_EXTREME : 0),
164
163
  LibLZMA::LZMA_CHECK[:"lzma_check_#{check}"])
165
-
164
+
166
165
  LZMAError.raise_if_necessary(res)
167
-
166
+
168
167
  res = ""
169
- res.encode!("BINARY")
168
+ res.encode!(Encoding::BINARY)
170
169
  if block_given?
171
170
  res = lzma_code(io, stream, &block)
172
171
  else
173
172
  lzma_code(io, stream){|chunk| res << chunk}
174
173
  end
175
-
174
+
176
175
  LibLZMA.lzma_end(stream.pointer)
177
-
176
+
178
177
  block_given? ? stream[:total_out] : res
179
178
  end
180
179
  alias encode_stream compress_stream
181
-
180
+
182
181
  #Compresses +in_file+ and writes the result to +out_file+.
183
182
  #===Parameters
184
183
  #[in_file] The path to the file to read from.
@@ -202,7 +201,7 @@ module XZ
202
201
  end
203
202
  end
204
203
  end
205
-
204
+
206
205
  #Compresses arbitrary data using the XZ algorithm.
207
206
  #===Parameters
208
207
  #[str] The data to compress.
@@ -220,7 +219,7 @@ module XZ
220
219
  s = StringIO.new(str)
221
220
  compress_stream(s, compression_level, check, extreme)
222
221
  end
223
-
222
+
224
223
  #Decompresses data in XZ format.
225
224
  #===Parameters
226
225
  #[str] The data to decompress.
@@ -238,7 +237,7 @@ module XZ
238
237
  s = StringIO.new(str)
239
238
  decompress_stream(s, memory_limit, flags)
240
239
  end
241
-
240
+
242
241
  #Decompresses +in_file+ and writes the result to +out_file+.
243
242
  #===Parameters
244
243
  #[in_file] The path to the file to read from.
@@ -262,20 +261,20 @@ module XZ
262
261
  end
263
262
  end
264
263
  end
265
-
264
+
266
265
  private
267
-
266
+
268
267
  #This method returns the size of +str+ in bytes.
269
268
  def binary_size(str)
270
269
  #Believe it or not, but this is faster than str.bytes.to_a.size.
271
270
  #I benchmarked it, and it is as twice as fast.
272
271
  if str.respond_to? :force_encoding
273
- str.dup.force_encoding("BINARY").size
272
+ str.dup.force_encoding(Encoding::BINARY).size
274
273
  else
275
274
  str.bytes.to_a.size
276
275
  end
277
276
  end
278
-
277
+
279
278
  #This method does the heavy work of (de-)compressing a stream. It takes
280
279
  #an IO object to read data from (that means the IO must be opened
281
280
  #for reading) and a XZ::LZMAStream object that is used to (de-)compress
@@ -286,10 +285,10 @@ module XZ
286
285
  def lzma_code(io, stream)
287
286
  input_buffer_p = FFI::MemoryPointer.new(CHUNK_SIZE)
288
287
  output_buffer_p = FFI::MemoryPointer.new(CHUNK_SIZE)
289
-
288
+
290
289
  while str = io.read(CHUNK_SIZE)
291
290
  input_buffer_p.write_string(str)
292
-
291
+
293
292
  #Set the data for compressing
294
293
  stream[:next_in] = input_buffer_p
295
294
  stream[:avail_in] = binary_size(str)
@@ -306,7 +305,7 @@ module XZ
306
305
  #Prepare for getting the compressed_data
307
306
  stream[:next_out] = output_buffer_p
308
307
  stream[:avail_out] = CHUNK_SIZE
309
-
308
+
310
309
  #Compress the data
311
310
  res = if io.eof?
312
311
  LibLZMA.lzma_code(stream.pointer, LibLZMA::LZMA_ACTION[:lzma_finish])
@@ -314,11 +313,11 @@ module XZ
314
313
  LibLZMA.lzma_code(stream.pointer, LibLZMA::LZMA_ACTION[:lzma_run])
315
314
  end
316
315
  check_lzma_code_retval(res)
317
-
316
+
318
317
  #Write the compressed data
319
318
  data = output_buffer_p.read_string(CHUNK_SIZE - stream[:avail_out])
320
319
  yield(data)
321
-
320
+
322
321
  #If the buffer is completely filled, it's likely that there is
323
322
  #more data liblzma wants to hand to us. Start a new iteration,
324
323
  #but don't provide new input data.
@@ -326,7 +325,7 @@ module XZ
326
325
  end #loop
327
326
  end #while
328
327
  end #lzma_code
329
-
328
+
330
329
  #Checks for errors and warnings that can be derived from the return
331
330
  #value of the lzma_code() function and shows them if necessary.
332
331
  def check_lzma_code_retval(code)
@@ -339,9 +338,9 @@ module XZ
339
338
  LZMAError.raise_if_necessary(code)
340
339
  end
341
340
  end
342
-
341
+
343
342
  end #class << self
344
-
343
+
345
344
  end
346
345
 
347
346
  require_relative "xz/lib_lzma"
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # Basic liblzma-bindings for Ruby.
5
5
  #
6
- # Copyright © 2011 Marvin Gülker
6
+ # Copyright © 2011,2013 Marvin Gülker et al.
7
7
  #
8
8
  # Permission is hereby granted, free of charge, to any person obtaining a
9
9
  # copy of this software and associated documentation files (the ‘Software’),
@@ -11,10 +11,10 @@
11
11
  # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
12
  # and/or sell copies of the Software, and to permit persons to whom the Software
13
13
  # is furnished to do so, subject to the following conditions:
14
- #
14
+ #
15
15
  # The above copyright notice and this permission notice shall be included in all
16
16
  # copies or substantial portions of the Software.
17
- #
17
+ #
18
18
  # THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
19
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
20
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,39 +24,39 @@
24
24
  # THE SOFTWARE.
25
25
 
26
26
  module XZ
27
-
27
+
28
28
  #This module wraps functions and enums used by liblzma.
29
29
  module LibLZMA
30
30
  extend FFI::Library
31
-
31
+
32
32
  #The maximum value of an uint64_t, as defined by liblzma.
33
33
  #Should be the same as
34
34
  # (2 ** 64) - 1
35
35
  UINT64_MAX = 18446744073709551615
36
-
36
+
37
37
  #Activates extreme compression. Same as xz's "-e" commandline switch.
38
38
  LZMA_PRESET_EXTREME = 1 << 31
39
-
39
+
40
40
  LZMA_TELL_NO_CHECK = 0x02
41
41
  LZMA_TELL_UNSUPPORTED_CHECK = 0x02
42
42
  LZMA_TELL_ANY_CHECK = 0x04
43
43
  LZMA_CONCATENATED = 0x08
44
-
44
+
45
45
  #Placeholder enum used by liblzma for later additions.
46
46
  LZMA_RESERVED_ENUM = enum :lzma_reserved_enum, 0
47
-
47
+
48
48
  #Actions that can be passed to the lzma_code() function.
49
49
  LZMA_ACTION = enum :lzma_run, 0,
50
50
  :lzma_sync_flush,
51
51
  :lzma_full_flush,
52
52
  :lzma_finish
53
-
53
+
54
54
  #Integrity check algorithms supported by liblzma.
55
55
  LZMA_CHECK = enum :lzma_check_none, 0,
56
56
  :lzma_check_crc32, 1,
57
57
  :lzma_check_crc64, 4,
58
58
  :lzma_check_sha256, 10
59
-
59
+
60
60
  #Possible return values of liblzma functions.
61
61
  LZMA_RET = enum :lzma_ok, 0,
62
62
  :lzma_stream_end,
@@ -70,19 +70,19 @@ module XZ
70
70
  :lzma_data_error,
71
71
  :lzma_buf_error,
72
72
  :lzma_prog_error
73
-
73
+
74
74
  ffi_lib ['lzma.so.5', 'lzma.so', 'lzma']
75
-
76
- attach_function :lzma_easy_encoder, [:pointer, :uint32, :int], :int
77
- attach_function :lzma_code, [:pointer, :int], :int
78
- attach_function :lzma_stream_decoder, [:pointer, :uint64, :uint32], :int
79
- attach_function :lzma_end, [:pointer], :void
80
-
75
+
76
+ attach_function :lzma_easy_encoder, [:pointer, :uint32, :int], :int, :blocking => true
77
+ attach_function :lzma_code, [:pointer, :int], :int, :blocking => true
78
+ attach_function :lzma_stream_decoder, [:pointer, :uint64, :uint32], :int, :blocking => true
79
+ attach_function :lzma_end, [:pointer], :void, :blocking => true
80
+
81
81
  end
82
82
 
83
83
  #The class of the error that this library raises.
84
84
  class LZMAError < StandardError
85
-
85
+
86
86
  #Raises an appropriate exception if +val+ isn't a liblzma success code.
87
87
  def self.raise_if_necessary(val)
88
88
  case LibLZMA::LZMA_RET[val]
@@ -95,7 +95,7 @@ module XZ
95
95
  when :lzma_prog_error then raise(self, "Program error--if you're sure your code is correct, you may have found a bug in liblzma.")
96
96
  end
97
97
  end
98
-
98
+
99
99
  end
100
100
 
101
101
  #The main struct of the liblzma library.
@@ -118,7 +118,7 @@ module XZ
118
118
  :reserved_int4, :size_t,
119
119
  :reserved_enum1, :int,
120
120
  :reserved_enum2, :int
121
-
121
+
122
122
  #This method does basicly the same thing as the
123
123
  #LZMA_STREAM_INIT macro of liblzma. Creates a new LZMAStream
124
124
  #that has been initialized for usage. If any argument is passed,
@@ -2,19 +2,19 @@
2
2
  # (The MIT license)
3
3
  #
4
4
  # Basic liblzma-bindings for Ruby.
5
- #
5
+ #
6
6
  # Copyright © 2012 Marvin Gülker
7
- #
7
+ #
8
8
  # Permission is hereby granted, free of charge, to any person obtaining a
9
9
  # copy of this software and associated documentation files (the ‘Software’),
10
10
  # to deal in the Software without restriction, including without limitation
11
11
  # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
12
  # and/or sell copies of the Software, and to permit persons to whom the Software
13
13
  # is furnished to do so, subject to the following conditions:
14
- #
14
+ #
15
15
  # The above copyright notice and this permission notice shall be included in all
16
16
  # copies or substantial portions of the Software.
17
- #
17
+ #
18
18
  # THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
19
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
20
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -58,7 +58,7 @@ class XZ::Stream
58
58
  #Believe it or not, but this is faster than str.bytes.to_a.size.
59
59
  #I benchmarked it, and it is as twice as fast.
60
60
  if str.respond_to? :force_encoding
61
- str.dup.force_encoding("BINARY").size
61
+ str.dup.force_encoding(Encoding::BINARY).size
62
62
  else
63
63
  str.bytes.to_a.size
64
64
  end
@@ -2,19 +2,19 @@
2
2
  # (The MIT license)
3
3
  #
4
4
  # Basic liblzma-bindings for Ruby.
5
- #
5
+ #
6
6
  # Copyright © 2012 Marvin Gülker
7
- #
7
+ #
8
8
  # Permission is hereby granted, free of charge, to any person obtaining a
9
9
  # copy of this software and associated documentation files (the ‘Software’),
10
10
  # to deal in the Software without restriction, including without limitation
11
11
  # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
12
  # and/or sell copies of the Software, and to permit persons to whom the Software
13
13
  # is furnished to do so, subject to the following conditions:
14
- #
14
+ #
15
15
  # The above copyright notice and this permission notice shall be included in all
16
16
  # copies or substantial portions of the Software.
17
- #
17
+ #
18
18
  # THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
19
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
20
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -55,7 +55,7 @@
55
55
  #
56
56
  # require "xz"
57
57
  # require "archive/tar/minitar"
58
- #
58
+ #
59
59
  # XZ::StreamReader.open("foo.tar.xz") do |txz|
60
60
  # # This automatically closes txz
61
61
  # Archive::Tar::Minitar.unpack(txz, "foo")
@@ -103,7 +103,7 @@ class XZ::StreamReader < XZ::Stream
103
103
  flags.each do |flag|
104
104
  raise(ArgumentError, "Unknown flag #{flag}!") unless [:tell_no_check, :tell_unsupported_check, :tell_any_check, :concatenated].include?(flag)
105
105
  end
106
-
106
+
107
107
  if delegate.respond_to?(:to_io)
108
108
  super(delegate)
109
109
  else
@@ -118,7 +118,7 @@ class XZ::StreamReader < XZ::Stream
118
118
  @memory_limit,
119
119
  @flags.inject(0){|val, flag| val | XZ::LibLZMA.const_get(:"LZMA_#{flag.to_s.upcase}")})
120
120
  XZ::LZMAError.raise_if_necessary(res)
121
-
121
+
122
122
  @input_buffer_p = FFI::MemoryPointer.new(XZ::CHUNK_SIZE)
123
123
 
124
124
  # These two are only used in #unbuffered read.
@@ -134,7 +134,7 @@ class XZ::StreamReader < XZ::Stream
134
134
  end
135
135
  end
136
136
  self.class.send(:alias_method, :open, :new)
137
-
137
+
138
138
  #Closes this StreamReader instance. Don’t use it afterwards
139
139
  #anymore.
140
140
  #==Return value
@@ -146,7 +146,7 @@ class XZ::StreamReader < XZ::Stream
146
146
  #you have to close it yourself.
147
147
  def close
148
148
  super
149
-
149
+
150
150
  # Close the XZ stream
151
151
  res = XZ::LibLZMA.lzma_end(@lzma_stream.pointer)
152
152
  XZ::LZMAError.raise_if_necessary(res)
@@ -194,7 +194,7 @@ class XZ::StreamReader < XZ::Stream
194
194
  # Be always sure to test this when a new version of
195
195
  # io-like is released!
196
196
  __io_like__internal_read_buffer.clear
197
-
197
+
198
198
  # Forcibly close the XZ stream (internally frees it!)
199
199
  res = XZ::LibLZMA.lzma_end(@lzma_stream.pointer)
200
200
  XZ::LZMAError.raise_if_necessary(res)
@@ -205,7 +205,7 @@ class XZ::StreamReader < XZ::Stream
205
205
  rescue => e
206
206
  raise(IOError, "Delegate IO failed to rewind! Original message: #{e.message}")
207
207
  end
208
-
208
+
209
209
  # Reinitialize everything. Note this doesn’t affect @file as it
210
210
  # is already set and stays so (we don’t pass a filename here,
211
211
  # but rather an IO)
@@ -226,7 +226,7 @@ class XZ::StreamReader < XZ::Stream
226
226
  #uncompressed data.
227
227
  def unbuffered_read(length)
228
228
  raise(EOFError, "Input data completely processed!") if @__lzma_finished
229
-
229
+
230
230
  output_buffer_p = FFI::MemoryPointer.new(length) # User guarantees that this fits into RAM
231
231
 
232
232
  @lzma_stream[:next_out] = output_buffer_p
@@ -2,19 +2,19 @@
2
2
  # (The MIT license)
3
3
  #
4
4
  # Basic liblzma-bindings for Ruby.
5
- #
5
+ #
6
6
  # Copyright © 2012 Marvin Gülker
7
- #
7
+ #
8
8
  # Permission is hereby granted, free of charge, to any person obtaining a
9
9
  # copy of this software and associated documentation files (the ‘Software’),
10
10
  # to deal in the Software without restriction, including without limitation
11
11
  # the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
12
  # and/or sell copies of the Software, and to permit persons to whom the Software
13
13
  # is furnished to do so, subject to the following conditions:
14
- #
14
+ #
15
15
  # The above copyright notice and this permission notice shall be included in all
16
16
  # copies or substantial portions of the Software.
17
- #
17
+ #
18
18
  # THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
19
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
20
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -105,9 +105,9 @@ class XZ::StreamWriter < XZ::Stream
105
105
  @file = File.open(delegate, "wb")
106
106
  super(@file)
107
107
  end
108
-
108
+
109
109
  # Initialize the internal LZMA stream for encoding
110
- res = XZ::LibLZMA.lzma_easy_encoder(@lzma_stream.pointer,
110
+ res = XZ::LibLZMA.lzma_easy_encoder(@lzma_stream.pointer,
111
111
  compression_level | (extreme ? XZ::LibLZMA::LZMA_PRESET_EXTREME : 0),
112
112
  XZ::LibLZMA::LZMA_CHECK[:"lzma_check_#{check}"])
113
113
  XZ::LZMAError.raise_if_necessary(res)
@@ -134,26 +134,26 @@ class XZ::StreamWriter < XZ::Stream
134
134
  #you have to do that yourself.
135
135
  def close
136
136
  super
137
-
137
+
138
138
  #1. Close the current block ("file") (an XZ stream may actually include
139
139
  # multiple compressed files, which however is not supported by
140
140
  # this library). For this we have to tell liblzma that
141
141
  # the next bytes we pass to it are the last bytes (by means of
142
142
  # the FINISH action). Just that we don’t pass any new input ;-)
143
-
143
+
144
144
  output_buffer_p = FFI::MemoryPointer.new(XZ::CHUNK_SIZE)
145
-
145
+
146
146
  # Get any pending data (LZMA_FINISH causes libzlma to flush its
147
147
  # internal buffers) and write it out to our wrapped IO.
148
148
  loop do
149
149
  @lzma_stream[:next_out] = output_buffer_p
150
150
  @lzma_stream[:avail_out] = output_buffer_p.size
151
-
151
+
152
152
  res = XZ::LibLZMA.lzma_code(@lzma_stream.pointer, XZ::LibLZMA::LZMA_ACTION[:lzma_finish])
153
153
  XZ::LZMAError.raise_if_necessary(res)
154
-
154
+
155
155
  @delegate_io.write(output_buffer_p.read_string(output_buffer_p.size - @lzma_stream[:avail_out]))
156
-
156
+
157
157
  break unless @lzma_stream[:avail_out] == 0
158
158
  end
159
159
 
@@ -198,7 +198,7 @@ class XZ::StreamWriter < XZ::Stream
198
198
  # Compress the data
199
199
  res = XZ::LibLZMA.lzma_code(@lzma_stream.pointer, XZ::LibLZMA::LZMA_ACTION[:lzma_run])
200
200
  XZ::LZMAError.raise_if_necessary(res) # TODO: Warnings
201
-
201
+
202
202
  # Write the compressed data
203
203
  result = output_buffer_p.read_string(output_buffer_p.size - @lzma_stream[:avail_out])
204
204
  @delegate_io.write(result)
@@ -211,5 +211,5 @@ class XZ::StreamWriter < XZ::Stream
211
211
  rescue XZ::LZMAError => e
212
212
  raise(SystemCallError, e.message)
213
213
  end
214
-
214
+
215
215
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-xz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marvin Gülker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-23 00:00:00.000000000 Z
11
+ date: 2014-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -80,15 +80,14 @@ extra_rdoc_files:
80
80
  - COPYING
81
81
  files:
82
82
  - lib/xz.rb
83
- - lib/xz/stream_reader.rb
84
- - lib/xz/lib_lzma.rb
85
83
  - lib/xz/stream.rb
86
84
  - lib/xz/stream_writer.rb
85
+ - lib/xz/stream_reader.rb
86
+ - lib/xz/lib_lzma.rb
87
87
  - HISTORY.rdoc
88
88
  - README.rdoc
89
89
  - COPYING
90
- - VERSION
91
- homepage: https://github.com/Quintus/ruby-xz
90
+ homepage: http://quintus.github.io/ruby-xz
92
91
  licenses:
93
92
  - MIT
94
93
  metadata: {}
@@ -112,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
111
  version: '0'
113
112
  requirements: []
114
113
  rubyforge_project:
115
- rubygems_version: 2.0.3
114
+ rubygems_version: 2.0.14
116
115
  signing_key:
117
116
  specification_version: 4
118
117
  summary: XZ compression via liblzma for Ruby.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0