kmz_compressor 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = KmzCompressor
2
+
3
+ Rack Middleware which retrieves KML from Rails and produces KMZ for the client.
4
+
5
+ Just add gem 'kmz_compressor' to your Gemfile and then request kmz for any action that accepts requests for kml.
@@ -0,0 +1,25 @@
1
+ module KMZCompressor
2
+ class Middleware
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ req = Rack::Request.new(env)
9
+
10
+ if req.path_info.end_with? '.kmz'
11
+ req.path_info = req.path_info.gsub(/kmz\Z/, 'kml')
12
+
13
+ @status, @headers, @response = @app.call(env)
14
+
15
+ [@status, @headers, self]
16
+ else
17
+ @app.call(env)
18
+ end
19
+ end
20
+
21
+ def each(&block)
22
+ block.call(Zippy.new {|zip| zip['doc.kml'] = @response.body }.data)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ require 'zippy'
2
+ require 'kmz_compressor/middleware'
3
+
4
+ module KMZCompressor
5
+ class Railtie < Rails::Railtie
6
+ initializer "kmz_compressor.init" do |app|
7
+ app.config.middleware.use "KMZCompressor::Middleware"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module KMZCompressor
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1 @@
1
+ require 'kmz_compressor/railtie' if defined?(Rails)
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kmz_compressor
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryan Wallace
9
+ - Nicholas Jakobsen
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-01-04 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ requirement: &70189510020580 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 3.1.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70189510020580
26
+ - !ruby/object:Gem::Dependency
27
+ name: zippy
28
+ requirement: &70189510019900 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *70189510019900
37
+ description: Rack Middleware which retrieves KML from Rails and produces KMZ for the
38
+ client.
39
+ email:
40
+ - contact@culturecode.ca
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - lib/kmz_compressor/middleware.rb
46
+ - lib/kmz_compressor/railtie.rb
47
+ - lib/kmz_compressor/version.rb
48
+ - lib/kmz_compressor.rb
49
+ - MIT-LICENSE
50
+ - README.rdoc
51
+ homepage: http://www.culturecode.ca/
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 1.8.10
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Rack Middleware which retrieves KML from Rails and produces KMZ for the client.
75
+ test_files: []