rbzip2 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Gemfile.lock +1 -1
- data/README.md +24 -5
- data/lib/rbzip2.rb +4 -1
- data/lib/rbzip2/compressor.rb +1310 -0
- data/lib/rbzip2/constants.rb +82 -66
- data/lib/rbzip2/crc.rb +105 -105
- data/lib/rbzip2/decompressor.rb +703 -684
- data/lib/rbzip2/input_data.rb +51 -0
- data/lib/rbzip2/io.rb +16 -12
- data/lib/rbzip2/output_data.rb +59 -0
- data/lib/rbzip2/version.rb +1 -1
- data/spec/compressor_spec.rb +42 -0
- data/spec/decompressor_spec.rb +41 -0
- data/spec/fixtures/big_test.bz2 +0 -0
- data/spec/fixtures/big_test.txt +2018 -0
- metadata +16 -7
- data/lib/rbzip2/data.rb +0 -51
- data/spec/io_spec.rb +0 -37
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbzip2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sebastian Staudt
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :development
|
@@ -107,6 +107,7 @@ extensions: []
|
|
107
107
|
extra_rdoc_files: []
|
108
108
|
|
109
109
|
files:
|
110
|
+
- .gemtest
|
110
111
|
- .gitignore
|
111
112
|
- .travis.yml
|
112
113
|
- Gemfile
|
@@ -115,17 +116,22 @@ files:
|
|
115
116
|
- README.md
|
116
117
|
- Rakefile
|
117
118
|
- lib/rbzip2.rb
|
119
|
+
- lib/rbzip2/compressor.rb
|
118
120
|
- lib/rbzip2/constants.rb
|
119
121
|
- lib/rbzip2/crc.rb
|
120
|
-
- lib/rbzip2/data.rb
|
121
122
|
- lib/rbzip2/decompressor.rb
|
123
|
+
- lib/rbzip2/input_data.rb
|
122
124
|
- lib/rbzip2/io.rb
|
125
|
+
- lib/rbzip2/output_data.rb
|
123
126
|
- lib/rbzip2/version.rb
|
124
127
|
- rbzip2.gemspec
|
128
|
+
- spec/compressor_spec.rb
|
129
|
+
- spec/decompressor_spec.rb
|
130
|
+
- spec/fixtures/big_test.bz2
|
131
|
+
- spec/fixtures/big_test.txt
|
125
132
|
- spec/fixtures/test.bz2
|
126
133
|
- spec/fixtures/test.txt
|
127
134
|
- spec/helper.rb
|
128
|
-
- spec/io_spec.rb
|
129
135
|
homepage: https://github.com/koraktor/rbzip2
|
130
136
|
licenses: []
|
131
137
|
|
@@ -160,7 +166,10 @@ signing_key:
|
|
160
166
|
specification_version: 3
|
161
167
|
summary: Pure Ruby impementation of bzip2
|
162
168
|
test_files:
|
169
|
+
- spec/compressor_spec.rb
|
170
|
+
- spec/decompressor_spec.rb
|
171
|
+
- spec/fixtures/big_test.bz2
|
172
|
+
- spec/fixtures/big_test.txt
|
163
173
|
- spec/fixtures/test.bz2
|
164
174
|
- spec/fixtures/test.txt
|
165
175
|
- spec/helper.rb
|
166
|
-
- spec/io_spec.rb
|
data/lib/rbzip2/data.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# the terms of the new BSD License.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2011, Sebastian Staudt
|
5
|
-
|
6
|
-
require 'rbzip2/constants'
|
7
|
-
|
8
|
-
class RBzip2::Data
|
9
|
-
|
10
|
-
attr_reader :base, :cftab, :get_and_move_to_front_decode_yy, :in_use,
|
11
|
-
:limit, :ll8, :min_lens, :perm, :receive_decoding_tables_pos,
|
12
|
-
:selector, :selector_mtf, :seq_to_unseq, :temp_char_array_2d,
|
13
|
-
:unzftab, :tt
|
14
|
-
|
15
|
-
def initialize(block_size)
|
16
|
-
@in_use = Array.new 256, false
|
17
|
-
|
18
|
-
@seq_to_unseq = Array.new 256, 0
|
19
|
-
@selector = Array.new RBzip2::MAX_SELECTORS, 0
|
20
|
-
@selector_mtf = Array.new RBzip2::MAX_SELECTORS, 0
|
21
|
-
|
22
|
-
@unzftab = Array.new 256, 0
|
23
|
-
|
24
|
-
@base = Array.new RBzip2::N_GROUPS
|
25
|
-
RBzip2::N_GROUPS.times { |i| @base[i] = Array.new(RBzip2::MAX_ALPHA_SIZE, 0) }
|
26
|
-
@limit = Array.new RBzip2::N_GROUPS
|
27
|
-
RBzip2::N_GROUPS.times { |i| @limit[i] = Array.new(RBzip2::MAX_ALPHA_SIZE, 0) }
|
28
|
-
@perm = Array.new RBzip2::N_GROUPS
|
29
|
-
RBzip2:: N_GROUPS.times { |i| @perm[i] = Array.new(RBzip2::MAX_ALPHA_SIZE, 0) }
|
30
|
-
@min_lens = Array.new RBzip2::N_GROUPS, 0
|
31
|
-
|
32
|
-
@cftab = Array.new 257, 0
|
33
|
-
@get_and_move_to_front_decode_yy = Array.new 256
|
34
|
-
@temp_char_array_2d = Array.new RBzip2::N_GROUPS
|
35
|
-
RBzip2::N_GROUPS.times { |i| @temp_char_array_2d[i] = Array.new(RBzip2::MAX_ALPHA_SIZE, 0) }
|
36
|
-
@receive_decoding_tables_pos = Array.new RBzip2::N_GROUPS, 0
|
37
|
-
|
38
|
-
@ll8 = Array.new block_size * RBzip2::BASEBLOCKSIZE
|
39
|
-
end
|
40
|
-
|
41
|
-
def init_tt(size)
|
42
|
-
tt_shadow = @tt
|
43
|
-
|
44
|
-
if tt_shadow.nil? || tt_shadow.size < size
|
45
|
-
@tt = tt_shadow = Array.new(size)
|
46
|
-
end
|
47
|
-
|
48
|
-
tt_shadow
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
data/spec/io_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# the terms of the new BSD License.
|
3
|
-
#
|
4
|
-
# Copyright (c) 2011, Sebastian Staudt
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
describe RBzip2::IO do
|
9
|
-
|
10
|
-
before do
|
11
|
-
@txt_file = File.new File.join(File.dirname(__FILE__), 'fixtures/test.txt')
|
12
|
-
bz2_file = File.new File.join(File.dirname(__FILE__), 'fixtures/test.bz2')
|
13
|
-
@bz2_io = RBzip2::IO.new bz2_file
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'allows decompressing data' do
|
17
|
-
RBzip2::IO.should include(Decompressor)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'acts like a standard IO' do
|
21
|
-
methods = RBzip2::IO.instance_methods.map { |m| m.to_sym }
|
22
|
-
methods.should include(:read, :close)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'knows its size' do
|
26
|
-
@bz2_io.size.should be(375)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'knows the size of the uncompressed data' do
|
30
|
-
@bz2_io.uncompressed.should be(704)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should be able to decompress compressed data' do
|
34
|
-
@bz2_io.read.should eq(@txt_file.read)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|