ulbrich-jruby-enginize 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -3,19 +3,26 @@
3
3
  == About
4
4
 
5
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
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
8
  AppEngine, go to http://code.google.com/appengine and have a look at the
9
- tutorials.
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.
10
11
 
11
12
  == Prerequisites
12
13
 
13
14
  JRuby-Enginize needs a proper JRuby installation including rake and the
14
15
  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.
16
+ template to generate an application for:
17
+
18
+ For Sinatra (http://www.sinatrarb.com), you will need the "sinatra" gem with
19
+ "haml" and "sass".
20
+
21
+ For Merb (http://www.merbivore.com), you will need the "merb-core" gem with
22
+ "extlib" and "appengine-apis".
23
+
24
+ Be sure to install gems with <tt>jgem</tt> or <tt>jruby -S gem</tt> as you
25
+ need them for JRuby and not for Ruby.
19
26
 
20
27
  You also need an Google AppEngine account to actually publish your code.
21
28
  Without account you can still play around with the tool and run applications
@@ -25,7 +32,7 @@ locally.
25
32
 
26
33
  Install JRuby-Enginize as a gem with
27
34
 
28
- jgem sources -a http://gems.github.com # Only needed once!
35
+ sudo jgem sources -a http://gems.github.com # Only needed once!
29
36
  sudo jgem install ulbrich-jruby-enginize
30
37
 
31
38
  and be sure to really install with <tt>jgem</tt> as JRuby-Enginize will
@@ -51,7 +58,7 @@ Here are the steps for creating and deploying a new Sinatra application:
51
58
 
52
59
  * Generate your application. Sample:
53
60
 
54
- <tt>jruby -S jruby-enginize --email foo@bar.com foobar</tt>
61
+ <tt>jruby -S jruby-enginize --template merb --email foo@bar.com foobar</tt>
55
62
 
56
63
  * Go to the new directory, learn about the available rake tasks and try out
57
64
  your application:
data/lib/generator.rb CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  require 'ftools'
7
7
  require 'find'
8
+ require 'digest/md5'
8
9
 
9
10
  module JRubyEnginize # :nodoc:
10
11
 
@@ -132,16 +133,50 @@ module JRubyEnginize # :nodoc:
132
133
  #
133
134
  # [source] Source file
134
135
  # [target] Target file
136
+ #
137
+ # The source files may contain some variables which are replaced on the
138
+ # fly. All variables are set in double curly brackets and are let passed
139
+ # without modification if they ar not recognized.
140
+ #
141
+ # Supported variables:
142
+ #
143
+ # [{{email}}] E-mail address of the Google AppEngine account
144
+ # [{{name}}] Name of the application
145
+ # [{{template}}] Name of the template (e.g. "sinatra")
146
+ # [{{hexrand-xx}}] Hexadecimal random string with xx characters
147
+ # [{{numrand-xx}}] Random number with xx digits
135
148
 
136
149
  def process_file(source, target)
137
- content = File.read(source).gsub(/\{\{[^}]*\}\}/) do |match|
138
- case match
150
+ content = File.read(source).gsub(/\{\{[^}]*\}\}/) do |variable|
151
+ case variable
139
152
  when '{{email}}'
140
153
  email
141
154
  when '{{name}}'
142
155
  name
143
156
  else
144
- match
157
+ if hexrand = variable.match(/{{hexrand-([0-9]+)}}/) and
158
+ hexrand.length == 2 and (len = hexrand[1].to_i) > 0
159
+ then
160
+ str = ''
161
+
162
+ while str.length < len do
163
+ str << Digest::MD5.hexdigest("#{rand}-#{Time.now}-#{rand}")
164
+ end
165
+
166
+ str[0, len]
167
+ elsif numrand = variable.match(/{{numrand-([0-9]+)}}/) and
168
+ numrand.length == 2 and (len = numrand[1].to_i) > 0
169
+ then
170
+ str = ''
171
+
172
+ while str.length < len do
173
+ str << rand.to_s.sub(/^.*\.0*/, '')
174
+ end
175
+
176
+ str[0, len]
177
+ else
178
+ variable
179
+ end
145
180
  end
146
181
  end
147
182
 
