Zliby 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/CHANGES +5 -0
  2. data/LICENSE +26 -0
  3. data/README +33 -0
  4. data/TODO +6 -0
  5. data/bin/zliby.rb +1 -0
  6. data/lib/zliby.rb +624 -0
  7. data/specs/adler32_spec.rb +46 -0
  8. data/specs/crc32_spec.rb +52 -0
  9. data/specs/crc_table_spec.rb +11 -0
  10. data/specs/deflate/append_spec.rb +2 -0
  11. data/specs/deflate/deflate_spec.rb +49 -0
  12. data/specs/deflate/flush_spec.rb +2 -0
  13. data/specs/deflate/initialize_copy_spec.rb +2 -0
  14. data/specs/deflate/new_spec.rb +2 -0
  15. data/specs/deflate/params_spec.rb +21 -0
  16. data/specs/deflate/set_dictionary_spec.rb +14 -0
  17. data/specs/gzipfile/close_spec.rb +23 -0
  18. data/specs/gzipfile/closed_spec.rb +18 -0
  19. data/specs/gzipfile/comment_spec.rb +28 -0
  20. data/specs/gzipfile/crc_spec.rb +2 -0
  21. data/specs/gzipfile/finish_spec.rb +2 -0
  22. data/specs/gzipfile/level_spec.rb +2 -0
  23. data/specs/gzipfile/mtime_spec.rb +2 -0
  24. data/specs/gzipfile/orig_name_spec.rb +28 -0
  25. data/specs/gzipfile/os_code_spec.rb +2 -0
  26. data/specs/gzipfile/sync_spec.rb +2 -0
  27. data/specs/gzipfile/to_io_spec.rb +2 -0
  28. data/specs/gzipfile/wrap_spec.rb +2 -0
  29. data/specs/gzipreader/each_byte_spec.rb +2 -0
  30. data/specs/gzipreader/each_line_spec.rb +2 -0
  31. data/specs/gzipreader/each_spec.rb +2 -0
  32. data/specs/gzipreader/eof_spec.rb +23 -0
  33. data/specs/gzipreader/getc_spec.rb +2 -0
  34. data/specs/gzipreader/gets_spec.rb +2 -0
  35. data/specs/gzipreader/lineno_spec.rb +2 -0
  36. data/specs/gzipreader/new_spec.rb +2 -0
  37. data/specs/gzipreader/open_spec.rb +2 -0
  38. data/specs/gzipreader/pos_spec.rb +27 -0
  39. data/specs/gzipreader/read_spec.rb +29 -0
  40. data/specs/gzipreader/readchar_spec.rb +2 -0
  41. data/specs/gzipreader/readline_spec.rb +2 -0
  42. data/specs/gzipreader/readlines_spec.rb +2 -0
  43. data/specs/gzipreader/rewind_spec.rb +34 -0
  44. data/specs/gzipreader/tell_spec.rb +2 -0
  45. data/specs/gzipreader/ungetc_spec.rb +2 -0
  46. data/specs/gzipreader/unused_spec.rb +2 -0
  47. data/specs/gzipwriter/append_spec.rb +2 -0
  48. data/specs/gzipwriter/comment_spec.rb +2 -0
  49. data/specs/gzipwriter/flush_spec.rb +2 -0
  50. data/specs/gzipwriter/mtime_spec.rb +42 -0
  51. data/specs/gzipwriter/new_spec.rb +2 -0
  52. data/specs/gzipwriter/open_spec.rb +2 -0
  53. data/specs/gzipwriter/orig_name_spec.rb +2 -0
  54. data/specs/gzipwriter/pos_spec.rb +2 -0
  55. data/specs/gzipwriter/print_spec.rb +2 -0
  56. data/specs/gzipwriter/printf_spec.rb +2 -0
  57. data/specs/gzipwriter/putc_spec.rb +2 -0
  58. data/specs/gzipwriter/puts_spec.rb +2 -0
  59. data/specs/gzipwriter/tell_spec.rb +2 -0
  60. data/specs/gzipwriter/write_spec.rb +23 -0
  61. data/specs/inflate/append_spec.rb +12 -0
  62. data/specs/inflate/inflate_spec.rb +49 -0
  63. data/specs/inflate/new_spec.rb +2 -0
  64. data/specs/inflate/set_dictionary_spec.rb +20 -0
  65. data/specs/inflate/sync_point_spec.rb +2 -0
  66. data/specs/inflate/sync_spec.rb +2 -0
  67. data/specs/zlib_version_spec.rb +2 -0
  68. data/specs/zstream/adler_spec.rb +1 -0
  69. data/specs/zstream/avail_in_spec.rb +1 -0
  70. data/specs/zstream/avail_out_spec.rb +1 -0
  71. data/specs/zstream/close_spec.rb +2 -0
  72. data/specs/zstream/closed_spec.rb +2 -0
  73. data/specs/zstream/data_type_spec.rb +2 -0
  74. data/specs/zstream/end_spec.rb +2 -0
  75. data/specs/zstream/ended_spec.rb +2 -0
  76. data/specs/zstream/finish_spec.rb +2 -0
  77. data/specs/zstream/finished_spec.rb +2 -0
  78. data/specs/zstream/flush_next_in_spec.rb +2 -0
  79. data/specs/zstream/flush_next_out_spec.rb +16 -0
  80. data/specs/zstream/reset_spec.rb +2 -0
  81. data/specs/zstream/stream_end_spec.rb +2 -0
  82. data/specs/zstream/total_in_spec.rb +2 -0
  83. data/specs/zstream/total_out_spec.rb +2 -0
  84. metadata +137 -0
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,34 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe "GzipReader#rewind" do
7
+
8
+ before :each do
9
+ @data = '12345abcde'
10
+ @zip = "\037\213\b\000,\334\321G\000\00334261MLJNI\005\000\235\005\000$\n\000\000\000"
11
+ @io = StringIO.new @zip
12
+ end
13
+
14
+ it "resets the position of the file pointer" do
15
+ gz = Zlib::GzipReader.new @io
16
+ gz.read
17
+ gz.pos.should == @data.length
18
+
19
+ gz.rewind
20
+ gz.pos.should == 0
21
+ end
22
+
23
+ it "invokes seek method on the associated IO object" do
24
+ # first, prepare the mock object:
25
+ (obj = mock("io")).should_receive(:get_io).any_number_of_times.and_return(@io)
26
+ def obj.read(arg); get_io.read(args); end
27
+ def obj.read; get_io.read; end
28
+ obj.should_receive(:seek).and_return(0)
29
+
30
+ gz = Zlib::GzipReader.new(obj)
31
+ gz.rewind()
32
+ gz.pos.should == 0
33
+ end
34
+ end
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,42 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+
6
+ describe 'Zlib::GzipWriter#mtime=' do
7
+ before :each do
8
+ @io = StringIO.new
9
+ end
10
+
11
+ it 'sets mtime using Integer' do
12
+ Zlib::GzipWriter.wrap @io do |gzio|
13
+ gzio.mtime = 1
14
+
15
+ gzio.mtime.should == Time.at(1)
16
+ end
17
+
18
+ @io.string[4, 4].should == "\001\0\0\0"
19
+ end
20
+
21
+ # ruby_bug '253', '1.9.0' do
22
+ it 'sets mtime using Time' do
23
+ Zlib::GzipWriter.wrap @io do |gzio|
24
+ gzio.mtime = Time.at 1
25
+
26
+ gzio.mtime.should == Time.at(1)
27
+ end
28
+
29
+ @io.string[4, 4].should == "\001\0\0\0"
30
+ end
31
+ #end
32
+
33
+ it 'raises if the header was written' do
34
+ Zlib::GzipWriter.wrap @io do |gzio|
35
+ gzio.write ''
36
+
37
+ lambda { gzio.mtime = nil }.should \
38
+ raise_error(Zlib::GzipFile::Error, 'header is already written')
39
+ end
40
+ end
41
+ end
42
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,23 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+ require 'stringio'
4
+
5
+ describe "GzipWriter#write" do
6
+
7
+ before :each do
8
+ @data = '12345abcde'
9
+ @zip = "\037\213\b\000,\334\321G\000\00334261MLJNI\005\000\235\005\000$\n\000\000\000"
10
+ @io = StringIO.new
11
+ end
12
+
13
+ it "writes some compressed data" do
14
+ Zlib::GzipWriter.wrap @io do |gzio|
15
+ gzio.write @data
16
+ end
17
+
18
+ # skip gzip header for now
19
+ @io.string[10..-1].should == @zip[10..-1]
20
+ end
21
+
22
+ end
23
+
@@ -0,0 +1,12 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::Inflate#<<' do
5
+ it 'appends data to the input stream' do
6
+ zs = Zlib::Inflate.new
7
+ zs << "x\234K\313\317\a\000\002\202\001E"
8
+
9
+ zs.finish.should == 'foo'
10
+ end
11
+ end
12
+
@@ -0,0 +1,49 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::Inflate#inflate' do
5
+
6
+ before :each do
7
+ @inflator = Zlib::Inflate.new
8
+ end
9
+
10
+ it 'inflates some data' do
11
+ data = "x\234c`\200\001\000\000\n\000\001"
12
+
13
+ unzipped = @inflator.inflate data
14
+ @inflator.finish
15
+
16
+ unzipped.should == "\000" * 10
17
+ end
18
+
19
+ it 'inflates lots of data' do
20
+ data = "x\234\355\301\001\001\000\000\000\200\220\376\257\356\b\n#{"\000" * 31}\030\200\000\000\001"
21
+
22
+ unzipped = @inflator.inflate data
23
+ @inflator.finish
24
+
25
+ unzipped.should == "\000" * 32 * 1024
26
+ end
27
+
28
+ end
29
+
30
+ describe 'Zlib::Inflate::inflate' do
31
+
32
+ it 'inflates some data' do
33
+ data = "x\234c`\200\001\000\000\n\000\001"
34
+
35
+ unzipped = Zlib::Inflate.inflate data
36
+
37
+ unzipped.should == "\000" * 10
38
+ end
39
+
40
+ it 'inflates lots of data' do
41
+ data = "x\234\355\301\001\001\000\000\000\200\220\376\257\356\b\n#{"\000" * 31}\030\200\000\000\001"
42
+
43
+ zipped = Zlib::Inflate.inflate data
44
+
45
+ zipped.should == "\000" * 32 * 1024
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,20 @@
1
+ #require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::Inflate#set_dictionary' do
5
+ it 'sets the inflate dictionary' do
6
+ deflated = "x\273\024\341\003\313KLJNIMK\317\310\314\002\000\025\206\003\370"
7
+
8
+ i = Zlib::Inflate.new
9
+
10
+ begin
11
+ i << deflated
12
+ raise Exception.new 'Zlib::NeedDict not raised'
13
+ rescue Zlib::NeedDict
14
+ i.set_dictionary 'aaaaaaaaaa'
15
+ end
16
+
17
+ i.finish.should == 'abcdefghij'
18
+ end
19
+ end
20
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1 @@
1
+ #require File.dirname(__FILE__) + '/../../../spec_helper'
@@ -0,0 +1 @@
1
+ #require File.dirname(__FILE__) + '/../../../spec_helper'
@@ -0,0 +1 @@
1
+ #require File.dirname(__FILE__) + '/../../../spec_helper'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,16 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
3
+
4
+ describe 'Zlib::ZStream#flush_next_out' do
5
+
6
+ it 'flushes the stream and flushes the output buffer' do
7
+ zs = Zlib::Inflate.new
8
+ zs << "x\234K\313\317\a\000\002\202\001E"
9
+
10
+ zs.flush_next_out.should == 'foo'
11
+ zs.finished?.should == true
12
+ zs.flush_next_out.should == ''
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
@@ -0,0 +1,2 @@
1
+ #require File.dirname(__FILE__) + '/../../spec_helper'
2
+ require '../lib/zliby'
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Zliby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Michael Letterle
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-31 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: theprokrammer@prokrams.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - CHANGES
25
+ - LICENSE
26
+ - TODO
27
+ files:
28
+ - bin/zliby.rb
29
+ - lib/zliby.rb
30
+ - README
31
+ - CHANGES
32
+ - LICENSE
33
+ - TODO
34
+ has_rdoc: true
35
+ homepage: http://zliby.rubyforge.org/
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project: zliby
56
+ rubygems_version: 1.0.1
57
+ signing_key:
58
+ specification_version: 2
59
+ summary: Compression Library In Pure Ruby
60
+ test_files:
61
+ - specs/adler32_spec.rb
62
+ - specs/crc32_spec.rb
63
+ - specs/crc_table_spec.rb
64
+ - specs/deflate/append_spec.rb
65
+ - specs/deflate/deflate_spec.rb
66
+ - specs/deflate/flush_spec.rb
67
+ - specs/deflate/initialize_copy_spec.rb
68
+ - specs/deflate/new_spec.rb
69
+ - specs/deflate/params_spec.rb
70
+ - specs/deflate/set_dictionary_spec.rb
71
+ - specs/gzipfile/closed_spec.rb
72
+ - specs/gzipfile/close_spec.rb
73
+ - specs/gzipfile/comment_spec.rb
74
+ - specs/gzipfile/crc_spec.rb
75
+ - specs/gzipfile/finish_spec.rb
76
+ - specs/gzipfile/level_spec.rb
77
+ - specs/gzipfile/mtime_spec.rb
78
+ - specs/gzipfile/orig_name_spec.rb
79
+ - specs/gzipfile/os_code_spec.rb
80
+ - specs/gzipfile/sync_spec.rb
81
+ - specs/gzipfile/to_io_spec.rb
82
+ - specs/gzipfile/wrap_spec.rb
83
+ - specs/gzipreader/each_byte_spec.rb
84
+ - specs/gzipreader/each_line_spec.rb
85
+ - specs/gzipreader/each_spec.rb
86
+ - specs/gzipreader/eof_spec.rb
87
+ - specs/gzipreader/getc_spec.rb
88
+ - specs/gzipreader/gets_spec.rb
89
+ - specs/gzipreader/lineno_spec.rb
90
+ - specs/gzipreader/new_spec.rb
91
+ - specs/gzipreader/open_spec.rb
92
+ - specs/gzipreader/pos_spec.rb
93
+ - specs/gzipreader/readchar_spec.rb
94
+ - specs/gzipreader/readlines_spec.rb
95
+ - specs/gzipreader/readline_spec.rb
96
+ - specs/gzipreader/read_spec.rb
97
+ - specs/gzipreader/rewind_spec.rb
98
+ - specs/gzipreader/tell_spec.rb
99
+ - specs/gzipreader/ungetc_spec.rb
100
+ - specs/gzipreader/unused_spec.rb
101
+ - specs/gzipwriter/append_spec.rb
102
+ - specs/gzipwriter/comment_spec.rb
103
+ - specs/gzipwriter/flush_spec.rb
104
+ - specs/gzipwriter/mtime_spec.rb
105
+ - specs/gzipwriter/new_spec.rb
106
+ - specs/gzipwriter/open_spec.rb
107
+ - specs/gzipwriter/orig_name_spec.rb
108
+ - specs/gzipwriter/pos_spec.rb
109
+ - specs/gzipwriter/printf_spec.rb
110
+ - specs/gzipwriter/print_spec.rb
111
+ - specs/gzipwriter/putc_spec.rb
112
+ - specs/gzipwriter/puts_spec.rb
113
+ - specs/gzipwriter/tell_spec.rb
114
+ - specs/gzipwriter/write_spec.rb
115
+ - specs/inflate/append_spec.rb
116
+ - specs/inflate/inflate_spec.rb
117
+ - specs/inflate/new_spec.rb
118
+ - specs/inflate/set_dictionary_spec.rb
119
+ - specs/inflate/sync_point_spec.rb
120
+ - specs/inflate/sync_spec.rb
121
+ - specs/zlib_version_spec.rb
122
+ - specs/zstream/adler_spec.rb
123
+ - specs/zstream/avail_in_spec.rb
124
+ - specs/zstream/avail_out_spec.rb
125
+ - specs/zstream/closed_spec.rb
126
+ - specs/zstream/close_spec.rb
127
+ - specs/zstream/data_type_spec.rb
128
+ - specs/zstream/ended_spec.rb
129
+ - specs/zstream/end_spec.rb
130
+ - specs/zstream/finished_spec.rb
131
+ - specs/zstream/finish_spec.rb
132
+ - specs/zstream/flush_next_in_spec.rb
133
+ - specs/zstream/flush_next_out_spec.rb
134
+ - specs/zstream/reset_spec.rb
135
+ - specs/zstream/stream_end_spec.rb
136
+ - specs/zstream/total_in_spec.rb
137
+ - specs/zstream/total_out_spec.rb