jruby-enginize 0.8

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.rdoc ADDED
@@ -0,0 +1,135 @@
1
+ = JRuby-Enginize
2
+
3
+ == About
4
+
5
+ JRuby-Enginize is a generator for Google AppEngine compliant JRuby
6
+ applications. The generator currently supports Sinatra and Merb with more
7
+ frameworks to come in the future. 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. For more about JRuby, please go to http://www.codehaus.org and see
10
+ what's up running Ruby applications on a Java VM.
11
+
12
+ == Prerequisites
13
+
14
+ JRuby-Enginize needs a proper JRuby installation including rake and the
15
+ Google AppEngine SDK (http://code.google.com/appengine/downloads.html) for
16
+ Java. Make sure that the AppEngine configuration tool "appcfg.sh" is in your
17
+ PATH as that's what parts of the software are wrapping.
18
+
19
+ More dependencies depend on the framework template to generate an application
20
+ for, but installation of additional gems is done with tools provided by
21
+ Google (so below).
22
+
23
+ == Installation
24
+
25
+ The Google people worked hard to make JRuby easier to deploy than it was at
26
+ the beginning, so don't blindly trust all those blog posts and samples you'll
27
+ find but use the newest version of jruby-enginize and have a look at the Wiki
28
+ page of the Google AppEngine JRuby tools
29
+ (http://code.google.com/p/appengine-jruby/wiki/GettingStarted)
30
+ to learn about the details beyond.
31
+
32
+ These are the steps for installing the Google tools plus JRuby-Enginize
33
+ running on top of it to streamline your first steps:
34
+
35
+ sudo gem sources -a http://gems.github.com # Only needed once!
36
+ sudo gem install google-appengine
37
+ sudo gem install ulbrich-jruby-enginize
38
+
39
+ You also need an Google AppEngine account to actually publish your code.
40
+ Without account you can still play around with the tools and run applications
41
+ locally.
42
+
43
+ == Using jruby-enginize
44
+
45
+ JRuby-Enginize includes is a single executable named <tt>jruby-enginize</tt>
46
+ which is inspired by the <tt>rails</tt> tool for generating Rails applications.
47
+ So just call
48
+
49
+ jruby-enginize
50
+
51
+ and have a look at the options.
52
+
53
+ Here are the steps for creating and deploying a new Sinatra application:
54
+
55
+ * Register with Google AppEngine and create a new application ID.
56
+
57
+ * Generate your application with that new ID as directory name. Sample:
58
+
59
+ <tt>jruby-enginize --template sinatra jruby-enginize</tt>
60
+
61
+ * Go to the new directory and install the missing gems first (depends on the
62
+ template you have chosen):
63
+
64
+ <tt>rake template:gems</tt>
65
+
66
+ !!Attention: Whenever you want to install additional gems, be sure
67
+ to use <tt>appcfg.rb gem</tt> provided by the Google AppEngine JRuby tools
68
+ and not <tt>jgem</tt> as Google maintains a local repository per project and
69
+ bundles the files to upload from that information. You will run into missing
70
+ gems on the server if you bypass this! Best approach is to use a separate
71
+ JRuby installation for AppEngine development to run into missing gems when
72
+ running the application locally, too.
73
+
74
+ * Learn about the available rake tasks
75
+
76
+ <tt>rake --tasks</tt>
77
+
78
+ * Try out your application locally:
79
+
80
+ <tt>sudo rake appengine:run</tt>
81
+
82
+ * Deploy the application:
83
+
84
+ <tt>rake appengine:deploy</tt>
85
+
86
+ The first time you deploy your application, you will be asked for e-mail and
87
+ password to confirm your upload to the server.
88
+
89
+ You can repeat the deployment whenever you want. Be sure to set the version
90
+ number in the AppEngine::Rack.configure_app part of "config.ru" to a new
91
+ value, when you are experimenting with an unstable version and don't want to
92
+ risk your users getting exceptions.
93
+
94
+ You can try the new version by opening e.g.
95
+
96
+ <tt>http://3.latest.jruby-enginize.appspot.com</tt>
97
+
98
+ and replacing "3" with the version number you want to run.
99
+
100
+ Switch the application to the new version as default (stable version) by
101
+ opening
102
+
103
+ <tt>http://appengine.google.com/deployment?&app_id=jruby-enginize</tt>
104
+
105
+ and setting a new default available at
106
+
107
+ <tt>http://jruby-enginize.appspot.com</tt>
108
+
109
+ A small README with these and a few more application specific hints is
110
+ generated along with the source code. Have fun.
111
+
112
+ == Copyright & License
113
+
114
+ Copyright (c) 2009 Holtzbrinck Digital GmbH, Jan Ulbrich
115
+
116
+ Permission is hereby granted, free of charge, to any person
117
+ obtaining a copy of this software and associated documentation
118
+ files (the "Software"), to deal in the Software without
119
+ restriction, including without limitation the rights to use,
120
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
121
+ copies of the Software, and to permit persons to whom the
122
+ Software is furnished to do so, subject to the following
123
+ conditions:
124
+
125
+ The above copyright notice and this permission notice shall be
126
+ included in all copies or substantial portions of the Software.
127
+
128
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
129
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
130
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
131
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
132
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
133
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
134
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
135
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ #!//usr/bin/env ruby
2
+ # JRuby-Enginize, a generator for Google AppEngine compliant JRuby apps.
3
+
4
+ require 'lib/script'
5
+
6
+ JRubyEnginize::Script.enginize
data/lib/generator.rb ADDED
@@ -0,0 +1,212 @@
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
+ require 'digest/md5'
9
+
10
+ module JRubyEnginize # :nodoc:
11
+
12
+ # Code for generating a directory tree created from a shared and a template
13
+ # specific set of template files.
14
+
15
+ class Generator
16
+ attr_reader :email, :template, :name, :path, :dryrun
17
+
18
+ # Constructor of the generator needing at least email, path and template
19
+ # to run.
20
+ #
21
+ # Parameters:
22
+ #
23
+ # [email] Mail address of the Google AppEngine account to publish with
24
+ # [path] Path of the directory to create
25
+ # [template] Name of the set of templates to generate from
26
+ # [options] Additional options
27
+ #
28
+ # Options:
29
+ #
30
+ # [:name] Optional app name defaulting to name of directory
31
+ # [:dryrun] Flag to enable
32
+
33
+ def initialize(email, path, template, options = {})
34
+ @email = email
35
+ @path = path
36
+ @template = template
37
+
38
+ options = options.dup
39
+
40
+ @name = options.delete(:name)
41
+ @name = File.basename(path) if @name.nil? or @name.empty?
42
+
43
+ @dryrun = options.delete(:dryrun)
44
+
45
+ raise ArgumentError, "Unknown option(s) #{options.keys.join(', ')}" unless options.empty?
46
+ end
47
+
48
+ # Runs the generator. Starts with setting up a map of files to create
49
+ # and overriding shared ones with template specific stuff. Runs through
50
+ # the collected files and calls process_file to render new files in the
51
+ # target path.
52
+
53
+ def run
54
+ templatesdir = Generator::templates_directory
55
+
56
+ shareddir = File.join(templatesdir, 'shared')
57
+ templatedir = File.join(templatesdir, template)
58
+
59
+ raise ArgumentError, 'Missing shared templates' unless File.stat(shareddir).directory?
60
+ raise ArgumentError, "Template \"#{template}\" missing" unless File.stat(templatedir).directory?
61
+
62
+ if dryrun
63
+ puts "Dry run which would generate the following files from template \"#{template}\":"
64
+ else
65
+ puts "Generating files from template \"#{template}\"."
66
+ end
67
+
68
+ template_files(shareddir, templatedir).each do |key, path|
69
+ target = File.join(self.path, key)
70
+
71
+ if dryrun
72
+ puts " Creating \"#{target}\" from template\n file \"#{path}\""
73
+ else
74
+ process_file(path, target)
75
+ end
76
+ end
77
+
78
+ if not dryrun
79
+ puts "Done with directory \"#{self.path}\"."
80
+
81
+ puts "\nYour next steps:\n cd #{self.path}\n\n rake template:gems"
82
+ puts "\n rake\n rake --tasks"
83
+ puts "\n sudo rake appengine:run # First call may fail: Just retry!"
84
+ puts "\n rake appengine:deploy"
85
+ end
86
+ end
87
+
88
+ # Returns an Array with the available template names.
89
+
90
+ def self.templates
91
+ return Dir[File.join(Generator::templates_directory, '*')].collect { |path|
92
+ (name = File.basename(path)) == 'shared' ? nil : name }.compact
93
+ end
94
+
95
+ protected
96
+
97
+ # Returns a Hash with relative paths of files as keys and the whole
98
+ # paths as values. Runs through all paths in the order as provided and
99
+ # overrides keys with files found in later paths.
100
+ #
101
+ # Sample:
102
+ #
103
+ # + templates
104
+ # + shared
105
+ # | + foo
106
+ # | + lib
107
+ # | + bar # Will be overridden with file found in specific
108
+ # |
109
+ # + specific
110
+ # + lib
111
+ # | + bar
112
+ # |
113
+ # + other
114
+ #
115
+ # => { 'foo' => '/path/templates/shared/foo',
116
+ # 'lib/bar' => '/path/templates/specific/bar',
117
+ # 'other' => '/path/templates/specific/other' }
118
+ #
119
+ # Parameters:
120
+ #
121
+ # [*paths] Paths to directories to gather files from
122
+
123
+ def template_files(*paths)
124
+ files = {}
125
+
126
+ Find.find(*paths) do |path|
127
+ Find.prune if path[-1].chr == '.'
128
+
129
+ next if File.stat(path).directory?
130
+ next if (key = path.gsub(/.*\/templates\/[^\/]+\//, '')) == ''
131
+
132
+ files[key] = path
133
+ end
134
+
135
+ return files
136
+ end
137
+
138
+ # Creates the target file from the source including some substitution
139
+ # of variables. The target path needs not to exist, as directories are
140
+ # added on the fly. If the source is an executable, the target file will
141
+ # be set executable, too.
142
+ #
143
+ # Parameters:
144
+ #
145
+ # [source] Source file
146
+ # [target] Target file
147
+ #
148
+ # The source files may contain some variables which are replaced on the
149
+ # fly. All variables are set in double curly brackets and are let passed
150
+ # without modification if they ar not recognized.
151
+ #
152
+ # Supported variables:
153
+ #
154
+ # [{{email}}] E-mail address of the Google AppEngine account
155
+ # [{{name}}] Name of the application
156
+ # [{{template}}] Name of the template (e.g. "sinatra")
157
+ # [{{hexrand-xx}}] Hexadecimal random string with xx characters
158
+ # [{{numrand-xx}}] Random number with xx digits
159
+
160
+ def process_file(source, target)
161
+ content = File.read(source).gsub(/\{\{[^}]*\}\}/) do |variable|
162
+ case variable
163
+ when '{{email}}'
164
+ raise 'missing e-mail address' if email.nil? or email.empty?
165
+ email
166
+ when '{{name}}'
167
+ name
168
+ else
169
+ if hexrand = variable.match(/\{\{hexrand-([0-9]+)\}\}/) and
170
+ hexrand.length == 2 and (len = hexrand[1].to_i) > 0
171
+ then
172
+ str = ''
173
+
174
+ while str.length < len do
175
+ str << Digest::MD5.hexdigest("#{rand}-#{Time.now}-#{rand}")
176
+ end
177
+
178
+ str[0, len]
179
+ elsif numrand = variable.match(/\{\{numrand-([0-9]+)\}\}/) and
180
+ numrand.length == 2 and (len = numrand[1].to_i) > 0
181
+ then
182
+ str = ''
183
+
184
+ while str.length < len do
185
+ str << rand.to_s.sub(/^.*\.0*/, '')
186
+ end
187
+
188
+ str[0, len]
189
+ else
190
+ variable
191
+ end
192
+ end
193
+ end
194
+
195
+ File.makedirs(File.dirname(target))
196
+
197
+ File.open(target, 'wb') do |file|
198
+ stat = File.stat(source)
199
+
200
+ file.write(content)
201
+ file.chmod(stat.mode | 0x111) if stat.executable?
202
+ end
203
+ end
204
+
205
+ # Returns the directory where the template files reside (located
206
+ # relative to the source file of class JRubyEnginize::Generator).
207
+
208
+ def self.templates_directory
209
+ return File.join(File.dirname(File.dirname(__FILE__)), 'templates')
210
+ end
211
+ end
212
+ end
data/lib/script.rb ADDED
@@ -0,0 +1,90 @@
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
+ =begin
30
+ # Check for running with JRuby: The whole generator makes no sense if not
31
+ # running with or at least for JRuby...
32
+
33
+ begin
34
+ java.lang.String
35
+ rescue
36
+ $stderr.puts "!!#{prog} makes only sense on JRuby systems. Please try again."
37
+ exit(1)
38
+ end
39
+ =end
40
+
41
+ # The AppEngine SDK has to be around, too.
42
+
43
+ begin
44
+ raise ArgumentError if not File.stat(`which appcfg.sh`.chop).executable?
45
+ rescue Exception
46
+ $stderr.puts "!!AppEngine SDK missing. Please retry after installing and make sure that"
47
+ $stderr.puts "AppEngine configuration tool \"appcfg.sh\" is in your PATH."
48
+
49
+ exit(2)
50
+ end
51
+
52
+ options = { :name => nil, :dryrun => false }
53
+
54
+ OptionParser.new do |opt|
55
+ opt.banner = "Usage: #{prog} [options] --email address dirname"
56
+
57
+ opt.on('-e', '--email address', 'E-Mail address to publish app with') { |email| }
58
+ opt.on('-t', '--template name', "Name of the template (defaults to #{template})") { |template| }
59
+ opt.on('-n', '--name appname', 'Name of the app (defaults to dir basename)') { |name|
60
+ options[:name] = name }
61
+ opt.on('-d', '--dry', 'Test run not really creating files') {
62
+ options[:dryrun] = true }
63
+ opt.on('-T', '--templates', 'List available templates') {
64
+ puts 'Supported templates:'
65
+ JRubyEnginize::Generator.templates.each { |name| puts " #{name}" }
66
+ exit(0) }
67
+
68
+ begin
69
+ opt.parse!(ARGV)
70
+
71
+ raise 'missing directory name' if (path = ARGV.first).nil? or path.empty?
72
+ raise 'directory already exists' if FileTest.exists? path
73
+ raise 'unknown template' if not JRubyEnginize::Generator.templates.include? template
74
+
75
+ raise 'missing e-mail address' if email.nil? or email.empty?
76
+ rescue SystemExit
77
+ exit(1)
78
+ rescue Exception => exception
79
+ $stderr.puts "!!#{exception}\n\n"
80
+
81
+ opt.parse!(['--help'])
82
+
83
+ exit(3)
84
+ end
85
+ end
86
+
87
+ JRubyEnginize::Generator.new(email, path, template, options).run
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,21 @@
1
+ .DS_Store
2
+ log/*
3
+ tmp/*
4
+ TAGS
5
+ *~
6
+ .#*
7
+ schema/schema.rb
8
+ schema/*_structure.sql
9
+ schema/*.sqlite3
10
+ schema/*.sqlite
11
+ schema/*.db
12
+ *.sqlite
13
+ *.sqlite3
14
+ *.db
15
+ src/*
16
+ .hgignore
17
+ .hg/*
18
+ .svn/*
19
+ gems/gems/*
20
+ gems/specifications/*
21
+ merb_profile_results
@@ -0,0 +1,31 @@
1
+ # This application file was generated by jruby-enginize.
2
+
3
+ begin
4
+ require 'appengine-apis/merb-logger'
5
+ rescue Exception
6
+ end
7
+
8
+ # Class EngineApp implements the only controller of this application.
9
+
10
+ class EngineApp < Merb::Controller
11
+ layout :engine_app
12
+
13
+ # Returns the location of the template depending on controller and action.
14
+ # Modified to match our flat world.
15
+ #
16
+ # Parameters:
17
+ #
18
+ # [action] Name of the action
19
+ # [type] Requested format
20
+ # [controller] Name of the controller
21
+
22
+ def _template_location(action, type = nil, controller = controller_name)
23
+ (controller == 'layout' ? "layout.#{action}.#{type}" : "#{action}.#{type}")
24
+ end
25
+
26
+ # GET /
27
+
28
+ def index
29
+ render
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ Merb::Config[:framework] = {
2
+ :application => Merb.root / 'app.rb',
3
+ :config => [Merb.root / 'config', nil],
4
+ :public => [Merb.root / 'public', nil],
5
+ :view => Merb.root / 'views'
6
+ }
7
+
@@ -0,0 +1,37 @@
1
+ # Go to http://wiki.merbivore.com/pages/init-rb
2
+
3
+ # use_orm :none
4
+ use_test :rspec
5
+ use_template_engine :erb
6
+
7
+ # Specify a specific version of a dependency
8
+ # dependency "RedCloth", "> 3.0"
9
+
10
+ Merb::BootLoader.before_app_loads do
11
+ # This will get executed after dependencies have been loaded but before your app's classes have loaded.
12
+ end
13
+
14
+ Merb::BootLoader.after_app_loads do
15
+ # This will get executed after your app's classes have been loaded.
16
+ end
17
+
18
+ # Move this to app.rb if you want it to be reloadable in dev mode.
19
+ Merb::Router.prepare do
20
+ match('/').to(:controller => 'engine_app', :action =>'index')
21
+
22
+ default_routes
23
+ end
24
+
25
+ Merb::Config.use { |c|
26
+ c[:environment] = 'production',
27
+ c[:framework] = {},
28
+ c[:log_level] = :debug,
29
+ c[:log_stream] = STDOUT,
30
+ c[:use_mutex] = false,
31
+ c[:session_store] = 'cookie',
32
+ c[:session_id_key] = '_{{name}}_session_id',
33
+ c[:session_secret_key] = '{{hexrand-41}}',
34
+ c[:exception_details] = false,
35
+ c[:reload_classes] = false,
36
+ c[:reload_templates] = false
37
+ }
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'appengine-rack'
3
+
4
+ require 'merb-core'
5
+
6
+ AppEngine::Rack.configure_app(
7
+ # :ssl_enabled => true,
8
+ :application => '{{name}}',
9
+ :version => 1)
10
+
11
+ Merb::Config.setup(:merb_root => File.dirname(__FILE__),
12
+ :environment => ENV['RACK_ENV'])
13
+
14
+ Merb.environment = Merb::Config[:environment]
15
+ Merb.root = Merb::Config[:merb_root]
16
+
17
+ Merb::BootLoader.run
18
+
19
+ run Merb::Rack::Application.new
@@ -0,0 +1,44 @@
1
+ # Tasks provided by Merb are guarded with a rescue block as we need this file
2
+ # to work prior to installation of Merb.
3
+
4
+ begin
5
+ require 'merb-core'
6
+ require 'merb-core/tasks/merb'
7
+
8
+ include FileUtils
9
+
10
+ # Load the basic runtime dependencies; this will include
11
+ # any plugins and therefore plugin rake tasks.
12
+ init_env = ENV['MERB_ENV'] || 'rake'
13
+ Merb.load_dependencies(:environment => init_env)
14
+
15
+ # Get Merb plugins and dependencies
16
+ Merb::Plugins.rakefiles.each { |r| require r }
17
+
18
+ # Load any app level custom rakefile extensions from lib/tasks
19
+ tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks")
20
+ rake_files = Dir["#{tasks_path}/*.rake"]
21
+ rake_files.each{|rake_file| load rake_file }
22
+
23
+ require 'spec/rake/spectask'
24
+ require 'merb-core/test/tasks/spectasks'
25
+ rescue Exception
26
+ end
27
+
28
+ # Task for loading gems needed by this template. Bootstrap to get installed...
29
+
30
+ namespace :template do
31
+ desc 'Load missing gems to local gem repository'
32
+ task :gems do
33
+ appcfg = which_executable('appcfg.rb')
34
+
35
+ puts 'Load missing gems to local gem repository'
36
+ `(sudo #{appcfg} gem install appengine-apis extlib merb-core) 1>&2`
37
+ end
38
+ end
39
+
40
+ # Add your own tasks...
41
+
42
+ namespace :merb do
43
+ end
44
+
@@ -0,0 +1,55 @@
1
+ body {
2
+ background: #bbbbbb;
3
+ color: #000000;
4
+ font-family: helvetica;
5
+ font-size: 12pt;
6
+ }
7
+
8
+ h1, h2, h3, h4, h5, h6 {
9
+ font-family: helvetica;
10
+ }
11
+
12
+ h1 {
13
+ font-size: 18pt;
14
+ }
15
+
16
+ h2 {
17
+ font-size: 16pt;
18
+ }
19
+
20
+ h3 {
21
+ font-size: 14pt;
22
+ }
23
+
24
+ h4, h5, h6 {
25
+ font-size: 12pt;
26
+ }
27
+
28
+ a {
29
+ color: inherit;
30
+ text-decoration: none;
31
+ border-bottom: 1px dotted;
32
+ }
33
+
34
+ a:hover {
35
+ border-bottom: 1px solid;
36
+ }
37
+
38
+ div {
39
+ width: 580px;
40
+ padding: 3px 5px;
41
+ text-align: left;
42
+ }
43
+
44
+ #main {
45
+ background: #ffffff;
46
+ margin-top: 50px;
47
+ height: auto;
48
+ border: 1px solid #808080;
49
+ }
50
+
51
+ #footer {
52
+ padding-left: 0px;
53
+ font-size: 9pt;
54
+ color: #404040;
55
+ }
@@ -0,0 +1,24 @@
1
+ require "rubygems"
2
+
3
+ # Add the local gems dir if found within the app root; any dependencies loaded
4
+ # hereafter will try to load from the local gems before loading system gems.
5
+ if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
6
+ $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(local_gem_dir)
7
+ end
8
+
9
+ require "spec"
10
+ require "merb-core"
11
+
12
+ Merb::Config.use do |c|
13
+ c[:session_store] = "memory"
14
+ end
15
+
16
+ Merb.start_environment(:testing => true,
17
+ :adapter => 'runner',
18
+ :environment => ENV['MERB_ENV'] || 'test')
19
+
20
+ Spec::Runner.configure do |config|
21
+ config.include(Merb::Test::ViewHelper)
22
+ config.include(Merb::Test::RouteHelper)
23
+ config.include(Merb::Test::ControllerHelper)
24
+ end
@@ -0,0 +1,27 @@
1
+ <center>
2
+ <div id='main'>
3
+ <center>
4
+ <p>
5
+ <img src='/images/appengine_logo.png' />
6
+ </p>
7
+ <h1>
8
+ Hi folks! Nice to meet you here!
9
+ </h1>
10
+ <p>
11
+ This is
12
+ <a href='http://code.google.com/appengine'>Google AppEngine</a>
13
+ running the
14
+ <a href='http://www.merbivore.com'>Merb</a>
15
+ framework.
16
+ </p>
17
+ <p>
18
+ <img src='/images/merb_logo.png' />
19
+ </p>
20
+ </center>
21
+ </div>
22
+ <div id='footer'>
23
+ This tiny app was generated by
24
+ <a href='http://github.com/ulbrich/jruby-enginize'>JRuby-Enginize</a>
25
+ to streamline Google AppEngine development.
26
+ </div>
27
+ </center>
@@ -0,0 +1,9 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <link href='/stylesheets/default.css' rel='stylesheet' type='text/css' />
5
+ </head>
6
+ <body>
7
+ <%= catch_content :for_layout %>
8
+ </body>
9
+ </html>
@@ -0,0 +1,71 @@
1
+ README
2
+
3
+ This is a generic README generated by jruby-enginize. Please replace with
4
+ something more meaningful... ;-)
5
+
6
+ INSTALL MISSING GEMS
7
+
8
+ As a basic requirement, you have to install missing gems required by the
9
+ template (this task is implemented individually for each template):
10
+
11
+ rake template:gems
12
+
13
+ !!Attention: Whenever you want to install additional gems, be sure to use
14
+ "appcfg.rb gem" provided by the Google AppEngine JRuby tools and not "jgem" as
15
+ Google maintains a local repository per project and bundles the files to
16
+ upload from that information. You will run into missing gems on the server if
17
+ you bypass this!
18
+
19
+ GOOGLE APPENGINE DEPLOYMENT
20
+
21
+ Deploy the application with
22
+
23
+ rake appengine:deploy
24
+
25
+ and open
26
+
27
+ http://{{name}}.appspot.com
28
+
29
+ to have a first test.
30
+
31
+ Be sure to set the version number in the AppEngine::Rack.configure_app part
32
+ of "config.ru" to a new value, when you are experimenting with an unstable
33
+ version and don't want to risk your users getting exceptions.
34
+
35
+ You can try the new version by opening e.g.
36
+
37
+ http://3.latest.{{name}}.appspot.com
38
+
39
+ and replacing "3" with the version number you want to run.
40
+
41
+ Switch the application to the new version as default (stable version) by
42
+ opening
43
+
44
+ http://appengine.google.com/deployment?&app_id={{name}}
45
+
46
+ and setting a new default.
47
+
48
+ SOME MORE INFO
49
+
50
+ - Gems installed with "appcfg.rb gem" reside in directory ".gems". Again: Do
51
+ not use "jgem" at all!
52
+
53
+ - Some gems will throw exceptions during bundling: Have a look for paths
54
+ assembled using ".." to reach the parent directory and replace with
55
+ File.dirname(...). Retry and be a good citizen and send in the patch the
56
+ developer of that gem... ;-)
57
+
58
+ - Data uploaded to the server is gathered in directory "WEB-INF" as with any
59
+ Java project. The first time "rake appengine:run" or "rake appengine:deploy"
60
+ is called, this directory will be created and "jruby-rack-xx.jar" is
61
+ downloaded from its homepage.
62
+
63
+ The first call to "rake appengine:run" or "rake appengine:deploy" with
64
+ downloading the rack jar will fail. Just ignore and retry.
65
+
66
+ - "WEB-INF/lib/gems.jar" is only created or updated after a call to
67
+ "appcfg.rb gem". This is enforced by "rake appengine:deploy" but not by
68
+ "rake appengine:update".
69
+
70
+ - Sometimes the local test server keeps running after Ctrl-C, so have a look
71
+ at "ps" and manually kill the process if needed.
@@ -0,0 +1,87 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ require 'net/http'
6
+
7
+ Dir[File.join(File.dirname(__FILE__), 'lib', 'tasks', '*.rake')].each do |ext|
8
+ load ext
9
+ end
10
+
11
+ # Helper for retrieving HTML files. Only used to check or trigger things so
12
+ # no highclass implementation...
13
+
14
+ def fetch(uri, limit = 10)
15
+ raise ArgumentError, 'HTTP redirect too deep' if limit == 0
16
+
17
+ response = Net::HTTP.get_response(URI.parse(uri))
18
+
19
+ case response
20
+ when Net::HTTPSuccess then
21
+ return response
22
+ when Net::HTTPRedirection then
23
+ return fetch(response['location'], limit - 1)
24
+ else
25
+ return response.error!
26
+ end
27
+ end
28
+
29
+ # Returns an absolute path for the requested executable. Falls back to
30
+ # returning only the executable if an exception is raised.
31
+
32
+ def which_executable(executable)
33
+ begin
34
+ if (path = `which #{executable}`.chomp).empty?
35
+ $stderr.puts "!!Error: Could not find \"#{executable}\""
36
+ exit
37
+ end
38
+ rescue Exception
39
+ path = executable
40
+ end
41
+
42
+ return path
43
+ end
44
+
45
+ desc 'Display some help and the README'
46
+ task :help do
47
+ puts 'Call "rake --tasks" to learn what tasks are available...'
48
+ puts
49
+ puts File.read('README')
50
+ end
51
+
52
+ task :default => [:help]
53
+
54
+ namespace :appengine do
55
+ desc 'Start a local test server'
56
+ task :run do
57
+ puts 'Start a local test server'
58
+ `(dev_appserver.rb .) 1>&2`
59
+ end
60
+
61
+ desc 'Force rebuilding "WEB-INF/lib/gems.jar"'
62
+ task :rebuildgems do
63
+ puts 'Force rebuilding "WEB-INF/lib/gems.jar"'
64
+ `(appcfg.rb gem help install) 2> /dev/null 1>&2`
65
+ end
66
+
67
+ desc 'Build the application package'
68
+ task :bundle do
69
+ puts 'Build the application package.'
70
+ `(appcfg.rb --email={{email}} --enable_jar_splitting bundle .) 1>&2`
71
+ end
72
+
73
+ desc 'Upload the application code to the server'
74
+ task :update do
75
+ puts 'Upload the new application code (this may take a while).'
76
+ `(appcfg.rb --email={{email}} --enable_jar_splitting update .) 1>&2`
77
+ end
78
+
79
+ desc 'Roll back a blocked and halfway broken deploy'
80
+ task :rollback do
81
+ puts 'Roll back a blocked and halfway broken deploy.'
82
+ `(appcfg.rb --email={{email}} rollback .) 1>&2`
83
+ end
84
+
85
+ desc 'Deploy the application (build package and upload application code)'
86
+ task :deploy => [:rebuildgems, :bundle, :update]
87
+ end
Binary file
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,14 @@
1
+ .DS_Store
2
+ log/*
3
+ tmp/*
4
+ TAGS
5
+ *~
6
+ .#*
7
+ *.sqlite
8
+ *.sqlite3
9
+ *.db
10
+ .hgignore
11
+ .hg/*
12
+ .svn/*
13
+ gems/gems/*
14
+ gems/specifications/*
@@ -0,0 +1,51 @@
1
+ # This application file was generated by jruby-enginize.
2
+
3
+ require 'rubygems'
4
+
5
+ require 'haml'
6
+ require 'sass'
7
+ require 'sinatra'
8
+
9
+ # Use AppEngine::URLFetch.fetch() for loading remote files.
10
+
11
+ require 'appengine-apis/urlfetch'
12
+
13
+ # Set to true if you need sessions.
14
+
15
+ set :sessions, false
16
+
17
+ # Configure Sinatra to reload during development.
18
+
19
+ class Sinatra::Reloader < Rack::Reloader
20
+ def safe_load(file, mtime, stderr = $stderr)
21
+ ::Sinatra::Application.reset!
22
+ stderr.puts "#{self.class}: reseting routes"
23
+ super
24
+ end
25
+ end
26
+
27
+ configure :development do
28
+ use Sinatra::Reloader
29
+ end
30
+
31
+ # Helpers to include...
32
+
33
+ helpers do
34
+ include Rack::Utils
35
+
36
+ alias_method :h, :escape_html
37
+ end
38
+
39
+ # GET /
40
+
41
+ get '/' do
42
+ haml :index
43
+ end
44
+
45
+ # GET /stylesheet.css
46
+
47
+ get '/stylesheet.css' do
48
+ content_type 'text/css', :charset => 'utf-8'
49
+
50
+ sass :stylesheet
51
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'appengine-rack'
3
+
4
+ require 'sinatra'
5
+
6
+ AppEngine::Rack.configure_app(
7
+ # :ssl_enabled => true,
8
+ :application => '{{name}}',
9
+ :version => 1)
10
+
11
+ require 'app'
12
+
13
+ run Sinatra::Application
@@ -0,0 +1,5 @@
1
+ 18c18
2
+ < File.join(File.dirname(__FILE__), '..', '..', file)
3
+ ---
4
+ > File.join(File.dirname(File.dirname(File.dirname(__FILE__))), file)
5
+
@@ -0,0 +1,19 @@
1
+ # Task for loading gems needed by this template. Bootstrap to get installed...
2
+
3
+ namespace :template do
4
+ desc 'Load missing gems to local gem repository'
5
+ task :gems do
6
+ appcfg = which_executable('appcfg.rb')
7
+ patch = which_executable('patch')
8
+
9
+ puts 'Load missing gems to local gem repository'
10
+ `(sudo #{appcfg} gem install appengine-apis haml sinatra) 1>&2`
11
+ puts 'Add patch for Haml 2.2.2 if needed'
12
+ `(sudo #{patch} --batch --silent .gems/gems/haml-2.2.2/lib/haml/util.rb < lib/tasks/haml-2_2_2-util.patch) 2> /dev/null 1>&2`
13
+ end
14
+ end
15
+
16
+ # Add your own tasks...
17
+
18
+ namespace :sinatra do
19
+ end
@@ -0,0 +1,19 @@
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 tiny app was generated by
18
+ %a{ :href => 'http://github.com/ulbrich/jruby-enginize' } JRuby-Enginize
19
+ to streamline Google AppEngine development.
@@ -0,0 +1,6 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %link{ :rel => 'stylesheet', :href => '/stylesheet.css', :type => 'text/css' }
5
+ %body
6
+ = yield
@@ -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 inherit
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,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby-enginize
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.8"
5
+ platform: ruby
6
+ authors:
7
+ - Jan Ulbrich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-04 00:00:00 +01: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.rdoc
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/lib/tasks/haml-2_2_2-util.patch
34
+ - templates/sinatra/config.ru
35
+ - templates/sinatra/app.rb
36
+ - templates/sinatra/.gitignore
37
+ - templates/shared/README
38
+ - templates/shared/Rakefile
39
+ - templates/shared/public/robots.txt
40
+ - templates/shared/public/images/appengine_logo.png
41
+ - templates/shared/public/favicon.ico
42
+ - templates/merb/views/layout.engine_app.html.erb
43
+ - templates/merb/views/index.html.erb
44
+ - templates/merb/spec/spec_helper.rb
45
+ - templates/merb/public/stylesheets/default.css
46
+ - templates/merb/public/images/merb_logo.png
47
+ - templates/merb/lib/tasks/merb.rake
48
+ - templates/merb/config.ru
49
+ - templates/merb/config/init.rb
50
+ - templates/merb/config/framework.rb
51
+ - templates/merb/app.rb
52
+ - templates/merb/.gitignore
53
+ - README.rdoc
54
+ has_rdoc: true
55
+ homepage: http://github.com/ulbrich/jruby-enginize
56
+ licenses: []
57
+
58
+ post_install_message:
59
+ rdoc_options:
60
+ - --exclude
61
+ - pkg
62
+ - --exclude
63
+ - templates
64
+ - --all
65
+ - --title
66
+ - JRuby-Enginize
67
+ - --main
68
+ - README.rdoc
69
+ require_paths:
70
+ - .
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ requirements: []
84
+
85
+ rubyforge_project:
86
+ rubygems_version: 1.3.5
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: A package for generating Google AppEngine compliant JRuby projects.
90
+ test_files: []
91
+