@@ -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 files as 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,85 @@
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 config)
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"]
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
+ config.gems = ['merb-core', 'extlib']
36
+
37
+ # The most recent versions of gems are used.
38
+ # You can specify versions of gems by using a hash assignment:
39
+ # config.gems["foo"] = "2.0.2"
40
+
41
+ # You can also use regexps or Gem::Dependency objects for flexibility or
42
+ # fine-grained control.
43
+ # config.gems << /^merb-/
44
+ # config.gems << Gem::Dependency.new("merb-core", "= 0.9.3")
45
+
46
+ # Include gem dependencies not mentioned specifically
47
+ config.gem_dependencies = true
48
+
49
+ # Files to be included in the root of the webapp. Note that files in public
50
+ # will have the leading 'public/' part of the path stripped during staging.
51
+ # config.public_html = FileList["public/**/*", "doc/**/*"]
52
+
53
+ # Pathmaps for controlling how public HTML files are copied into the .war
54
+ # config.pathmaps.public_html = ["%{public/,}p"]
55
+
56
+ # Name of the war file (without the .war)
57
+ config.war_name = "{{name}}"
58
+
59
+ # Name of the MANIFEST.MF template for the war file. Defaults to the
60
+ # MANIFEST.MF normally generated by `jar cf`.
61
+ # config.manifest_file = "config/MANIFEST.MF"
62
+
63
+ # Value of environment variables
64
+ # config.webxml.foo.env = ENV['FOO_ENV']
65
+
66
+ # Application booter to use, one of :rack, :rails, or :merb
67
+ config.webxml.booter = :merb
68
+
69
+ # When using the :rack booter, "Rackup" script to use.
70
+ # The script is evaluated in a Rack::Builder to load the application.
71
+ # Examples:
72
+ # config.webxml.rackup = %{require './lib/demo'; run Rack::Adapter::Camping.new(Demo)}
73
+ # config.webxml.rackup = require 'cgi' && CGI::escapeHTML(File.read("config.ru"))
74
+
75
+ # Control the pool of runtimes. Leaving unspecified means
76
+ # the pool will grow as needed to service requests. It is recommended
77
+ # that you fix these values when running a production server!
78
+ # config.webxml.jruby.min.runtimes = 2
79
+ # config.webxml.jruby.max.runtimes = 4
80
+ config.webxml.jruby.min.runtimes = 1
81
+ config.webxml.jruby.max.runtimes = 1
82
+ config.webxml.jruby.init.serial = true
83
+
84
+ config.java_libs = []
85
+ end
@@ -0,0 +1,34 @@
1
+ require 'merb-core'
2
+ require 'merb-core/tasks/merb'
3
+
4
+ include FileUtils
5
+
6
+ # Load the basic runtime dependencies; this will include
7
+ # any plugins and therefore plugin rake tasks.
8
+ init_env = ENV['MERB_ENV'] || 'rake'
9
+ Merb.load_dependencies(:environment => init_env)
10
+
11
+ # Get Merb plugins and dependencies
12
+ Merb::Plugins.rakefiles.each { |r| require r }
13
+
14
+ # Load any app level custom rakefile extensions from lib/tasks
15
+ tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks")
16
+ rake_files = Dir["#{tasks_path}/*.rake"]
17
+ rake_files.each{|rake_file| load rake_file }
18
+
19
+ require 'spec/rake/spectask'
20
+ require 'merb-core/test/tasks/spectasks'
21
+
22
+ ##############################################################################
23
+ # ADD YOUR CUSTOM TASKS IN /lib/tasks
24
+ # NAME YOUR RAKE FILES file_name.rake
25
+ ##############################################################################
26
+
27
+ namespace :merb do
28
+ desc 'Start a local test server on port 4000'
29
+ task :run do
30
+ puts 'Start a local test server on port 4000'
31
+ `(jruby -S merb -V) 1>&2`
32
+ end
33
+ end
34
+
@@ -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,26 @@
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 sample application was generated by
24
+ <a href='http://github.com/ulbrich/jruby-enginize'>JRuby-Enginize</a>
25
+ </div>
26
+ </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,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: /
@@ -1,7 +1,7 @@
1
1
  namespace :sinatra do
2
- desc 'Start a local test server on part 4567'
2
+ desc 'Start a local test server on port 4567'
3
3
  task :run do
4
- puts 'Start a local test server on part 4567'
4
+ puts 'Start a local test server on port 4567'
5
5
  `(jruby -S app.rb) 1>&2`
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ulbrich-jruby-enginize
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.4"
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Ulbrich
@@ -35,9 +35,21 @@ files:
35
35
  - templates/sinatra/app.rb
36
36
  - templates/shared/README
37
37
  - templates/shared/Rakefile
38
+ - templates/shared/public/robots.txt
38
39
  - templates/shared/public/images/appengine_logo.png
39
40
  - templates/shared/lib/jruby-rack-0.9.4.jar
40
41
  - templates/shared/appengine-web.xml
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/warble.rb
49
+ - templates/merb/config/init.rb
50
+ - templates/merb/config/framework.rb
51
+ - templates/merb/app.rb
52
+ - templates/merb/.gitignore
41
53
  - README.rdoc
42
54
  has_rdoc: true
43
55
  homepage: http://github.com/ulbrich/jruby-enginize