appengine-rack 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/lib/appengine-rack.rb +51 -0
- metadata +32 -9
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ EOF
|
|
10
10
|
|
11
11
|
spec = Gem::Specification.new do |s|
|
12
12
|
s.name = "appengine-rack"
|
13
|
-
s.version = "0.0.
|
13
|
+
s.version = "0.0.7"
|
14
14
|
s.author = "Ryan Brown"
|
15
15
|
s.email = "ribrdb@google.com"
|
16
16
|
s.homepage = "http://code.google.com/p/appengine-jruby"
|
@@ -22,6 +22,7 @@ spec = Gem::Specification.new do |s|
|
|
22
22
|
s.files = %w(LICENSE Rakefile) + Dir.glob("lib/**/*")
|
23
23
|
|
24
24
|
s.add_dependency('rack')
|
25
|
+
s.add_dependency('jruby-rack', '0.9.7')
|
25
26
|
end
|
26
27
|
|
27
28
|
task :default => :spec
|
data/lib/appengine-rack.rb
CHANGED
@@ -107,7 +107,58 @@ module AppEngine
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
110
|
+
|
111
|
+
# Split loading requests into 3 parts
|
112
|
+
#
|
113
|
+
# deferred_dispatcher = AppEngine::Rack::DeferredDispatcher.new(
|
114
|
+
# :require => File.expand_path('../config/environment', __FILE__),
|
115
|
+
# :dispatch => 'ActionController::Dispatcher')
|
116
|
+
#
|
117
|
+
# map '/admin' do
|
118
|
+
# use AppEngine::Rack::AdminRequired
|
119
|
+
# run deferred_dispatcher
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
# map '/' do
|
123
|
+
# use AppEngine::Rack::LoginRequired
|
124
|
+
# run deferred_dispatcher
|
125
|
+
# end
|
126
|
+
|
127
|
+
class DeferredDispatcher
|
128
|
+
def initialize args
|
129
|
+
@args = args
|
130
|
+
end
|
131
|
+
|
132
|
+
def call env
|
133
|
+
if @runtime.nil?
|
134
|
+
@runtime = true
|
135
|
+
# 1: redirect with runtime and jruby-rack loaded
|
136
|
+
redirect_or_error(env)
|
137
|
+
elsif @rack_app.nil?
|
138
|
+
require @args[:require]
|
139
|
+
@rack_app = Object.module_eval(@args[:dispatch]).new
|
140
|
+
# 2: redirect with framework required & dispatched
|
141
|
+
redirect_or_error(env)
|
142
|
+
else
|
143
|
+
# 3: process all other requests
|
144
|
+
@rack_app.call(env)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def redirect_or_error(env)
|
149
|
+
if env['REQUEST_METHOD'].eql?('GET')
|
150
|
+
redir_url = env['REQUEST_URI'] +
|
151
|
+
(env['QUERY_STRING'].eql?('') ? '?' : '&') + Time.now.to_i.to_s
|
152
|
+
res = ::Rack::Response.new('*', 302)
|
153
|
+
res['Location'] = redir_url
|
154
|
+
res.finish
|
155
|
+
else
|
156
|
+
::Rack::Response.new('Service Unavailable', 503).finish
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
110
160
|
|
161
|
+
|
111
162
|
class RackApplication
|
112
163
|
attr_accessor :application, :inbound_services, :precompilation_enabled
|
113
164
|
attr_reader :version, :static_files, :resource_files, :public_root
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appengine-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
version: 0.0.7
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Ryan Brown
|
@@ -9,19 +14,35 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-04-07 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rack
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: jruby-rack
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
- 9
|
42
|
+
- 7
|
43
|
+
version: 0.9.7
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
25
46
|
description: |
|
26
47
|
Commom dependencies for configuring an App Engine application via Rack.
|
27
48
|
|
@@ -50,18 +71,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
71
|
requirements:
|
51
72
|
- - ">="
|
52
73
|
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
53
76
|
version: "0"
|
54
|
-
version:
|
55
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
78
|
requirements:
|
57
79
|
- - ">="
|
58
80
|
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
59
83
|
version: "0"
|
60
|
-
version:
|
61
84
|
requirements: []
|
62
85
|
|
63
86
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.3.
|
87
|
+
rubygems_version: 1.3.6
|
65
88
|
signing_key:
|
66
89
|
specification_version: 3
|
67
90
|
summary: Commom dependencies for configuring an App Engine application via Rack.
|