appengine-tools 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +202 -0
- data/README.rdoc +10 -0
- data/Rakefile +57 -0
- data/bin/appcfg.rb +18 -0
- data/bin/dev_appserver.rb +18 -0
- data/lib/appengine-tools/appcfg.rb +216 -0
- data/lib/appengine-tools/boot.rb +63 -0
- data/lib/appengine-tools/bundler.rb +196 -0
- data/lib/appengine-tools/dev_appserver.rb +62 -0
- data/lib/appengine-tools/web-xml.rb +86 -0
- data/lib/appengine-tools/xml-formatter.rb +40 -0
- data/spec/appengine-web.xml +12 -0
- data/spec/config.ru +33 -0
- data/spec/rack_spec.rb +31 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/web-xml_spec.rb +30 -0
- data/spec/web.xml +81 -0
- metadata +101 -0
data/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.rdoc
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Generate XML files required by App Engine for JRuby from a rackup file.
|
2
|
+
This works from standard Ruby or JRuby, but you'll need the rack gem.
|
3
|
+
|
4
|
+
Configure your app from within the 'config.ru' file:
|
5
|
+
|
6
|
+
AppEngine::Rack.app.configure( :application => 'simple', :version => 2 )
|
7
|
+
|
8
|
+
Now run xmlgen.rb and and your ready to go:
|
9
|
+
|
10
|
+
jruby -rubygems -e 'require "appengine-tools/genxml"'
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rubygems/specification'
|
4
|
+
require 'date'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
GEM = "appengine-tools"
|
8
|
+
GEM_VERSION = "0.0.1"
|
9
|
+
AUTHOR = "Ryan Brown"
|
10
|
+
EMAIL = "ribrdb@gmail.com"
|
11
|
+
HOMEPAGE = "http://code.google.com/p/appengine-jruby"
|
12
|
+
SUMMARY = "Tools for developing and deploying apps to Google App Engine"
|
13
|
+
|
14
|
+
spec = Gem::Specification.new do |s|
|
15
|
+
s.name = GEM
|
16
|
+
s.version = GEM_VERSION
|
17
|
+
s.platform = Gem::Platform::RUBY
|
18
|
+
s.has_rdoc = true
|
19
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
|
20
|
+
s.summary = SUMMARY
|
21
|
+
s.description = s.summary
|
22
|
+
s.author = AUTHOR
|
23
|
+
s.email = EMAIL
|
24
|
+
s.homepage = HOMEPAGE
|
25
|
+
|
26
|
+
s.require_path = 'lib'
|
27
|
+
s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
|
28
|
+
s.executables = [ 'appcfg.rb', 'dev_appserver.rb' ]
|
29
|
+
s.add_dependency('appengine-rack')
|
30
|
+
s.add_dependency('appengine-sdk')
|
31
|
+
s.add_dependency('jruby-abridged')
|
32
|
+
end
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
desc "Run specs"
|
37
|
+
Spec::Rake::SpecTask.new do |t|
|
38
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
39
|
+
t.spec_opts = IO.read('spec/spec.opts').split
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
44
|
+
pkg.gem_spec = spec
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "install the gem locally"
|
48
|
+
task :install => [:package] do
|
49
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "create a gemspec file"
|
53
|
+
task :make_spec do
|
54
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
55
|
+
file.puts spec.to_ruby
|
56
|
+
end
|
57
|
+
end
|
data/bin/appcfg.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#! /usr/bin/env 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
|
+
require 'appengine-tools/appcfg'
|
18
|
+
AppEngine::Admin::JRubyAppCfg.main(ARGV)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright:: Copyright 2009 Google Inc.
|
3
|
+
# Original Author:: John Woodell (mailto:woodie@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
|
+
require 'appengine-tools/dev_appserver'
|
18
|
+
AppEngine::Development::JRubyDevAppserver.run(ARGV)
|
@@ -0,0 +1,216 @@
|
|
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
|
+
require 'appengine-sdk'
|
18
|
+
require 'appengine-tools/boot'
|
19
|
+
require 'appengine-tools/bundler'
|
20
|
+
require 'yaml'
|
21
|
+
|
22
|
+
module AppEngine
|
23
|
+
module Admin
|
24
|
+
if defined? Java
|
25
|
+
AppCfg = AppEngine::SDK.load_appcfg
|
26
|
+
import Java.ComGoogleAppengineToolsAdmin.AppAdminFactory
|
27
|
+
import Java.ComGoogleAppengineToolsAdmin.AppVersionUpload
|
28
|
+
import Java.ComGoogleAppengineToolsUtil.Logging
|
29
|
+
|
30
|
+
class JRubyAppVersionUpload < AppVersionUpload
|
31
|
+
def initialize(connection, app)
|
32
|
+
@connection = connection
|
33
|
+
@app = app
|
34
|
+
super(connection, app)
|
35
|
+
end
|
36
|
+
|
37
|
+
def getIndexYaml
|
38
|
+
indexes = merge_indexes
|
39
|
+
if indexes
|
40
|
+
return indexes.to_yaml
|
41
|
+
end
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def getCronYaml
|
46
|
+
cron = File.join(app.path, 'cron.yaml')
|
47
|
+
if File.exists?(cron)
|
48
|
+
return cron.to_yaml
|
49
|
+
end
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def merge_indexes
|
54
|
+
if @app.indexes_xml
|
55
|
+
indexes = YAML.load(@app.indexes_xml.to_yaml)['indexes']
|
56
|
+
end
|
57
|
+
indexes ||= []
|
58
|
+
index_yaml = File.join(@app.path, 'index.yaml')
|
59
|
+
if File.exist?(index_yaml)
|
60
|
+
manual_indexes = YAML.load_file(index_yaml)['indexes'] || []
|
61
|
+
manual_indexes.each do |index|
|
62
|
+
indexes << index unless indexes.include?(index)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
if indexes.size > 0
|
66
|
+
{'indexes' => indexes}
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class JRubyAppCfg
|
75
|
+
NO_XML_COMMANDS = [ 'version' ]
|
76
|
+
RUBY_COMMANDS = ['bundle', 'gem', 'help', 'run']
|
77
|
+
COMMAND_SUMMARY = <<EOF
|
78
|
+
run: run jruby in your application environment.
|
79
|
+
gem: run rubygems for your application.
|
80
|
+
bundle: package your application for deployment.
|
81
|
+
The 'gem' and 'run' commands assume the app directory is the current directory.
|
82
|
+
EOF
|
83
|
+
class << self
|
84
|
+
def main(args)
|
85
|
+
command, parsed_args = parse_args(args)
|
86
|
+
if RUBY_COMMANDS.include? command
|
87
|
+
send(command, *parsed_args)
|
88
|
+
return
|
89
|
+
end
|
90
|
+
if command && ! NO_XML_COMMANDS.include?(command)
|
91
|
+
AppEngine::Admin.bundle_app(parsed_args[0])
|
92
|
+
end
|
93
|
+
if !RUBY_COMMANDS.include?(command)
|
94
|
+
puts "running AppCfg"
|
95
|
+
run_appcfg(args)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def run_appcfg(args)
|
100
|
+
factory = AppAdminFactory.new
|
101
|
+
factory.setAppVersionUploadClass(JRubyAppVersionUpload)
|
102
|
+
Logging.initializeLogging
|
103
|
+
AppCfg.new(factory, args.to_java(java.lang.String))
|
104
|
+
end
|
105
|
+
|
106
|
+
def bundle(path)
|
107
|
+
AppEngine::Admin.bundle_app(path)
|
108
|
+
end
|
109
|
+
|
110
|
+
def bundle_help
|
111
|
+
help = <<EOF
|
112
|
+
#{$0} bundle app_dir
|
113
|
+
|
114
|
+
Generates files necessary to run an application as a Java Servlet.
|
115
|
+
This is run automatically when necessary, so you should not
|
116
|
+
need to run it manually.
|
117
|
+
|
118
|
+
EOF
|
119
|
+
end
|
120
|
+
|
121
|
+
def gem(*args)
|
122
|
+
AppEngine::Development.boot_jruby
|
123
|
+
require 'rubygems'
|
124
|
+
require 'rubygems/command_manager'
|
125
|
+
Gem.configuration = Gem::ConfigFile.new(args)
|
126
|
+
Gem.use_paths('.gems')
|
127
|
+
Gem::Command.add_specific_extra_args(
|
128
|
+
'install', %w(--no-rdoc --no-ri))
|
129
|
+
begin
|
130
|
+
Gem::CommandManager.instance.run(Gem.configuration.args)
|
131
|
+
rescue Gem::SystemExitException => e
|
132
|
+
exit e.exit_code unless e.exit_code == 0
|
133
|
+
end
|
134
|
+
unless Dir.glob('.gems/specifications/*.gemspec').empty?
|
135
|
+
Dir.mkdir 'WEB-INF' unless File.exists? 'WEB-INF'
|
136
|
+
Dir.mkdir 'WEB-INF/lib' unless File.exists? 'WEB-INF/lib'
|
137
|
+
Dir.chdir '.gems'
|
138
|
+
command = %w(jar cf ../WEB-INF/lib/gems.jar gems specifications)
|
139
|
+
if !system(*command)
|
140
|
+
puts 'Error running jar command.'
|
141
|
+
exit $?
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def gem_help
|
147
|
+
help = <<EOF
|
148
|
+
#{$0} gem [rubygems arguments]
|
149
|
+
|
150
|
+
|
151
|
+
Configures rubygems for this application and bundles the gems into a .jar file.
|
152
|
+
Must be run from the application directory.
|
153
|
+
|
154
|
+
EOF
|
155
|
+
end
|
156
|
+
|
157
|
+
def run(*args)
|
158
|
+
AppEngine::Development.boot_app('.', args)
|
159
|
+
end
|
160
|
+
|
161
|
+
def run_help
|
162
|
+
help = <<EOF
|
163
|
+
#{$0} run [ruby args]
|
164
|
+
|
165
|
+
|
166
|
+
Starts the jruby interpreter within your application's environment.
|
167
|
+
Use `#{$0} run -S command` to run a command such as rake or irb.
|
168
|
+
Must be run from the application directory, after running bundle.
|
169
|
+
|
170
|
+
EOF
|
171
|
+
end
|
172
|
+
|
173
|
+
def help(command=nil)
|
174
|
+
puts
|
175
|
+
if command != 'help' && RUBY_COMMANDS.include?(command)
|
176
|
+
puts send("#{command}_help")
|
177
|
+
else
|
178
|
+
java_args = %W(java -cp #{AppEngine::SDK::TOOLS_JAR})
|
179
|
+
java_args << 'com.google.appengine.tools.admin.AppCfg'
|
180
|
+
java_args << 'help'
|
181
|
+
java_args << command if command
|
182
|
+
print_help(%x{#{java_args.map{|x| x.inspect}.join(' ')}}, !command)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def print_help(help, summary)
|
187
|
+
help.gsub!('AppCfg', $0)
|
188
|
+
count = 0
|
189
|
+
help.each_line do |line|
|
190
|
+
line.chomp!
|
191
|
+
if summary && line.size > 0 && line.lstrip == line
|
192
|
+
count += 1
|
193
|
+
print COMMAND_SUMMARY if count == 3
|
194
|
+
end
|
195
|
+
puts line
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def parse_args(args)
|
200
|
+
if RUBY_COMMANDS.include?(args[0])
|
201
|
+
return [args[0], args[1, args.length]]
|
202
|
+
elsif args.empty? || !(%w(-h --help) & args).empty?
|
203
|
+
return ['help', []]
|
204
|
+
elsif args[-3] == 'request_logs'
|
205
|
+
command = args[-3]
|
206
|
+
path = args[-2]
|
207
|
+
else
|
208
|
+
command = args[-2]
|
209
|
+
path = args[-1]
|
210
|
+
end
|
211
|
+
return [command, [path]]
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,63 @@
|
|
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
|
+
require 'appengine-sdk'
|
18
|
+
|
19
|
+
module AppEngine
|
20
|
+
module Development
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def boot_jruby(root=nil)
|
24
|
+
unless defined?(JRUBY_VERSION)
|
25
|
+
require 'rubygems'
|
26
|
+
require 'jruby-abridged'
|
27
|
+
|
28
|
+
jars = [
|
29
|
+
JRubyAbridged.jruby_jar,
|
30
|
+
JRubyAbridged.rubygems_jar,
|
31
|
+
AppEngine::SDK::TOOLS_JAR,
|
32
|
+
]
|
33
|
+
|
34
|
+
ENV['GEM_HOME'] = Gem.dir
|
35
|
+
exec_jruby(root, jars, [$0] + ARGV)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def boot_app(root, args)
|
40
|
+
root = File.expand_path(root)
|
41
|
+
|
42
|
+
jars = AppEngine::SDK::RUNTIME_JARS
|
43
|
+
|
44
|
+
jruby_args = %w(-rappengine_boot) + args
|
45
|
+
|
46
|
+
ENV['APPLICATION_ROOT'] = root
|
47
|
+
ENV.delete 'GEM_HOME'
|
48
|
+
exec_jruby(root, jars, jruby_args)
|
49
|
+
end
|
50
|
+
|
51
|
+
def exec_jruby(root, jars, args)
|
52
|
+
app_jars = root ? Dir.glob("#{root}/WEB-INF/lib/*.jar") : []
|
53
|
+
classpath = (app_jars + jars).join(File::PATH_SEPARATOR)
|
54
|
+
utf = "-Dfile.encoding=UTF-8"
|
55
|
+
java_command = %W(java #{utf} -cp #{classpath} org.jruby.Main) + args
|
56
|
+
if ENV['VERBOSE']
|
57
|
+
puts java_command.map {|a| a.inspect}.join(' ')
|
58
|
+
end
|
59
|
+
exec *java_command
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,196 @@
|
|
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
|
+
require 'appengine-tools/web-xml'
|
20
|
+
require 'appengine-tools/xml-formatter'
|
21
|
+
|
22
|
+
module AppEngine
|
23
|
+
module Admin
|
24
|
+
|
25
|
+
class Application
|
26
|
+
attr_reader :root
|
27
|
+
|
28
|
+
def initialize(root)
|
29
|
+
@root = root
|
30
|
+
end
|
31
|
+
|
32
|
+
def path(*pieces)
|
33
|
+
File.join(@root, *pieces)
|
34
|
+
end
|
35
|
+
|
36
|
+
def webinf
|
37
|
+
path('WEB-INF')
|
38
|
+
end
|
39
|
+
|
40
|
+
def webinf_lib
|
41
|
+
path('WEB-INF', 'lib')
|
42
|
+
end
|
43
|
+
|
44
|
+
def config_ru
|
45
|
+
path('config.ru')
|
46
|
+
end
|
47
|
+
|
48
|
+
def web_xml
|
49
|
+
path('WEB-INF', 'web.xml')
|
50
|
+
end
|
51
|
+
|
52
|
+
def aeweb_xml
|
53
|
+
path('WEB-INF', 'appengine-web.xml')
|
54
|
+
end
|
55
|
+
|
56
|
+
def public_root
|
57
|
+
path(AppEngine::Rack.app.public_root) if AppEngine::Rack.app.public_root
|
58
|
+
end
|
59
|
+
|
60
|
+
def rack_app
|
61
|
+
AppEngine::Rack.app
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class AppBundler
|
67
|
+
EXISTING_JRUBY = /^jruby(?!-rack).*jar$/
|
68
|
+
EXISTING_RACK = /jruby-rack.*jar$/
|
69
|
+
EXISTING_APIS = /^appengine-api.*jar$/
|
70
|
+
JRUBY_RACK = 'jruby-rack-0.9.4.jar'
|
71
|
+
JRUBY_RACK_URL = 'http://kenai.com/projects/jruby-rack/downloads/' +
|
72
|
+
'download/' + JRUBY_RACK
|
73
|
+
RACKUP = %q{Dir.chdir('..') if Dir.pwd =~ /WEB-INF$/;} +
|
74
|
+
%q{eval IO.read('config.ru'), nil, 'config.ru', 1}
|
75
|
+
|
76
|
+
def initialize(root_path)
|
77
|
+
@app = Application.new(root_path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def bundle
|
81
|
+
create_webinf
|
82
|
+
create_public
|
83
|
+
copy_jruby
|
84
|
+
copy_rack
|
85
|
+
copy_sdk
|
86
|
+
convert_config_ru
|
87
|
+
end
|
88
|
+
|
89
|
+
def app
|
90
|
+
@app
|
91
|
+
end
|
92
|
+
|
93
|
+
def create_webinf
|
94
|
+
Dir.mkdir(app.webinf) unless File.exists?(app.webinf)
|
95
|
+
Dir.mkdir(app.webinf_lib) unless File.exists?(app.webinf_lib)
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_public
|
99
|
+
path = app.public_root
|
100
|
+
if path && !File.exists?(path)
|
101
|
+
Dir.mkdir(path)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def convert_config_ru
|
106
|
+
AppEngine::Development.boot_jruby(app.root)
|
107
|
+
if !File.exists?(app.config_ru)
|
108
|
+
if File.exists?(app.web_xml)
|
109
|
+
unless File.exists?(app.aeweb_xml)
|
110
|
+
puts "Error: you either need a #{app.config_ru} or "
|
111
|
+
puts " #{app.aeweb_xml}."
|
112
|
+
exit 1
|
113
|
+
end
|
114
|
+
else
|
115
|
+
# TODO auto generate a config.ru
|
116
|
+
puts "Error: you need to create #{app.config_ru}."
|
117
|
+
exit 1
|
118
|
+
end
|
119
|
+
else
|
120
|
+
generate_xml
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def copy_jruby
|
125
|
+
current_jruby = find_jars(EXISTING_JRUBY)
|
126
|
+
if current_jruby.empty?
|
127
|
+
require 'jruby-abridged'
|
128
|
+
FileUtils.cp([JRubyAbridged.jruby_jar, JRubyAbridged.rubygems_jar],
|
129
|
+
app.webinf_lib)
|
130
|
+
end
|
131
|
+
# TODO else warn if out of date
|
132
|
+
end
|
133
|
+
|
134
|
+
def copy_rack
|
135
|
+
current_rack = find_jars(EXISTING_RACK)
|
136
|
+
if current_rack.empty?
|
137
|
+
# TODO cache this somewhere
|
138
|
+
require 'open-uri'
|
139
|
+
puts 'Downloading jruby-rack...'
|
140
|
+
open(JRUBY_RACK_URL) do |src|
|
141
|
+
open(File.join(app.webinf_lib, JRUBY_RACK), 'wb') do |dest|
|
142
|
+
dest.write(src.read)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def copy_sdk
|
149
|
+
current_apis = find_jars(EXISTING_APIS)
|
150
|
+
if current_apis.empty?
|
151
|
+
require 'appengine-sdk'
|
152
|
+
jars = Dir.glob(
|
153
|
+
"#{AppEngine::SDK::SDK_ROOT}/lib/user/appengine-api*.jar")
|
154
|
+
# TODO if there's more than 1 we need to check the api version.
|
155
|
+
FileUtils.cp(jars[0], app.webinf_lib)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
|
161
|
+
def find_jars(regex)
|
162
|
+
Dir.entries(app.webinf_lib).grep(regex) rescue []
|
163
|
+
end
|
164
|
+
|
165
|
+
def generate_xml
|
166
|
+
Dir.glob("#{app.webinf_lib}/*.jar").each do |path|
|
167
|
+
$: << path
|
168
|
+
end
|
169
|
+
app_root = app.root
|
170
|
+
builder = WebXmlBuilder.new do
|
171
|
+
# First configure the basic jruby-rack settings.
|
172
|
+
add_jruby_rack_defaults(RACKUP)
|
173
|
+
|
174
|
+
# Now read the user's rackup file
|
175
|
+
# TODO generate a skeleton if it's missing
|
176
|
+
Dir.chdir(app_root) do
|
177
|
+
eval IO.read('config.ru'), nil, 'config.ru', 1
|
178
|
+
end
|
179
|
+
end
|
180
|
+
open(app.web_xml, 'w') do |webxml|
|
181
|
+
xml = AppEngine::Rack::XmlFormatter.format(builder.to_xml)
|
182
|
+
webxml.write(xml)
|
183
|
+
end
|
184
|
+
open(app.aeweb_xml, 'w') do |aeweb|
|
185
|
+
xml = AppEngine::Rack::XmlFormatter.format(app.rack_app.to_xml)
|
186
|
+
aeweb.write(xml)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def self.bundle_app(root_path)
|
192
|
+
AppBundler.new(root_path).bundle
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# Copyright:: Copyright 2009 Google Inc.
|
3
|
+
# Original Author:: John Woodell (mailto:woodie@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
|
+
require 'appengine-sdk'
|
18
|
+
require 'appengine-tools/boot'
|
19
|
+
require 'appengine-tools/bundler'
|
20
|
+
|
21
|
+
module AppEngine
|
22
|
+
module Development
|
23
|
+
DEV_APPSERVER = 'com.google.appengine.tools.development.DevAppServerMain'
|
24
|
+
class JRubyDevAppserver
|
25
|
+
class << self
|
26
|
+
def run(args)
|
27
|
+
path = args[-1] || '.'
|
28
|
+
if args.length > 0 and File::directory?(args[-1])
|
29
|
+
unless ENV['BOOTING_DEVAPPSERVER']
|
30
|
+
puts "=> Booting DevAppServer"
|
31
|
+
puts "=> Press Ctrl-C to shutdown server"
|
32
|
+
print "=> "
|
33
|
+
$stdout.flush
|
34
|
+
ENV['BOOTING_DEVAPPSERVER'] = 'true'
|
35
|
+
end
|
36
|
+
AppEngine::Admin.bundle_app(path)
|
37
|
+
end
|
38
|
+
AppEngine::Development.boot_jruby
|
39
|
+
args.unshift(DEV_APPSERVER)
|
40
|
+
jruby_home = get_jruby_home(args[-1])
|
41
|
+
if jruby_home
|
42
|
+
args.unshift("--jvm_flag=-Djruby.home=#{jruby_home}")
|
43
|
+
end
|
44
|
+
AppEngine::SDK.load_kickstart.main(args.to_java(:string))
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_jruby_home(path)
|
48
|
+
return unless path
|
49
|
+
Dir.chdir("#{path}/WEB-INF/lib") do
|
50
|
+
jars = Dir.glob("jruby-abridged-*.jar").grep(
|
51
|
+
/^jruby-abridged-\d+[.]\d+[.]\d+[.]jar$/)
|
52
|
+
if !jars.empty?
|
53
|
+
jar = File.expand_path(jars[0])
|
54
|
+
return "file:/#{jar}!/META-INF/jruby.home"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,86 @@
|
|
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 'rack'
|
19
|
+
require 'rexml/document'
|
20
|
+
require 'uri'
|
21
|
+
|
22
|
+
require 'appengine-rack/java'
|
23
|
+
|
24
|
+
class WebXmlBuilder < Rack::Builder
|
25
|
+
DUMMY_APP = Proc.new{|env|}
|
26
|
+
|
27
|
+
def initialize(&block)
|
28
|
+
@path = "/"
|
29
|
+
@paths = Hash.new {|h, k| h[k] = []}
|
30
|
+
instance_eval(&block) if block_given?
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_jruby_rack_defaults(rackup)
|
34
|
+
use JavaContextParams, :rackup => rackup
|
35
|
+
|
36
|
+
run JavaServlet.new('org.jruby.rack.RackServlet')
|
37
|
+
use JavaContextListener, 'org.jruby.rack.RackServletContextListener'
|
38
|
+
end
|
39
|
+
|
40
|
+
def use(middleware, *args, &block)
|
41
|
+
if middleware.respond_to? :append_xml
|
42
|
+
@paths[@path] << [middleware, args, block]
|
43
|
+
else
|
44
|
+
@paths[@path] << [middleware.new(DUMMY_APP, *args, &block)]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def map(path, &block)
|
49
|
+
if URI.parse(path).scheme.nil? # we can only natively support path matching
|
50
|
+
saved_path = @path
|
51
|
+
@path = [@path, path].join('/').squeeze('/')
|
52
|
+
begin
|
53
|
+
instance_eval(&block) if block_given?
|
54
|
+
ensure
|
55
|
+
@path = saved_path
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def run(app)
|
61
|
+
@paths[@path] << [app, [], nil]
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_xml
|
65
|
+
doc = REXML::Document.new.add_element('web-app')
|
66
|
+
doc.add_attribute("xmlns", "http://java.sun.com/xml/ns/javaee")
|
67
|
+
doc.add_attribute("version", "2.5")
|
68
|
+
each_path do |path, objects|
|
69
|
+
pattern = path.chomp('/')
|
70
|
+
pattern = '/' if pattern.empty?
|
71
|
+
objects.each do |object, args, block|
|
72
|
+
if object.respond_to? :append_xml
|
73
|
+
object.append_xml(doc, pattern, *args, &block)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
doc
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
def each_path
|
82
|
+
@paths.sort {|a, b| b[0].length - a[0].length}.each do |path, value|
|
83
|
+
yield path, value
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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 'rexml/formatters/pretty'
|
19
|
+
|
20
|
+
module AppEngine
|
21
|
+
module Rack
|
22
|
+
class XmlFormatter < REXML::Formatters::Pretty
|
23
|
+
def initialize
|
24
|
+
@compact = true
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def write_text( node, output )
|
29
|
+
output << node.to_s()
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.format(xml)
|
33
|
+
@formatter ||= XmlFormatter.new
|
34
|
+
output = ''
|
35
|
+
@formatter.write(xml, output)
|
36
|
+
return output
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<appengine-web-app xmlns='http://appengine.google.com/ns/1.0'>
|
2
|
+
<application>tools-test</application>
|
3
|
+
<version>foo</version>
|
4
|
+
<public-root>/public</public-root>
|
5
|
+
<static-files/>
|
6
|
+
<resource-files/>
|
7
|
+
<system-properties>
|
8
|
+
<property name='os.arch' value=''/>
|
9
|
+
<property name='jruby.management.enabled' value='false'/>
|
10
|
+
</system-properties>
|
11
|
+
<ssl-enabled>true</ssl-enabled>
|
12
|
+
</appengine-web-app>
|
data/spec/config.ru
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'appengine-rack'
|
2
|
+
|
3
|
+
AppEngine::Rack.configure_app(
|
4
|
+
:application => 'tools-test', :version => 'foo', :ssl_enabled => true)
|
5
|
+
|
6
|
+
ruby_app = lambda {|env| [200, {}, "Hello Rack!"]}
|
7
|
+
|
8
|
+
map '/admin' do
|
9
|
+
use JavaServletFilter, 'com.example.AdminFilter', :wildcard => true
|
10
|
+
run JavaServlet.new('com.example.AdminServlet', :wildcard => true)
|
11
|
+
end
|
12
|
+
|
13
|
+
map '/store' do
|
14
|
+
use JavaServletFilter, 'com.example.StoreFilter', :name => 'StoreFilter'
|
15
|
+
run JavaServlet.new('com.example.StoreServlet', :name => 'store')
|
16
|
+
end
|
17
|
+
|
18
|
+
map '/admin2' do
|
19
|
+
use AppEngine::Rack::AdminRequired
|
20
|
+
run ruby_app
|
21
|
+
end
|
22
|
+
|
23
|
+
map '/private' do
|
24
|
+
use AppEngine::Rack::LoginRequired
|
25
|
+
run ruby_app
|
26
|
+
end
|
27
|
+
|
28
|
+
map '/secure' do
|
29
|
+
use AppEngine::Rack::SSLRequired
|
30
|
+
run ruby_app
|
31
|
+
end
|
32
|
+
|
33
|
+
run ruby_app
|
data/spec/rack_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright:: Copyright 2009 Google Inc.
|
2
|
+
# Original Author:: Ryan Brown (mailto:ribrdb@google.com)
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
17
|
+
require 'appengine-rack'
|
18
|
+
require 'appengine-tools/web-xml'
|
19
|
+
require 'appengine-tools/xml-formatter'
|
20
|
+
|
21
|
+
describe AppEngine::Rack do
|
22
|
+
it "should generate correct xml" do
|
23
|
+
rackup = IO.read("#{File.dirname(__FILE__)}/config.ru")
|
24
|
+
builder = WebXmlBuilder.new do
|
25
|
+
add_jruby_rack_defaults('rackup')
|
26
|
+
eval rackup, nil, "#{File.dirname(__FILE__)}/config.ru", 1
|
27
|
+
end
|
28
|
+
xml = AppEngine::Rack::XmlFormatter.format(AppEngine::Rack.app.to_xml)
|
29
|
+
xml.should == IO.read("#{File.dirname(__FILE__)}/appengine-web.xml")
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --diff
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright:: Copyright 2009 Google Inc.
|
2
|
+
# Original Author:: Ryan Brown (mailto:ribrdb@google.com)
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
17
|
+
require 'appengine-tools/web-xml'
|
18
|
+
require 'appengine-tools/xml-formatter'
|
19
|
+
|
20
|
+
describe WebXmlBuilder do
|
21
|
+
it "should generate correct xml" do
|
22
|
+
rackup = IO.read("#{File.dirname(__FILE__)}/config.ru")
|
23
|
+
builder = WebXmlBuilder.new do
|
24
|
+
add_jruby_rack_defaults('rackup')
|
25
|
+
eval rackup, nil, "#{File.dirname(__FILE__)}/config.ru", 1
|
26
|
+
end
|
27
|
+
xml = AppEngine::Rack::XmlFormatter.format(builder.to_xml)
|
28
|
+
xml.should == IO.read("#{File.dirname(__FILE__)}/web.xml")
|
29
|
+
end
|
30
|
+
end
|
data/spec/web.xml
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
<web-app version='2.5' xmlns='http://java.sun.com/xml/ns/javaee'>
|
2
|
+
<security-constraint>
|
3
|
+
<web-resource-collection>
|
4
|
+
<url-pattern>/private/*</url-pattern>
|
5
|
+
</web-resource-collection>
|
6
|
+
<auth-constraint>
|
7
|
+
<role-name>*</role-name>
|
8
|
+
</auth-constraint>
|
9
|
+
</security-constraint>
|
10
|
+
<security-constraint>
|
11
|
+
<web-resource-collection>
|
12
|
+
<url-pattern>/admin2/*</url-pattern>
|
13
|
+
</web-resource-collection>
|
14
|
+
<auth-constraint>
|
15
|
+
<role-name>admin</role-name>
|
16
|
+
</auth-constraint>
|
17
|
+
</security-constraint>
|
18
|
+
<security-constraint>
|
19
|
+
<web-resource-collection>
|
20
|
+
<url-pattern>/secure/*</url-pattern>
|
21
|
+
</web-resource-collection>
|
22
|
+
<user-data-constraint>
|
23
|
+
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
|
24
|
+
</user-data-constraint>
|
25
|
+
</security-constraint>
|
26
|
+
<filter>
|
27
|
+
<filter-name>StoreFilter</filter-name>
|
28
|
+
<filter-class>com.example.StoreFilter</filter-class>
|
29
|
+
</filter>
|
30
|
+
<filter-mapping>
|
31
|
+
<filter-name>StoreFilter</filter-name>
|
32
|
+
<url-pattern>/store</url-pattern>
|
33
|
+
</filter-mapping>
|
34
|
+
<servlet>
|
35
|
+
<servlet-name>store</servlet-name>
|
36
|
+
<servlet-class>com.example.StoreServlet</servlet-class>
|
37
|
+
</servlet>
|
38
|
+
<servlet-mapping>
|
39
|
+
<servlet-name>store</servlet-name>
|
40
|
+
<url-pattern>/store</url-pattern>
|
41
|
+
</servlet-mapping>
|
42
|
+
<filter>
|
43
|
+
<filter-name>com.example.AdminFilter</filter-name>
|
44
|
+
<filter-class>com.example.AdminFilter</filter-class>
|
45
|
+
</filter>
|
46
|
+
<filter-mapping>
|
47
|
+
<filter-name>com.example.AdminFilter</filter-name>
|
48
|
+
<url-pattern>/admin</url-pattern>
|
49
|
+
</filter-mapping>
|
50
|
+
<filter-mapping>
|
51
|
+
<filter-name>com.example.AdminFilter</filter-name>
|
52
|
+
<url-pattern>/admin/*</url-pattern>
|
53
|
+
</filter-mapping>
|
54
|
+
<servlet>
|
55
|
+
<servlet-name>com.example.AdminServlet</servlet-name>
|
56
|
+
<servlet-class>com.example.AdminServlet</servlet-class>
|
57
|
+
</servlet>
|
58
|
+
<servlet-mapping>
|
59
|
+
<servlet-name>com.example.AdminServlet</servlet-name>
|
60
|
+
<url-pattern>/admin</url-pattern>
|
61
|
+
</servlet-mapping>
|
62
|
+
<servlet-mapping>
|
63
|
+
<servlet-name>com.example.AdminServlet</servlet-name>
|
64
|
+
<url-pattern>/admin/*</url-pattern>
|
65
|
+
</servlet-mapping>
|
66
|
+
<context-param>
|
67
|
+
<param-name>rackup</param-name>
|
68
|
+
<param-value>rackup</param-value>
|
69
|
+
</context-param>
|
70
|
+
<servlet>
|
71
|
+
<servlet-name>org.jruby.rack.RackServlet</servlet-name>
|
72
|
+
<servlet-class>org.jruby.rack.RackServlet</servlet-class>
|
73
|
+
</servlet>
|
74
|
+
<servlet-mapping>
|
75
|
+
<servlet-name>org.jruby.rack.RackServlet</servlet-name>
|
76
|
+
<url-pattern>/</url-pattern>
|
77
|
+
</servlet-mapping>
|
78
|
+
<listener>
|
79
|
+
<listener-class>org.jruby.rack.RackServletContextListener</listener-class>
|
80
|
+
</listener>
|
81
|
+
</web-app>
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: appengine-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Brown
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-30 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: appengine-rack
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: appengine-sdk
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jruby-abridged
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: Tools for developing and deploying apps to Google App Engine
|
46
|
+
email: ribrdb@gmail.com
|
47
|
+
executables:
|
48
|
+
- appcfg.rb
|
49
|
+
- dev_appserver.rb
|
50
|
+
extensions: []
|
51
|
+
|
52
|
+
extra_rdoc_files:
|
53
|
+
- README.rdoc
|
54
|
+
- LICENSE
|
55
|
+
files:
|
56
|
+
- LICENSE
|
57
|
+
- README.rdoc
|
58
|
+
- Rakefile
|
59
|
+
- lib/appengine-tools/appcfg.rb
|
60
|
+
- lib/appengine-tools/boot.rb
|
61
|
+
- lib/appengine-tools/bundler.rb
|
62
|
+
- lib/appengine-tools/dev_appserver.rb
|
63
|
+
- lib/appengine-tools/web-xml.rb
|
64
|
+
- lib/appengine-tools/xml-formatter.rb
|
65
|
+
- spec/appengine-web.xml
|
66
|
+
- spec/config.ru
|
67
|
+
- spec/rack_spec.rb
|
68
|
+
- spec/spec.opts
|
69
|
+
- spec/spec_helper.rb
|
70
|
+
- spec/web-xml_spec.rb
|
71
|
+
- spec/web.xml
|
72
|
+
has_rdoc: true
|
73
|
+
homepage: http://code.google.com/p/appengine-jruby
|
74
|
+
licenses: []
|
75
|
+
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.5
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Tools for developing and deploying apps to Google App Engine
|
100
|
+
test_files: []
|
101
|
+
|