diff --git a/CHANGELOG.md b/CHANGELOG.md index 92751b8..76d6f9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2.0.0 (2017-10-31) + +- Replace RubyZip with ZipTricks as default compressor (#16) +- Drop support for Ruby < 2.1.0 (required for zip\_tricks gem) +- Deprecate :io\_wrapper option, you can now pass wrapper instances (#20) + ## 1.3.2 (2017-10-30) - Fix circular require in workbook diff --git a/lib/xlsxtream/io/zip_tricks_fibers.rb b/lib/xlsxtream/io/zip_tricks_fibers.rb new file mode 100644 index 0000000..63fa6bb --- /dev/null +++ b/lib/xlsxtream/io/zip_tricks_fibers.rb @@ -0,0 +1,36 @@ +require "zip_tricks" + +module Xlsxtream + module IO + class ZipTricksFibers + def initialize(body) + @streamer = ::ZipTricks::Streamer.new(body) + @wf = nil + end + + def <<(data) + @wf.resume(data) + self + end + + def add_file(path) + @wf.resume(:__close__) if @wf + + @wf = Fiber.new do | bytes_or_close_sym | + @streamer.write_deflated_file(path) do |write_sink| + loop do + break if bytes_or_close_sym == :__close__ + write_sink << bytes_or_close_sym + bytes_or_close_sym = Fiber.yield + end + end + end + end + + def close + @wf.resume(:__close__) if @wf + @streamer.close + end + end + end +end diff --git a/lib/xlsxtream/version.rb b/lib/xlsxtream/version.rb index 36401c8..7a19f01 100644 --- a/lib/xlsxtream/version.rb +++ b/lib/xlsxtream/version.rb @@ -1,3 +1,3 @@ module Xlsxtream - VERSION = '1.3.2'.freeze + VERSION = '2.0.0'.freeze end