-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3e1583
commit cbd2cf2
Showing
3 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Xlsxtream | ||
VERSION = '1.3.2'.freeze | ||
VERSION = '2.0.0'.freeze | ||
end |