appengine-tools 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/appengine-tools/boot.rb +3 -1
- data/lib/appengine-tools/boot_app.rb +33 -0
- data/lib/appengine-tools/bundler.rb +20 -24
- data/lib/appengine-tools/web-xml.rb +9 -10
- data/spec/rack_spec.rb +1 -1
- data/spec/web-xml_spec.rb +1 -1
- metadata +4 -3
data/Rakefile
CHANGED
data/lib/appengine-tools/boot.rb
CHANGED
@@ -19,6 +19,8 @@ require 'appengine-sdk'
|
|
19
19
|
module AppEngine
|
20
20
|
module Development
|
21
21
|
|
22
|
+
BOOT_APP_RB = File.join(File.dirname(__FILE__), 'boot_app.rb')
|
23
|
+
|
22
24
|
class << self
|
23
25
|
def boot_jruby(root=nil, options={})
|
24
26
|
unless defined?(JRUBY_VERSION)
|
@@ -53,7 +55,7 @@ module AppEngine
|
|
53
55
|
|
54
56
|
jars = AppEngine::SDK::RUNTIME_JARS
|
55
57
|
|
56
|
-
jruby_args =
|
58
|
+
jruby_args = ["-r#{BOOT_APP_RB}"] + args
|
57
59
|
|
58
60
|
ENV['APPLICATION_ROOT'] = root
|
59
61
|
ENV.delete 'GEM_HOME'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
# Copyright:: Copyright 2009 Google Inc.
|
3
|
+
# Original Author:: Ryan Brown (mailto:ribrdb@google.com)
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'bundler_gems/environment'
|
19
|
+
rescue LoadError
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
# Install stubs and environment
|
24
|
+
require 'appengine-apis/testing'
|
25
|
+
AppEngine::Testing.boot
|
26
|
+
require 'appengine-apis/urlfetch'
|
27
|
+
require 'appengine-apis/tempfile'
|
28
|
+
rescue Exception => e
|
29
|
+
if ENV['VERBOSE']
|
30
|
+
puts e.inspect
|
31
|
+
puts e.backtrace
|
32
|
+
end
|
33
|
+
end
|
@@ -28,7 +28,7 @@ module AppEngine
|
|
28
28
|
|
29
29
|
class Application
|
30
30
|
attr_reader :root
|
31
|
-
|
31
|
+
|
32
32
|
def initialize(root)
|
33
33
|
@root = root
|
34
34
|
end
|
@@ -98,24 +98,20 @@ module AppEngine
|
|
98
98
|
end
|
99
99
|
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
class AppBundler
|
103
103
|
EXISTING_JRUBY = /^(jruby-abridged|appengine-jruby)-.*jar$/
|
104
104
|
EXISTING_APIS = /^appengine-api.*jar$/
|
105
|
-
RACKUP = %q{Dir.chdir('..') if Dir.pwd =~ /WEB-INF$/; } +
|
106
|
-
%q{begin; require 'bundler_gems/environment'; } +
|
107
|
-
%q{rescue LoadError; end;} +
|
108
|
-
%q{eval IO.read('config.ru'), nil, 'config.ru', 1}
|
109
105
|
|
110
106
|
def initialize(root_path)
|
111
107
|
@app = Application.new(root_path)
|
112
108
|
end
|
113
|
-
|
109
|
+
|
114
110
|
def bundle(args=[])
|
115
111
|
bundle_deps(args)
|
116
112
|
convert_config_ru
|
117
113
|
end
|
118
|
-
|
114
|
+
|
119
115
|
def bundle_deps(args=[])
|
120
116
|
confirm_appdir
|
121
117
|
create_webinf
|
@@ -129,11 +125,11 @@ module AppEngine
|
|
129
125
|
gem_bundler = AppEngine::Admin::GemBundler.new(app.root)
|
130
126
|
gem_bundler.bundle(args)
|
131
127
|
end
|
132
|
-
|
128
|
+
|
133
129
|
def app
|
134
130
|
@app
|
135
131
|
end
|
136
|
-
|
132
|
+
|
137
133
|
def confirm_appdir
|
138
134
|
unless File.exists?(app.config_ru) or
|
139
135
|
File.exists?(app.gemfile) or File.exists?(app.webinf)
|
@@ -152,16 +148,16 @@ module AppEngine
|
|
152
148
|
Dir.mkdir(app.webinf_lib) unless File.exists?(app.webinf_lib)
|
153
149
|
Dir.mkdir(app.generation_dir) unless File.exists?(app.generation_dir)
|
154
150
|
end
|
155
|
-
|
151
|
+
|
156
152
|
def create_public
|
157
153
|
return unless defined? JRUBY_VERSION
|
158
154
|
if app.public_root and !File.exists?(app.public_root)
|
159
|
-
Dir.mkdir(app.public_root)
|
155
|
+
Dir.mkdir(app.public_root)
|
160
156
|
end
|
161
157
|
FileUtils.touch(app.favicon_ico) unless File.exists?(app.favicon_ico)
|
162
158
|
FileUtils.touch(app.robots_txt) unless File.exists?(app.robots_txt)
|
163
159
|
end
|
164
|
-
|
160
|
+
|
165
161
|
def convert_config_ru
|
166
162
|
unless File.exists?(app.config_ru)
|
167
163
|
puts "=> Generating rackup"
|
@@ -169,32 +165,32 @@ module AppEngine
|
|
169
165
|
downcase.gsub('_', '-').gsub(/[^-a-z0-9]/, '')
|
170
166
|
stock_rackup = <<EOF
|
171
167
|
require 'appengine-rack'
|
172
|
-
AppEngine::Rack.configure_app(
|
173
|
-
:application => "#{app_id}",
|
168
|
+
AppEngine::Rack.configure_app(
|
169
|
+
:application => "#{app_id}",
|
174
170
|
:precompilation_enabled => true,
|
175
171
|
:version => "1")
|
176
|
-
run lambda { Rack::Response.new("Hello").finish }
|
172
|
+
run lambda { ::Rack::Response.new("Hello").finish }
|
177
173
|
EOF
|
178
174
|
File.open(app.config_ru, 'w') {|f| f.write(stock_rackup) }
|
179
175
|
end
|
180
176
|
generate_xml
|
181
177
|
create_public
|
182
178
|
end
|
183
|
-
|
179
|
+
|
184
180
|
def copy_jruby
|
185
181
|
require 'appengine-jruby-jars'
|
186
182
|
update_jars("JRuby", EXISTING_JRUBY, [AppEngine::JRubyJars.jruby_jar])
|
187
183
|
end
|
188
|
-
|
184
|
+
|
189
185
|
def copy_sdk
|
190
186
|
require 'appengine-sdk'
|
191
187
|
glob = "appengine-api-{1.0-sdk,labs}-*.jar"
|
192
188
|
jars = Dir.glob("#{AppEngine::SDK::SDK_ROOT}/lib/user/#{glob}")
|
193
189
|
update_jars('appengine-sdk', EXISTING_APIS, jars)
|
194
190
|
end
|
195
|
-
|
191
|
+
|
196
192
|
private
|
197
|
-
|
193
|
+
|
198
194
|
def find_jars(regex)
|
199
195
|
Dir.entries(app.webinf_lib).grep(regex) rescue []
|
200
196
|
end
|
@@ -240,7 +236,7 @@ EOF
|
|
240
236
|
yaml = YAML.load_file app.build_status
|
241
237
|
return false unless yaml.is_a? Hash
|
242
238
|
return false unless File.stat(app.config_ru).mtime.eql? yaml[:config_ru]
|
243
|
-
return false unless File.stat(app.web_xml).mtime.eql? yaml[:web_xml]
|
239
|
+
return false unless File.stat(app.web_xml).mtime.eql? yaml[:web_xml]
|
244
240
|
return false unless File.stat(app.aeweb_xml).mtime.eql? yaml[:aeweb_xml]
|
245
241
|
true
|
246
242
|
end
|
@@ -262,7 +258,7 @@ EOF
|
|
262
258
|
end
|
263
259
|
|
264
260
|
# Now configure the basic jruby-rack settings.
|
265
|
-
add_jruby_rack_defaults
|
261
|
+
add_jruby_rack_defaults
|
266
262
|
end
|
267
263
|
open(app.web_xml, 'w') do |webxml|
|
268
264
|
xml = AppEngine::Rack::XmlFormatter.format(builder.to_xml)
|
@@ -284,11 +280,11 @@ EOF
|
|
284
280
|
end
|
285
281
|
end
|
286
282
|
end
|
287
|
-
|
283
|
+
|
288
284
|
def self.bundle_app(*args)
|
289
285
|
AppBundler.new(args.pop).bundle(args)
|
290
286
|
end
|
291
|
-
|
287
|
+
|
292
288
|
def self.bundle_deps(*args)
|
293
289
|
AppBundler.new(args.pop).bundle(args)
|
294
290
|
end
|
@@ -23,7 +23,7 @@ require 'appengine-rack/java'
|
|
23
23
|
|
24
24
|
class WebXmlBuilder < Rack::Builder
|
25
25
|
DUMMY_APP = Proc.new{|env|}
|
26
|
-
|
26
|
+
|
27
27
|
def initialize(&block)
|
28
28
|
@path = "/"
|
29
29
|
@paths = Hash.new {|h, k| h[k] = []}
|
@@ -31,7 +31,7 @@ class WebXmlBuilder < Rack::Builder
|
|
31
31
|
@mime_mapping = {}
|
32
32
|
instance_eval(&block) if block_given?
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def add_mime_mapping(doc)
|
36
36
|
@mime_mapping.each_pair do |key,val|
|
37
37
|
mime = doc.add_element('mime-mapping')
|
@@ -39,16 +39,15 @@ class WebXmlBuilder < Rack::Builder
|
|
39
39
|
mime.add_element('mime-type').add_text(val)
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
43
|
-
def add_jruby_rack_defaults
|
44
|
-
use JavaContextParams, :rackup => rackup
|
42
|
+
|
43
|
+
def add_jruby_rack_defaults
|
45
44
|
unless @skip_defaults
|
46
|
-
use JavaServletFilter, 'org.jruby.rack.RackFilter',
|
45
|
+
use JavaServletFilter, 'org.jruby.rack.RackFilter',
|
47
46
|
{ :name => 'RackFilter', :wildcard => true }
|
48
47
|
end
|
49
48
|
use JavaContextListener, 'com.google.appengine.jruby.LazyContextListener'
|
50
49
|
end
|
51
|
-
|
50
|
+
|
52
51
|
def use(middleware, *args, &block)
|
53
52
|
if middleware.respond_to? :append_xml
|
54
53
|
@paths[@path] << [middleware, args, block]
|
@@ -56,7 +55,7 @@ class WebXmlBuilder < Rack::Builder
|
|
56
55
|
@paths[@path] << [middleware.new(DUMMY_APP, *args, &block)]
|
57
56
|
end
|
58
57
|
end
|
59
|
-
|
58
|
+
|
60
59
|
def map(path, &block)
|
61
60
|
if URI.parse(path).scheme.nil? # we can only natively support path matching
|
62
61
|
saved_path = @path
|
@@ -68,7 +67,7 @@ class WebXmlBuilder < Rack::Builder
|
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
71
|
-
|
70
|
+
|
72
71
|
def run(app)
|
73
72
|
@paths[@path] << [app, [], nil]
|
74
73
|
end
|
@@ -89,7 +88,7 @@ class WebXmlBuilder < Rack::Builder
|
|
89
88
|
add_mime_mapping(doc)
|
90
89
|
doc
|
91
90
|
end
|
92
|
-
|
91
|
+
|
93
92
|
private
|
94
93
|
def each_path
|
95
94
|
@paths.sort {|a, b| b[0].length - a[0].length}.each do |path, value|
|
data/spec/rack_spec.rb
CHANGED
@@ -22,7 +22,7 @@ describe AppEngine::Rack do
|
|
22
22
|
it "should generate correct xml" do
|
23
23
|
rackup = IO.read("#{File.dirname(__FILE__)}/config.ru")
|
24
24
|
builder = WebXmlBuilder.new do
|
25
|
-
add_jruby_rack_defaults
|
25
|
+
add_jruby_rack_defaults
|
26
26
|
eval rackup, nil, "#{File.dirname(__FILE__)}/config.ru", 1
|
27
27
|
end
|
28
28
|
xml = AppEngine::Rack::XmlFormatter.format(AppEngine::Rack.app.to_xml)
|
data/spec/web-xml_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe WebXmlBuilder do
|
|
21
21
|
it "should generate correct xml" do
|
22
22
|
rackup = IO.read("#{File.dirname(__FILE__)}/config.ru")
|
23
23
|
builder = WebXmlBuilder.new do
|
24
|
-
add_jruby_rack_defaults
|
24
|
+
add_jruby_rack_defaults
|
25
25
|
eval rackup, nil, "#{File.dirname(__FILE__)}/config.ru", 1
|
26
26
|
end
|
27
27
|
xml = AppEngine::Rack::XmlFormatter.format(builder.to_xml)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 12
|
9
|
+
version: 0.0.12
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ryan Brown
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-04
|
18
|
+
date: 2010-05-04 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- Rakefile
|
103
103
|
- lib/appengine-tools/appcfg.rb
|
104
104
|
- lib/appengine-tools/boot.rb
|
105
|
+
- lib/appengine-tools/boot_app.rb
|
105
106
|
- lib/appengine-tools/bundler.rb
|
106
107
|
- lib/appengine-tools/dev_appserver.rb
|
107
108
|
- lib/appengine-tools/gem_bundler.rb
|