zipstream 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +15 -9
- data/VERSION +1 -1
- data/lib/zipstream/body.rb +1 -1
- data/lib/zipstream/fiber.rb +6 -6
- metadata +4 -4
data/README.md
CHANGED
@@ -4,17 +4,21 @@ Create zip files to a stream.
|
|
4
4
|
|
5
5
|
Integration with Ruby on Rails means you can create a file, `index.zipstream`, which is a ruby file with a zip object:
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
```ruby
|
8
|
+
@entries.each do |entry|
|
9
|
+
zip.write "entry-#{entry.id}.txt", entry.to_s
|
10
|
+
end
|
11
|
+
```
|
10
12
|
|
11
13
|
Which will happily implicitly render from:
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
```ruby
|
16
|
+
class EntriesController
|
17
|
+
def index
|
18
|
+
@entries = Entry.all
|
19
|
+
end
|
20
|
+
end
|
21
|
+
```
|
18
22
|
|
19
23
|
Giving you a zip file when rendered. More to come!
|
20
24
|
|
@@ -24,9 +28,11 @@ Keep in mind that this will use one of your workers/threads/processes until the
|
|
24
28
|
|
25
29
|
Tested with Rails 3.1 on REE 1.8.7 and MRI 1.9.3. Specs coming soon (tm).
|
26
30
|
|
31
|
+
Large files are not yet handled efficiently. Coming soon!
|
32
|
+
|
27
33
|
## Thanks
|
28
34
|
|
29
|
-
Inspired by http://pablotron.org/software/zipstream-php/
|
35
|
+
Inspired by Rails Builder templates and http://pablotron.org/software/zipstream-php/
|
30
36
|
|
31
37
|
## License
|
32
38
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/zipstream/body.rb
CHANGED
data/lib/zipstream/fiber.rb
CHANGED
@@ -13,29 +13,29 @@ else
|
|
13
13
|
@body = lambda &block
|
14
14
|
end
|
15
15
|
|
16
|
-
def resume
|
16
|
+
def resume arg
|
17
17
|
@@fibers.push self
|
18
18
|
# jumping into fiber
|
19
|
-
jump
|
19
|
+
jump arg
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.current
|
23
23
|
@@fibers.last
|
24
24
|
end
|
25
25
|
|
26
|
-
def self.yield
|
26
|
+
def self.yield arg
|
27
27
|
if fiber = @@fibers.pop
|
28
28
|
# jumping out of fiber
|
29
|
-
fiber.send :jump,
|
29
|
+
fiber.send :jump, arg
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def jump
|
35
|
+
def jump arg
|
36
36
|
callcc do |continuation|
|
37
37
|
destination, @body = @body, continuation
|
38
|
-
destination.call
|
38
|
+
destination.call arg
|
39
39
|
@@fibers.pop
|
40
40
|
# return from the last 'resume'
|
41
41
|
@body.call
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zipstream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70130652353800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.7.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70130652353800
|
25
25
|
description:
|
26
26
|
email: sj26@sj26.com
|
27
27
|
executables: []
|