zippy 0.1.0 → 0.2.0
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/lib/zippy.rb +7 -5
- metadata +31 -41
- data/rails/README +0 -18
- data/rails/init.rb +0 -23
data/lib/zippy.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#encoding: utf-8
|
1
2
|
require 'zip/zip'
|
2
3
|
|
3
4
|
class Zippy
|
@@ -7,16 +8,17 @@ class Zippy
|
|
7
8
|
|
8
9
|
|
9
10
|
#Make an archive
|
10
|
-
#
|
11
|
+
#Takes a hash of options and entries. Options use symbols and entries use strings.
|
12
|
+
#The :filename option is optional; if none is provided, a generated, temporary
|
11
13
|
#filename will be used.
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#be added after initialization
|
14
|
+
#
|
15
|
+
#Example: Zippy.new(:filename => 'my.zip', 'README' => 'Thank you for reading me.')
|
15
16
|
def initialize(entries_and_options={})
|
16
17
|
entries_and_options.each{|k,v| send("#{k}=", v) if respond_to?("#{k}=") && k.is_a?(Symbol) }
|
17
18
|
without_autocommit do
|
18
19
|
entries_and_options.each{|k,v| self[k] = v if k.is_a?(String) }
|
19
20
|
end
|
21
|
+
zipfile.commit if autocommit?
|
20
22
|
yield self if block_given?
|
21
23
|
end
|
22
24
|
|
@@ -103,7 +105,7 @@ class Zippy
|
|
103
105
|
def data
|
104
106
|
return nil if empty?
|
105
107
|
zipfile.commit
|
106
|
-
File.read(filename)
|
108
|
+
File.read(filename, :encoding => Encoding::BINARY)
|
107
109
|
end
|
108
110
|
|
109
111
|
|
metadata
CHANGED
@@ -1,67 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: zippy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Tore Darell
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-03-15 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: rubyzip
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Version
|
16
|
+
requirement: &2152049820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
23
21
|
version: 0.9.1
|
24
|
-
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2152049820
|
25
25
|
description: Zippy reads and writes zip files
|
26
26
|
email: toredarell@gmail.com
|
27
27
|
executables: []
|
28
|
-
|
29
28
|
extensions: []
|
30
|
-
|
31
29
|
extra_rdoc_files: []
|
32
|
-
|
33
|
-
files:
|
30
|
+
files:
|
34
31
|
- lib/zippy.rb
|
35
32
|
- README
|
36
|
-
- rails/init.rb
|
37
|
-
- rails/README
|
38
|
-
has_rdoc: true
|
39
33
|
homepage: http://github.com/toretore/zippy
|
40
34
|
licenses: []
|
41
|
-
|
42
35
|
post_install_message:
|
43
36
|
rdoc_options: []
|
44
|
-
|
45
|
-
require_paths:
|
37
|
+
require_paths:
|
46
38
|
- lib
|
47
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
59
51
|
requirements: []
|
60
|
-
|
61
52
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.
|
53
|
+
rubygems_version: 1.8.10
|
63
54
|
signing_key:
|
64
55
|
specification_version: 3
|
65
56
|
summary: rubyzip for dummies
|
66
57
|
test_files: []
|
67
|
-
|
data/rails/README
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
This plugin adds a template handler for the extension "zipper", so you
|
2
|
-
could for example have a view show.zip.zipper which returns a zip file.
|
3
|
-
The view file is evaluated as Ruby, inside a Zippy.new{|zip|} block.
|
4
|
-
|
5
|
-
Example controller:
|
6
|
-
def show
|
7
|
-
@gallery = Gallery.find(params[:id])
|
8
|
-
respond_to do |format|
|
9
|
-
format.html
|
10
|
-
format.zip
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Example view:
|
15
|
-
zip['description.txt'] = @gallery.description
|
16
|
-
@gallery.photos.each do |photo|
|
17
|
-
zip["photo_#{photo.id}.png"] = File.open(photo.url)
|
18
|
-
end
|
data/rails/init.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'zippy'
|
2
|
-
|
3
|
-
Mime::Type.register 'application/zip', :zip
|
4
|
-
|
5
|
-
module ::ActionView
|
6
|
-
module TemplateHandlers
|
7
|
-
class Zipper < TemplateHandler
|
8
|
-
include Compilable
|
9
|
-
|
10
|
-
def compile(template)
|
11
|
-
"Zippy.new do |zip|" +
|
12
|
-
(template.respond_to?(:source) ? template.source : template) +
|
13
|
-
"end.data"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
if defined? ::ActionView::Template and ::ActionView::Template.respond_to? :register_template_handler
|
20
|
-
::ActionView::Template
|
21
|
-
else
|
22
|
-
::ActionView::Base
|
23
|
-
end.register_template_handler(:zipper, ::ActionView::TemplateHandlers::Zipper)
|