QuickLZ/Ruby

http://storehouse.sakura.ne.jp/viewvc/viewvc.cgi/qlzruby/?root=svn
とりあえず。

require 'qlzruby'
require 'open-uri'
require 'stringio'

puts QuickLZ::VERSION

source = <<-EOS
じゅげむ じゅげむ
ごこうのすりきり
ぱいぽ ぱいぽ
EOS

# block
puts "uncompress size: #{source.length}"
comp_data = QuickLZ.block_compress(source)
puts "compress size: #{comp_data.length}"

decomp_data = QuickLZ.block_decompress(comp_data)
puts "decompress size: #{decomp_data.length}"
puts "decompress success?: #{source == decomp_data}"

puts

# stream
source = open('http://d.hatena.ne.jp/winebarrel/') {|f| f.read }
source = StringIO.new(source)

puts "uncompress size: #{source.length}"
comp_data = StringIO.new
QuickLZ.stream_compress(source, comp_data)
puts "compress size: #{comp_data.length}"

comp_data.seek(0)
decomp_data = StringIO.new
QuickLZ.stream_decompress(comp_data, decomp_data)
puts "decompress size: #{decomp_data.length}"
puts "decompress success?: #{source.string == decomp_data.string}"