ulbrich-jruby-enginize 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +114 -0
- data/bin/jruby-enginize +6 -0
- data/lib/generator.rb +165 -0
- data/lib/script.rb +85 -0
- data/templates/shared/README +39 -0
- data/templates/shared/Rakefile +68 -0
- data/templates/shared/appengine-web.xml +21 -0
- data/templates/shared/lib/jruby-rack-0.9.4.jar +0 -0
- data/templates/shared/lib/split-jruby.sh +67 -0
- data/templates/shared/public/images/appengine_logo.png +0 -0
- data/templates/sinatra/app.rb +26 -0
- data/templates/sinatra/config/warble.rb +95 -0
- data/templates/sinatra/config.ru +13 -0
- data/templates/sinatra/lib/tasks/sinatra.rake +7 -0
- data/templates/sinatra/public/images/sinatra_logo.png +0 -0
- data/templates/sinatra/views/index.haml +17 -0
- data/templates/sinatra/views/layout.haml +6 -0
- data/templates/sinatra/views/stylesheet.sass +44 -0
- metadata +78 -0
data/README
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
= JRuby-Enginize
|
2
|
+
|
3
|
+
== About
|
4
|
+
|
5
|
+
JRuby-Enginize is a generator for Google AppEngine compliant JRuby
|
6
|
+
applications. The generator will support several frameworks but only has
|
7
|
+
Sinatra on board for the moment being. If you want to learn more about Google
|
8
|
+
AppEngine, go to http://code.google.com/appengine and have a look at the
|
9
|
+
tutorials.
|
10
|
+
|
11
|
+
== Prerequisites
|
12
|
+
|
13
|
+
JRuby-Enginize needs a proper JRuby installation including rake and the
|
14
|
+
Google AppEngine SDK for Java. More dependencies depend on the framework
|
15
|
+
template to generate an application for: For Sinatra
|
16
|
+
(http://www.sinatrarb.com), you will need the "sinatra" gem. Be sure to
|
17
|
+
install such gems with <tt>jgem</tt> or <tt>jruby -S gem</tt> as you need
|
18
|
+
them for JRuby and not for Ruby.
|
19
|
+
|
20
|
+
You also need an Google AppEngine account to actually publish your code.
|
21
|
+
Without account you can still play around with the tool and run applications
|
22
|
+
locally.
|
23
|
+
|
24
|
+
== Installation
|
25
|
+
|
26
|
+
Install JRuby-Enginize as a gem with
|
27
|
+
|
28
|
+
jgem sources -a http://gems.github.com # Only needed once!
|
29
|
+
sudo jgem install ulbrich-jruby-enginize
|
30
|
+
|
31
|
+
and be sure to really install with <tt>jgem</tt> as JRuby-Enginize will
|
32
|
+
refuse to work in normal Ruby environment. It is for creating application
|
33
|
+
running on Google AppEngine and it makes no sense outside JRuby!
|
34
|
+
|
35
|
+
== Using jruby-enginize
|
36
|
+
|
37
|
+
The gem includes is a single executable named <tt>jruby-enginize</tt> which is
|
38
|
+
inspired by the <tt>rails</tt> tool for generating Rails applications. So just
|
39
|
+
call
|
40
|
+
|
41
|
+
jruby -S jruby-enginize
|
42
|
+
|
43
|
+
and have a look at the options.
|
44
|
+
|
45
|
+
Here are the steps for creating and deploying a new Sinatra application:
|
46
|
+
|
47
|
+
* Register with Google AppEngine and look for a name for your application
|
48
|
+
which is not already taken. If you don't care about this, you will get in
|
49
|
+
trouble upon deploying your application and have to manually reconfigure
|
50
|
+
all files!
|
51
|
+
|
52
|
+
* Generate your application. Sample:
|
53
|
+
|
54
|
+
<tt>jruby -S jruby-enginize --email foo@bar.com foobar</tt>
|
55
|
+
|
56
|
+
* Go to the new directory, learn about the available rake tasks and try out
|
57
|
+
your application:
|
58
|
+
|
59
|
+
<tt>cd foobar</tt>
|
60
|
+
<tt>jruby rake --tasks</tt>
|
61
|
+
|
62
|
+
<tt>jruby -S rake sinatra:run</tt>
|
63
|
+
|
64
|
+
* Deploy the application with the application name and e-mail address you
|
65
|
+
generated with:
|
66
|
+
|
67
|
+
<tt>jruby -S rake appengine:deploy</tt>
|
68
|
+
|
69
|
+
You can repeat the deployment whenever you want. Be sure to set the version
|
70
|
+
number in "appengine-web.xml" to a new value, when you are experimenting with
|
71
|
+
an unstable version and don't want to risk your users getting exceptions.
|
72
|
+
|
73
|
+
You can try the new version by opening e.g.
|
74
|
+
|
75
|
+
http://3.latest.foobar.appspot.com
|
76
|
+
|
77
|
+
and replacing "3" with the version number you want to run.
|
78
|
+
|
79
|
+
Switch the application to the new version as default (stable version) by
|
80
|
+
opening
|
81
|
+
|
82
|
+
http://appengine.google.com/deployment?&app_id=foobar
|
83
|
+
|
84
|
+
and setting a new default available at
|
85
|
+
|
86
|
+
http://foobar.appspot.com
|
87
|
+
|
88
|
+
A small README with these and a few more application specific hints is
|
89
|
+
generated along with the source code. Have fun.
|
90
|
+
|
91
|
+
== Copyright & License
|
92
|
+
|
93
|
+
Copyright (c) 2009 Holtzbrinck Digital GmbH, Jan Ulbrich
|
94
|
+
|
95
|
+
Permission is hereby granted, free of charge, to any person
|
96
|
+
obtaining a copy of this software and associated documentation
|
97
|
+
files (the "Software"), to deal in the Software without
|
98
|
+
restriction, including without limitation the rights to use,
|
99
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
100
|
+
copies of the Software, and to permit persons to whom the
|
101
|
+
Software is furnished to do so, subject to the following
|
102
|
+
conditions:
|
103
|
+
|
104
|
+
The above copyright notice and this permission notice shall be
|
105
|
+
included in all copies or substantial portions of the Software.
|
106
|
+
|
107
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
108
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
109
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
110
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
111
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
112
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
113
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
114
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/jruby-enginize
ADDED
data/lib/generator.rb
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
# JRuby-Enginize, a generator for Google AppEngine compliant JRuby apps.
|
2
|
+
#
|
3
|
+
# This file contains the JRubyEnginize::Generator class creating a new
|
4
|
+
# directory tree of files drawn from a set of shared and specific templates.
|
5
|
+
|
6
|
+
require 'ftools'
|
7
|
+
require 'find'
|
8
|
+
|
9
|
+
module JRubyEnginize # :nodoc:
|
10
|
+
|
11
|
+
# Code for generating a directory tree created from a shared and a template
|
12
|
+
# specific set of template files.
|
13
|
+
|
14
|
+
class Generator
|
15
|
+
attr_reader :email, :template, :name, :path, :dryrun
|
16
|
+
|
17
|
+
# Constructor of the generator needing at least email, path and template
|
18
|
+
# to run.
|
19
|
+
#
|
20
|
+
# Parameters:
|
21
|
+
#
|
22
|
+
# [email] Mail address of the Google AppEngine account to publish with
|
23
|
+
# [path] Path of the directory to create
|
24
|
+
# [template] Name of the set of templates to generate from
|
25
|
+
# [options] Additional options
|
26
|
+
#
|
27
|
+
# Options:
|
28
|
+
#
|
29
|
+
# [:name] Optional app name defaulting to name of directory
|
30
|
+
# [:dryrun] Flag to enable
|
31
|
+
|
32
|
+
def initialize(email, path, template, options = {})
|
33
|
+
@email = email
|
34
|
+
@path = path
|
35
|
+
@template = template
|
36
|
+
|
37
|
+
options = options.dup
|
38
|
+
|
39
|
+
@name = options.delete(:name)
|
40
|
+
@name = File.basename(path) if @name.nil? or @name.empty?
|
41
|
+
|
42
|
+
@dryrun = options.delete(:dryrun)
|
43
|
+
|
44
|
+
raise ArgumentError, "Unknown option(s) #{options.keys.join(', ')}" unless options.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
# Runs the generator. Starts with setting up a map of files to create
|
48
|
+
# and overriding shared ones with template specific stuff. Runs through
|
49
|
+
# the collected files and calls process_file to render new files in the
|
50
|
+
# target path.
|
51
|
+
|
52
|
+
def run
|
53
|
+
templatesdir = Generator::templates_directory
|
54
|
+
|
55
|
+
shareddir = File.join(templatesdir, 'shared')
|
56
|
+
templatedir = File.join(templatesdir, template)
|
57
|
+
|
58
|
+
raise ArgumentError, 'Missing shared templates' unless File.stat(shareddir).directory?
|
59
|
+
raise ArgumentError, "Template \"#{template}\" missing" unless File.stat(templatedir).directory?
|
60
|
+
|
61
|
+
|
62
|
+
puts "!!no changes written as this is only a dry run...\n" if dryrun
|
63
|
+
puts "Generating files for template \"#{template}\":\n\n"
|
64
|
+
|
65
|
+
template_files(shareddir, templatedir).each do |key, path|
|
66
|
+
target = File.join(self.path, key)
|
67
|
+
puts " Creating \"#{target}\" from template\n file \"#{path}\""
|
68
|
+
|
69
|
+
process_file(path, target) unless dryrun
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "\nYour next steps:\n\n cd #{self.path}\n\n jruby -S rake"
|
73
|
+
puts " jruby -S rake --tasks\n\n jruby -S rake appengine:deploy\n\n"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns an Array with the available template names.
|
77
|
+
|
78
|
+
def self.templates
|
79
|
+
return Dir[File.join(Generator::templates_directory, '*')].collect { |path|
|
80
|
+
(name = File.basename(path)) == 'shared' ? nil : name }.compact
|
81
|
+
end
|
82
|
+
|
83
|
+
protected
|
84
|
+
|
85
|
+
# Returns a Hash with relative paths of files as keys and the whole
|
86
|
+
# paths as values. Runs through all paths in the order as provided and
|
87
|
+
# overrides keys with files found in later paths.
|
88
|
+
#
|
89
|
+
# Sample:
|
90
|
+
#
|
91
|
+
# + templates
|
92
|
+
# + shared
|
93
|
+
# | + foo
|
94
|
+
# | + lib
|
95
|
+
# | + bar # Will be overridden with file found in specific
|
96
|
+
# |
|
97
|
+
# + specific
|
98
|
+
# + lib
|
99
|
+
# | + bar
|
100
|
+
# |
|
101
|
+
# + other
|
102
|
+
#
|
103
|
+
# => { 'foo' => '/path/templates/shared/foo',
|
104
|
+
# 'lib/bar' => '/path/templates/specific/bar',
|
105
|
+
# 'other' => '/path/templates/specific/other' }
|
106
|
+
#
|
107
|
+
# Parameters:
|
108
|
+
#
|
109
|
+
# [*paths] Paths to directories to gather files from
|
110
|
+
|
111
|
+
def template_files(*paths)
|
112
|
+
files = {}
|
113
|
+
|
114
|
+
Find.find(*paths) do |path|
|
115
|
+
Find.prune if path[-1].chr == '.'
|
116
|
+
|
117
|
+
next if File.stat(path).directory?
|
118
|
+
next if (key = path.gsub(/.*\/templates\/[^\/]+\//, '')) == ''
|
119
|
+
|
120
|
+
files[key] = path
|
121
|
+
end
|
122
|
+
|
123
|
+
return files
|
124
|
+
end
|
125
|
+
|
126
|
+
# Creates the target file from the source including some substitution
|
127
|
+
# of variables. The target path needs not to exist, as directories are
|
128
|
+
# added on the fly. If the source is an executable, the target file will
|
129
|
+
# be set executable, too.
|
130
|
+
#
|
131
|
+
# Parameters:
|
132
|
+
#
|
133
|
+
# [source] Source file
|
134
|
+
# [target] Target file
|
135
|
+
|
136
|
+
def process_file(source, target)
|
137
|
+
content = File.read(source).gsub(/\{\{[^}]*\}\}/) do |match|
|
138
|
+
case match
|
139
|
+
when '{{email}}'
|
140
|
+
email
|
141
|
+
when '{{name}}'
|
142
|
+
name
|
143
|
+
else
|
144
|
+
match
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
File.makedirs(File.dirname(target))
|
149
|
+
|
150
|
+
File.open(target, 'wb') do |file|
|
151
|
+
stat = File.stat(source)
|
152
|
+
|
153
|
+
file.write(content)
|
154
|
+
file.chmod(stat.mode | 0x111) if stat.executable?
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the directory where the template files reside (located
|
159
|
+
# relative to the source file of class JRubyEnginize::Generator).
|
160
|
+
|
161
|
+
def self.templates_directory
|
162
|
+
return File.join(File.dirname(File.dirname(__FILE__)), 'templates')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
data/lib/script.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# JRuby-Enginize, a generator for Google AppEngine compliant JRuby apps.
|
2
|
+
#
|
3
|
+
# This file contains the JRubyEnginize::Script class refactored to keep the
|
4
|
+
# executables lean.
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
require 'rubygems'
|
8
|
+
|
9
|
+
require 'lib/generator'
|
10
|
+
|
11
|
+
module JRubyEnginize # :nodoc:
|
12
|
+
|
13
|
+
# Commandline code refactored to keep the executables lean.
|
14
|
+
|
15
|
+
module Script
|
16
|
+
|
17
|
+
# Command line code for the <tt>"jruby-enginize"</tt> executable. Call
|
18
|
+
# with <tt>"--help"</tt> to learn more. Checks for running on JRuby and
|
19
|
+
# having the Google AppEngine SDK around and forwards work to
|
20
|
+
# JRubyEnginize::Generator.
|
21
|
+
|
22
|
+
def self.enginize
|
23
|
+
email = nil
|
24
|
+
template = 'sinatra'
|
25
|
+
path = nil
|
26
|
+
|
27
|
+
prog = File.basename($0)
|
28
|
+
|
29
|
+
# Check for running with JRuby: The whole generator makes no sense if not
|
30
|
+
# running with or at least for JRuby...
|
31
|
+
|
32
|
+
begin
|
33
|
+
java.lang.String
|
34
|
+
rescue
|
35
|
+
$stderr.puts "!!#{prog} makes only sense on JRuby systems. Please try again."
|
36
|
+
exit(1)
|
37
|
+
end
|
38
|
+
|
39
|
+
# The AppEngine SDK has to be around, too.
|
40
|
+
|
41
|
+
begin
|
42
|
+
raise ArgumentError if not File.stat(`which appcfg.sh`.chop).executable?
|
43
|
+
rescue Exception
|
44
|
+
$stderr.puts "!!AppEngine SDK missing. Please retry after installing."
|
45
|
+
exit(2)
|
46
|
+
end
|
47
|
+
|
48
|
+
options = { :name => nil, :dryrun => false }
|
49
|
+
|
50
|
+
OptionParser.new do |opt|
|
51
|
+
opt.banner = "Usage: #{prog} [options] --email address dirname"
|
52
|
+
|
53
|
+
opt.on('-e', '--email address', 'E-Mail address to publish app with') { |email| }
|
54
|
+
opt.on('-t', '--template name', "Name of the template (defaults to #{template})") { |template| }
|
55
|
+
opt.on('-n', '--name appname', 'Name of the app (defaults to dir basename)') { |name|
|
56
|
+
options[:name] = name }
|
57
|
+
opt.on('-d', '--dry', 'Test run not really creating files') {
|
58
|
+
options[:dryrun] = true }
|
59
|
+
opt.on('-T', '--templates', 'List available templates') {
|
60
|
+
puts 'Supported templates:'
|
61
|
+
JRubyEnginize::Generator.templates.each { |name| puts " #{name}" }
|
62
|
+
exit(0) }
|
63
|
+
|
64
|
+
begin
|
65
|
+
opt.parse!(ARGV)
|
66
|
+
|
67
|
+
raise "missing directory name" if (path = ARGV.first).nil? or path.empty?
|
68
|
+
raise "directory already exists" if FileTest.exists? path
|
69
|
+
|
70
|
+
raise "missing e-mail address" if email.nil? or email.empty?
|
71
|
+
rescue SystemExit
|
72
|
+
exit(1)
|
73
|
+
rescue Exception => exception
|
74
|
+
$stderr.puts "!!#{exception}\n\n"
|
75
|
+
|
76
|
+
opt.parse!(['--help'])
|
77
|
+
|
78
|
+
exit(3)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
JRubyEnginize::Generator.new(email, path, template, options).run
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
README
|
2
|
+
|
3
|
+
This is a generic README generated by jruby-enginize. Please replace with
|
4
|
+
something more meaningful... ;-)
|
5
|
+
|
6
|
+
GOOGLE APPENGINE DEPLOYMENT
|
7
|
+
|
8
|
+
As a basic requirement, copy and split the JRuby-JAR calling
|
9
|
+
|
10
|
+
jrake jruby:splitjars
|
11
|
+
|
12
|
+
once and after each upgrade to a new version of JRuby.
|
13
|
+
|
14
|
+
Deploy the application with
|
15
|
+
|
16
|
+
jrake appengine:deploy
|
17
|
+
|
18
|
+
and open
|
19
|
+
|
20
|
+
http://{{name}}.appspot.com
|
21
|
+
|
22
|
+
to have a first test.
|
23
|
+
|
24
|
+
Be sure to set the version number in "appengine-web.xml" to a new value, when
|
25
|
+
you are experimenting with an unstable version and don't want to risk your
|
26
|
+
users getting exceptions.
|
27
|
+
|
28
|
+
You can try the new version by opening e.g.
|
29
|
+
|
30
|
+
http://3.latest.{{name}}.appspot.com
|
31
|
+
|
32
|
+
and replacing "3" with the version number you want to run.
|
33
|
+
|
34
|
+
Switch the application to the new version as default (stable version) by
|
35
|
+
opening
|
36
|
+
|
37
|
+
http://appengine.google.com/deployment?&app_id={{name}}
|
38
|
+
|
39
|
+
and setting a new default.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
Dir[File.join(File.dirname(__FILE__), 'lib', 'tasks', '*.rake')].each do |ext|
|
6
|
+
load ext
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Display some help and the README'
|
10
|
+
task :help do
|
11
|
+
puts 'Call "jruby -S rake --tasks" to learn what tasks are available...'
|
12
|
+
puts
|
13
|
+
puts File.read('README')
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => [:help]
|
17
|
+
|
18
|
+
namespace :jruby do
|
19
|
+
desc 'Split the way too large JRuby JAR into two smaller files'
|
20
|
+
task :splitjars do
|
21
|
+
puts 'Split the way too large JRuby JAR into two smaller files.'
|
22
|
+
libdir = File.join(File.dirname(__FILE__), 'lib')
|
23
|
+
puts `#{libdir}/split-jruby.sh`
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Runs the splitjars task if splitted files not already exist'
|
27
|
+
task :check4jars do
|
28
|
+
file1 = File.join(File.dirname(__FILE__), 'lib', 'jruby-core.jar')
|
29
|
+
file2 = File.join(File.dirname(__FILE__), 'lib', 'ruby-stdlib.jar')
|
30
|
+
|
31
|
+
begin
|
32
|
+
File.stat(file1)
|
33
|
+
File.stat(file2)
|
34
|
+
rescue Errno::ENOENT
|
35
|
+
puts 'Need to copy and split JAR files. Generating them on the fly now...'
|
36
|
+
Rake::Task['jruby:splitjars'].invoke
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
namespace :appengine do
|
42
|
+
desc 'Create the WAR file for deployment'
|
43
|
+
task :war do
|
44
|
+
puts 'Create the WAR file for deployment.'
|
45
|
+
puts `jruby -S warble`
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Upload the new application code'
|
49
|
+
task :upload do
|
50
|
+
puts 'Upload the new application code (this may take a while).'
|
51
|
+
puts `appcfg.sh --enable_jar_splitting --email={{email}} update tmp/war`
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Roll back a blocked and halfway broken deploy'
|
55
|
+
task :rollback do
|
56
|
+
puts 'Roll back a blocked and halfway broken deploy.'
|
57
|
+
puts `appcfg.sh --enable_jar_splitting rollback tmp/war`
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'Remove temp stuff'
|
61
|
+
task :clean do
|
62
|
+
puts 'Remove temp stuff.'
|
63
|
+
puts `rm -rf tmp slingyard.war`
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'Deploy the application (generating WAR plus uploading files)'
|
67
|
+
task :deploy => ['jruby:check4jars', :war, :upload]
|
68
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
2
|
+
<application>{{name}}</application>
|
3
|
+
<version>1</version>
|
4
|
+
<static-files />
|
5
|
+
<resource-files />
|
6
|
+
<sessions-enabled>false</sessions-enabled>
|
7
|
+
<system-properties>
|
8
|
+
<property name="jruby.management.enabled" value="false" />
|
9
|
+
<property name="os.arch" value="" />
|
10
|
+
<property name="jruby.compile.mode" value="JIT"/> <!-- JIT|FORCE|OFF -->
|
11
|
+
<property name="jruby.compile.fastest" value="true"/>
|
12
|
+
<property name="jruby.compile.frameless" value="true"/>
|
13
|
+
<property name="jruby.compile.positionless" value="true"/>
|
14
|
+
<property name="jruby.compile.threadless" value="false"/>
|
15
|
+
<property name="jruby.compile.fastops" value="false"/>
|
16
|
+
<property name="jruby.compile.fastcase" value="false"/>
|
17
|
+
<property name="jruby.compile.chainsize" value="500"/>
|
18
|
+
<property name="jruby.compile.lazyHandles" value="false"/>
|
19
|
+
<property name="jruby.compile.peephole" value="true"/>
|
20
|
+
</system-properties>
|
21
|
+
</appengine-web-app>
|
Binary file
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Utility script for splitting the JRuby JAR into two smaller JAR files. This
|
3
|
+
# is a workaround for a limitation of the JAR size in Google AppEngine.
|
4
|
+
#
|
5
|
+
# The code for this script has been taken from hints and links found at
|
6
|
+
# http://jruby-rack.appspot.com.
|
7
|
+
|
8
|
+
SCRIPTHOME=`dirname $0`
|
9
|
+
JRUBY=`which jruby`
|
10
|
+
|
11
|
+
if [ ! -x "$JRUBY" ]; then
|
12
|
+
echo "!!Missing jruby executable. Please check installation." > /dev/stderr
|
13
|
+
exit 1
|
14
|
+
fi
|
15
|
+
|
16
|
+
# See where the jruby binary is installed and find the JRuby JAR from there.
|
17
|
+
|
18
|
+
PREFIX=`dirname \`dirname $JRUBY\``
|
19
|
+
JARFILE="$PREFIX/share/java/jruby/lib/jruby-complete.jar"
|
20
|
+
|
21
|
+
if [ ! -f "$JARFILE" ]; then
|
22
|
+
PREFIX=`dirname \`dirname $JRUBY\``
|
23
|
+
JARFILE="$PREFIX/lib/jruby-complete.jar"
|
24
|
+
fi
|
25
|
+
|
26
|
+
if [ ! -f "$JARFILE" ]; then
|
27
|
+
echo "!!Missing JRuby JAR. Please check installation." > /dev/stderr
|
28
|
+
exit 1
|
29
|
+
fi
|
30
|
+
|
31
|
+
echo "Using $JARFILE for splitting"
|
32
|
+
echo "and assembling a AppEngine savvy version of the JRuby JAR in the lib "
|
33
|
+
echo "directory."
|
34
|
+
|
35
|
+
cd $SCRIPTHOME
|
36
|
+
|
37
|
+
rm -rf jruby-core.jar
|
38
|
+
rm -rf ruby-stdlib.jar
|
39
|
+
rm -rf tmp_unpack
|
40
|
+
|
41
|
+
mkdir -p tmp_unpack
|
42
|
+
cd tmp_unpack
|
43
|
+
|
44
|
+
jar xf $JARFILE
|
45
|
+
|
46
|
+
cd ..
|
47
|
+
|
48
|
+
mkdir -p jruby-core
|
49
|
+
|
50
|
+
mv tmp_unpack/org jruby-core
|
51
|
+
mv tmp_unpack/com jruby-core
|
52
|
+
mv tmp_unpack/jline jruby-core
|
53
|
+
mv tmp_unpack/jay jruby-core
|
54
|
+
mv tmp_unpack/jruby jruby-core
|
55
|
+
|
56
|
+
cd jruby-core
|
57
|
+
|
58
|
+
jar cf ../jruby-core.jar .
|
59
|
+
|
60
|
+
cd ../tmp_unpack
|
61
|
+
|
62
|
+
jar cf ../ruby-stdlib.jar .
|
63
|
+
|
64
|
+
cd ..
|
65
|
+
|
66
|
+
rm -rf jruby-core
|
67
|
+
rm -rf tmp_unpack
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This application files as generated by jruby-enginize.
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'haml'
|
7
|
+
require 'sass'
|
8
|
+
require 'sinatra'
|
9
|
+
rescue LoadError => exception
|
10
|
+
$stderr.puts '!!missing sinatra. Install sinatra gem and try again.'
|
11
|
+
exit(1)
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /
|
15
|
+
|
16
|
+
get '/' do
|
17
|
+
haml :index
|
18
|
+
end
|
19
|
+
|
20
|
+
# GET /stylesheet.css
|
21
|
+
|
22
|
+
get '/stylesheet.css' do
|
23
|
+
content_type 'text/css', :charset => 'utf-8'
|
24
|
+
|
25
|
+
sass :stylesheet
|
26
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Disable automatic framework detection by uncommenting/setting to false
|
2
|
+
# Warbler.framework_detection = false
|
3
|
+
|
4
|
+
# Warbler web application assembly configuration file
|
5
|
+
Warbler::Config.new do |config|
|
6
|
+
# Temporary directory where the application is staged
|
7
|
+
# config.staging_dir = "tmp/war"
|
8
|
+
|
9
|
+
# Application directories to be included in the webapp.
|
10
|
+
config.dirs = %w(lib public views)
|
11
|
+
|
12
|
+
# Additional files/directories to include, above those in config.dirs
|
13
|
+
# config.includes = FileList["db"]
|
14
|
+
config.includes = FileList["appengine-web.xml", "app.rb", "config.ru"]
|
15
|
+
# Additional files/directories to exclude
|
16
|
+
# config.excludes = FileList["lib/tasks/*"]
|
17
|
+
|
18
|
+
# Additional Java .jar files to include. Note that if .jar files are placed
|
19
|
+
# in lib (and not otherwise excluded) then they need not be mentioned here.
|
20
|
+
# JRuby and JRuby-Rack are pre-loaded in this list. Be sure to include your
|
21
|
+
# own versions if you directly set the value
|
22
|
+
# config.java_libs += FileList["lib/java/*.jar"]
|
23
|
+
|
24
|
+
# Loose Java classes and miscellaneous files to be placed in WEB-INF/classes.
|
25
|
+
# config.java_classes = FileList["target/classes/**.*"]
|
26
|
+
|
27
|
+
# One or more pathmaps defining how the java classes should be copied into
|
28
|
+
# WEB-INF/classes. The example pathmap below accompanies the java_classes
|
29
|
+
# configuration above. See http://rake.rubyforge.org/classes/String.html#M000017
|
30
|
+
# for details of how to specify a pathmap.
|
31
|
+
# config.pathmaps.java_classes << "%{target/classes/,}p"
|
32
|
+
|
33
|
+
# Gems to be included. You need to tell Warbler which gems your application needs
|
34
|
+
# so that they can be packaged in the war file.
|
35
|
+
# The Rails gems are included by default unless the vendor/rails directory is present.
|
36
|
+
# config.gems += ["activerecord-jdbcmysql-adapter", "jruby-openssl"]
|
37
|
+
# config.gems << "tzinfo"
|
38
|
+
config.gems = ['sinatra', 'haml']
|
39
|
+
|
40
|
+
# Uncomment this if you don't want to package rails gem.
|
41
|
+
# config.gems -= ["rails"]
|
42
|
+
|
43
|
+
# The most recent versions of gems are used.
|
44
|
+
# You can specify versions of gems by using a hash assignment:
|
45
|
+
# config.gems["rails"] = "2.0.2"
|
46
|
+
|
47
|
+
# You can also use regexps or Gem::Dependency objects for flexibility or
|
48
|
+
# fine-grained control.
|
49
|
+
# config.gems << /^merb-/
|
50
|
+
# config.gems << Gem::Dependency.new("merb-core", "= 0.9.3")
|
51
|
+
|
52
|
+
# Include gem dependencies not mentioned specifically
|
53
|
+
config.gem_dependencies = true
|
54
|
+
|
55
|
+
# Files to be included in the root of the webapp. Note that files in public
|
56
|
+
# will have the leading 'public/' part of the path stripped during staging.
|
57
|
+
# config.public_html = FileList["public/**/*", "doc/**/*"]
|
58
|
+
|
59
|
+
# Pathmaps for controlling how public HTML files are copied into the .war
|
60
|
+
# config.pathmaps.public_html = ["%{public/,}p"]
|
61
|
+
|
62
|
+
# Name of the war file (without the .war) -- defaults to the basename
|
63
|
+
# of RAILS_ROOT
|
64
|
+
config.war_name = "{{name}}"
|
65
|
+
|
66
|
+
# Name of the MANIFEST.MF template for the war file. Defaults to the
|
67
|
+
# MANIFEST.MF normally generated by `jar cf`.
|
68
|
+
# config.manifest_file = "config/MANIFEST.MF"
|
69
|
+
|
70
|
+
# Value of RAILS_ENV for the webapp -- default as shown below
|
71
|
+
# config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
|
72
|
+
|
73
|
+
# Application booter to use, one of :rack, :rails, or :merb. (Default :rails)
|
74
|
+
# config.webxml.booter = :rack
|
75
|
+
config.webxml.booter = :rack
|
76
|
+
|
77
|
+
# When using the :rack booter, "Rackup" script to use.
|
78
|
+
# The script is evaluated in a Rack::Builder to load the application.
|
79
|
+
# Examples:
|
80
|
+
# config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)}
|
81
|
+
# config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru"))
|
82
|
+
|
83
|
+
# Control the pool of Rails runtimes. Leaving unspecified means
|
84
|
+
# the pool will grow as needed to service requests. It is recommended
|
85
|
+
# that you fix these values when running a production server!
|
86
|
+
# config.webxml.jruby.min.runtimes = 2
|
87
|
+
# config.webxml.jruby.max.runtimes = 4
|
88
|
+
config.webxml.jruby.min.runtimes = 1
|
89
|
+
config.webxml.jruby.max.runtimes = 1
|
90
|
+
config.webxml.jruby.init.serial = true
|
91
|
+
|
92
|
+
# JNDI data source name
|
93
|
+
# config.webxml.jndi = 'jdbc/rails'
|
94
|
+
config.java_libs = []
|
95
|
+
end
|
Binary file
|
@@ -0,0 +1,17 @@
|
|
1
|
+
%center
|
2
|
+
%div{ :id => 'main' }
|
3
|
+
%center
|
4
|
+
%p
|
5
|
+
%img{ :src => '/images/appengine_logo.png' }
|
6
|
+
%h1
|
7
|
+
Hi folks! Nice to meet you here!
|
8
|
+
%p
|
9
|
+
This is
|
10
|
+
%a{ :href => 'http://code.google.com/appengine' } Google AppEngine
|
11
|
+
running the
|
12
|
+
%a{ :href => 'http://www.sinatrarb.com' } Sinatra
|
13
|
+
framework.
|
14
|
+
%p
|
15
|
+
%img{ :src => '/images/sinatra_logo.png' }
|
16
|
+
%div{ :id => 'footer' }
|
17
|
+
This small application was generated by JRuby-Enginize.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
body
|
2
|
+
:background #bbbbbb
|
3
|
+
:color #000000
|
4
|
+
:font-family helvetica
|
5
|
+
:font-size 12pt
|
6
|
+
|
7
|
+
h1, h2, h3, h4, h5, h6
|
8
|
+
:font-family helvetica
|
9
|
+
|
10
|
+
h1
|
11
|
+
:font-size 18pt
|
12
|
+
|
13
|
+
h2
|
14
|
+
:font-size 16pt
|
15
|
+
|
16
|
+
h3
|
17
|
+
:font-size 14pt
|
18
|
+
|
19
|
+
h4, h5, h6
|
20
|
+
:font-size 12pt
|
21
|
+
|
22
|
+
a
|
23
|
+
:color #000000
|
24
|
+
:text-decoration none
|
25
|
+
:border-bottom 1px dotted
|
26
|
+
|
27
|
+
a:hover
|
28
|
+
:border-bottom 1px solid
|
29
|
+
|
30
|
+
div
|
31
|
+
:width 580px
|
32
|
+
:padding 3px 5px
|
33
|
+
:text-align left
|
34
|
+
|
35
|
+
#main
|
36
|
+
:background #ffffff
|
37
|
+
:margin-top 50px
|
38
|
+
:height auto
|
39
|
+
:border 1px solid #808080
|
40
|
+
|
41
|
+
#footer
|
42
|
+
:padding-left 0px
|
43
|
+
:font-size 9pt
|
44
|
+
:color #404040
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ulbrich-jruby-enginize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Ulbrich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: jan.ulbrich @nospam@ holtzbrinck.com
|
18
|
+
executables:
|
19
|
+
- jruby-enginize
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- bin/jruby-enginize
|
26
|
+
- lib/generator.rb
|
27
|
+
- lib/script.rb
|
28
|
+
- templates/sinatra/views/stylesheet.sass
|
29
|
+
- templates/sinatra/views/layout.haml
|
30
|
+
- templates/sinatra/views/index.haml
|
31
|
+
- templates/sinatra/public/images/sinatra_logo.png
|
32
|
+
- templates/sinatra/lib/tasks/sinatra.rake
|
33
|
+
- templates/sinatra/config.ru
|
34
|
+
- templates/sinatra/config/warble.rb
|
35
|
+
- templates/sinatra/app.rb
|
36
|
+
- templates/shared/README
|
37
|
+
- templates/shared/Rakefile
|
38
|
+
- templates/shared/public/images/appengine_logo.png
|
39
|
+
- templates/shared/lib/split-jruby.sh
|
40
|
+
- templates/shared/lib/jruby-rack-0.9.4.jar
|
41
|
+
- templates/shared/appengine-web.xml
|
42
|
+
- README
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://github.com/ulbrich/jruby-enginize
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --exclude
|
48
|
+
- pkg
|
49
|
+
- --exclude
|
50
|
+
- templates
|
51
|
+
- --all
|
52
|
+
- --title
|
53
|
+
- JRuby-Enginize
|
54
|
+
- --main
|
55
|
+
- README
|
56
|
+
require_paths:
|
57
|
+
- .
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "0"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.2.0
|
74
|
+
signing_key:
|
75
|
+
specification_version: 2
|
76
|
+
summary: A package for generating Google AppEngine compliant JRuby projects.
|
77
|
+
test_files: []
|
78
|
+
|