appengine-rack 0.0.10 → 0.0.11.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ EOF
13
13
 
14
14
  spec = Gem::Specification.new do |s|
15
15
  s.name = "appengine-rack"
16
- s.version = "0.0.10"
16
+ s.version = "0.0.11.pre"
17
17
  s.author = "Ryan Brown"
18
18
  s.email = "ribrdb@google.com"
19
19
  s.homepage = "http://code.google.com/p/appengine-jruby"
Binary file
@@ -23,112 +23,20 @@ begin
23
23
  rescue Exception
24
24
  end
25
25
 
26
- class ::Rack::Builder
27
-
28
- def skip_rack_servlet
29
- @skip_defaults = true
30
- end
31
-
32
- def mime_mapping(mapping)
33
- @mime_mapping = mapping
34
- end
35
-
36
- end
37
-
38
26
  module AppEngine
39
27
  module Rack
40
- ROOT = File.expand_path(File.dirname(__FILE__))
41
-
42
- class Resources
43
- COMMON_EXCLUDES = {
44
- :rails_excludes => %w(README Rakefile db/** doc/** bin/**
45
- log/** script/** test/** tmp/**),
46
- :merb_excludes => %w(Rakefile autotest/** doc/** bin/**
47
- gems/** spec/**) }
48
-
49
- def initialize
50
- @includes = []
51
- @excludes = []
52
- end
53
-
54
- def include(glob, expiration=nil)
55
- if glob.is_a? Array
56
- glob.each do |g|
57
- @includes << [g, expiration]
58
- end
59
- else
60
- @includes << [glob, expiration]
61
- end
62
- end
63
-
64
- def exclude(glob)
65
- if glob.is_a? Array
66
- @excludes += glob
67
- elsif glob.is_a? Symbol
68
- @excludes += COMMON_EXCLUDES[glob]
69
- else
70
- @excludes << glob
71
- end
72
- end
73
-
74
- def append_to(xml, type)
75
- resources = xml.add_element(type)
76
- @includes.each do |path, expiration|
77
- element = resources.add_element('include')
78
- element.add_attribute('path', path)
79
- element.add_attribute('expiration', expiration) if expiration
80
- end
81
- @excludes.each do |path|
82
- resources.add_element('exclude').add_attribute('path', path)
83
- end
84
- end
85
- end
86
-
87
- class PropertyMap < Hash
88
- def append_to(xml)
89
- unless empty?
90
- sys = xml.add_element('system-properties')
91
- each do |name, value|
92
- sys.add_element('property').
93
- add_attributes( { "name" => name, "value" => value.to_s } )
94
- end
95
- end
96
- end
97
- end
98
-
99
- class EnvVarMap < Hash
100
- def append_to(xml)
101
- unless empty?
102
- env = xml.add_element('env-variables')
103
- each do |name, value|
104
- env.add_element('env-var').
105
- add_attributes( { "name" => name, "value" => value.to_s } )
106
- end
107
- end
108
- end
109
- end
110
-
111
28
  # Split loading requests into 3 parts
112
29
  #
113
30
  # deferred_dispatcher = AppEngine::Rack::DeferredDispatcher.new(
114
31
  # :require => File.expand_path('../config/environment', __FILE__),
115
32
  # :dispatch => 'ActionController::Dispatcher')
116
- #
117
- # map '/admin' do
118
- # use AppEngine::Rack::AdminRequired
119
- # run deferred_dispatcher
120
- # end
121
33
  #
122
- # map '/' do
123
- # use AppEngine::Rack::LoginRequired
124
- # run deferred_dispatcher
125
- # end
126
-
34
+ # run deferred_dispatcher
127
35
  class DeferredDispatcher
128
36
  def initialize args
129
37
  @args = args
130
38
  end
131
-
39
+
132
40
  def call env
133
41
  if @runtime.nil?
134
42
  @runtime = true
@@ -144,7 +52,7 @@ module AppEngine
144
52
  @rack_app.call(env)
145
53
  end
146
54
  end
147
-
55
+
148
56
  def redirect_or_error(env)
149
57
  if env['REQUEST_METHOD'].eql?('GET')
150
58
  redir_url = env['REQUEST_URI'] +
@@ -157,143 +65,8 @@ module AppEngine
157
65
  end
158
66
  end
159
67
  end
160
-
161
-
162
- class RackApplication
163
- attr_accessor :application, :inbound_services, :precompilation_enabled
164
- attr_reader :version, :static_files, :resource_files, :public_root
165
- attr_reader :system_properties, :environment_variables
166
- attr_writer :ssl_enabled, :sessions_enabled
167
-
168
- def initialize
169
- @version = '1'
170
- @system_properties = PropertyMap[ 'os.arch' => '',
171
- 'jruby.jit.threshold' => 99,
172
- 'jruby.native.enabled' => false,
173
- 'jruby.management.enabled' => false,
174
- 'jruby.rack.input.rewindable' => false ]
175
- @environment_variables = EnvVarMap.new
176
- @static_files = Resources.new
177
- @resource_files = Resources.new
178
- @public_root = '/public'
179
- @inbound_services = []
180
- end
181
-
182
- alias id application
183
-
184
- def sessions_enabled?
185
- @sessions_enabled
186
- end
187
-
188
- def ssl_enabled?
189
- @ssl_enabled
190
- end
191
-
192
- def precompilation_enabled?
193
- @precompilation_enabled
194
- end
195
-
196
- def public_root=(root)
197
- root = "/#{root}".squeeze '/'
198
- root = nil if root.eql? '/'
199
- @public_root = root
200
- end
201
-
202
- def version=(version)
203
- @version = version.to_s
204
- end
205
-
206
- def configure(options={})
207
- [:system_properties, :environment_variables].each do |key|
208
- self.send(key).merge!(options.delete(key)) if options[key]
209
- end
210
- options.each { |k,v| self.send("#{k}=", v) }
211
- end
212
-
213
- def to_xml
214
- require 'rexml/document'
215
-
216
- xml = REXML::Document.new.add_element('appengine-web-app')
217
- xml.add_attribute('xmlns','http://appengine.google.com/ns/1.0')
218
- xml.add_element('application').add_text(application)
219
- xml.add_element('version').add_text(version)
220
- xml.add_element('public-root').add_text(@public_root) if @public_root
221
- static_files.append_to(xml, 'static-files')
222
- resource_files.append_to(xml, 'resource-files')
223
- system_properties.append_to(xml)
224
- environment_variables.append_to(xml)
225
- if sessions_enabled?
226
- xml.add_element('sessions-enabled').add_text('true')
227
- end
228
- if ssl_enabled?
229
- xml.add_element('ssl-enabled').add_text('true')
230
- end
231
- if precompilation_enabled?
232
- xml.add_element('precompilation-enabled').add_text('true')
233
- end
234
- unless @inbound_services.empty?
235
- services = xml.add_element('inbound-services')
236
- @inbound_services.each do |service|
237
- services.add_element('service').add_text(service.to_s)
238
- end
239
- end
240
- return xml
241
- end
242
- end
243
-
244
- class SecurityMiddleware
245
- def self.append_xml(doc, pattern)
246
- security = doc.add_element('security-constraint')
247
- collection = security.add_element('web-resource-collection')
248
- collection.add_element('url-pattern').add_text(pattern)
249
- collection.add_element('url-pattern').add_text(
250
- AppEngine::Rack.make_wildcard(pattern))
251
- yield security
252
- end
253
-
254
- def self.new(app, *args, &block)
255
- app
256
- end
257
-
258
- end
259
-
260
- class AdminRequired < SecurityMiddleware
261
- def self.append_xml(doc, pattern)
262
- super(doc, pattern) do |security|
263
- auth = security.add_element('auth-constraint')
264
- auth.add_element('role-name').add_text('admin')
265
- end
266
- end
267
- end
268
-
269
- class LoginRequired < SecurityMiddleware
270
- def self.append_xml(doc, pattern)
271
- super(doc, pattern) do |security|
272
- auth = security.add_element('auth-constraint')
273
- auth.add_element('role-name').add_text('*')
274
- end
275
- end
276
- end
277
-
278
- class SSLRequired < SecurityMiddleware
279
- def self.append_xml(doc, pattern)
280
- super(doc, pattern) do |security|
281
- udc = security.add_element('user-data-constraint')
282
- udc.add_element('transport-guarantee').add_text('CONFIDENTIAL')
283
- end
284
- end
285
- end
286
68
 
287
69
  class << self
288
- def app
289
- @app ||= RackApplication.new
290
- end
291
-
292
- def configure_app(options={})
293
- @app = RackApplication.new
294
- @app.configure(options)
295
- end
296
-
297
70
  # Deprecated, use ENV['RACK_ENV'] instead
298
71
  def environment
299
72
  if !$servlet_context.nil? and
@@ -303,10 +76,6 @@ module AppEngine
303
76
  'production'
304
77
  end
305
78
  end
306
-
307
- def make_wildcard(pattern)
308
- "#{pattern}/*".squeeze('/')
309
- end
310
79
  end
311
80
  end
312
81
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appengine-rack
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ - pre
10
+ version: 0.0.11.pre
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ryan Brown
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-09 00:00:00 -04:00
18
+ date: 2010-06-09 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -71,7 +72,6 @@ files:
71
72
  - LICENSE
72
73
  - Rakefile
73
74
  - lib/appengine-rack/boot.rb
74
- - lib/appengine-rack/java.rb
75
75
  - lib/appengine-rack.jar
76
76
  - lib/appengine-rack.rb
77
77
  has_rdoc: true
@@ -92,11 +92,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  version: "0"
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - ">"
96
96
  - !ruby/object:Gem::Version
97
97
  segments:
98
- - 0
99
- version: "0"
98
+ - 1
99
+ - 3
100
+ - 1
101
+ version: 1.3.1
100
102
  requirements: []
101
103
 
102
104
  rubyforge_project:
@@ -1,94 +0,0 @@
1
- #!/usr/bin/ruby1.8 -w
2
- #
3
- # Copyright:: Copyright 2009 Google Inc.
4
- # Original Author:: Ryan Brown (mailto:ribrdb@google.com)
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require 'appengine-rack'
19
-
20
- class JavaServlet
21
- def initialize(klass, options={})
22
- @klass = klass.to_s
23
- @name = (options[:name] || klass).to_s
24
- @wildcard = options[:wildcard]
25
- end
26
-
27
- def call(env)
28
- raise RuntimeError, "JavaServlet should be dispatched by web.xml"
29
- end
30
-
31
- def append_xml(doc, pattern)
32
- servlet = doc.add_element('servlet')
33
- servlet.add_element('servlet-name').add_text(@name)
34
- servlet.add_element('servlet-class').add_text(@klass)
35
- map = doc.add_element('servlet-mapping')
36
- map.add_element('servlet-name').add_text(@name)
37
- map.add_element('url-pattern').add_text(pattern.to_s)
38
- if @wildcard
39
- wildcard = doc.add_element('servlet-mapping')
40
- wildcard.add_element('servlet-name').add_text(@name)
41
- wildcard.add_element('url-pattern').add_text(
42
- AppEngine::Rack.make_wildcard(pattern))
43
- end
44
- end
45
- end
46
-
47
- class JavaServletFilter
48
- def self.append_xml(doc, pattern, klass, options={})
49
- name = options[:name] || klass
50
- filter = doc.add_element('filter')
51
- filter.add_element('filter-name').add_text(name.to_s)
52
- filter.add_element('filter-class').add_text(klass.to_s)
53
- unless pattern == '/' && options[:wildcard]
54
- map = doc.add_element('filter-mapping')
55
- map.add_element('filter-name').add_text(name.to_s)
56
- map.add_element('url-pattern').add_text(pattern.to_s)
57
- end
58
- if options[:wildcard]
59
- wildcard = doc.add_element('filter-mapping')
60
- wildcard.add_element('filter-name').add_text(name.to_s)
61
- wildcard.add_element('url-pattern').add_text(
62
- AppEngine::Rack.make_wildcard(pattern))
63
- end
64
- end
65
-
66
- def self.new(app, *args, &block)
67
- app
68
- end
69
- end
70
-
71
- class JavaContextListener
72
- def self.append_xml(doc, pattern, klass)
73
- listener = doc.add_element('listener')
74
- listener.add_element('listener-class').add_text(klass.to_s)
75
- end
76
-
77
- def self.new(app, *args, &block)
78
- app
79
- end
80
- end
81
-
82
- class JavaContextParams
83
- def self.append_xml(doc, pattern, params)
84
- params.each do |name, value|
85
- e = doc.add_element('context-param')
86
- e.add_element('param-name').add_text(name.to_s)
87
- e.add_element('param-value').add_text(value.to_s)
88
- end
89
- end
90
-
91
- def self.new(app, *args, &block)
92
- app
93
- end
94
- end