jruby-enginize 0.8 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -9,32 +9,35 @@ AppEngine, go to http://code.google.com/appengine and have a look at the
9
9
  tutorials. For more about JRuby, please go to http://www.codehaus.org and see
10
10
  what's up running Ruby applications on a Java VM.
11
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
12
+ The Google people work hard to make JRuby easier to deploy with each release
13
+ of their tools, so don't blindly trust all those blog posts and samples you'll
27
14
  find but use the newest version of jruby-enginize and have a look at the Wiki
28
15
  page of the Google AppEngine JRuby tools
29
16
  (http://code.google.com/p/appengine-jruby/wiki/GettingStarted)
30
17
  to learn about the details beyond.
31
18
 
19
+ If you used JRuby-Enginize before, you will note two bigger changes:
20
+
21
+ * There is no need for a separate JRuby installation anymore, as the
22
+ google-appengine gem does that for you.
23
+
24
+ * Gem handling changed as Google now uses bundler and all required gems have
25
+ to be registered in a new file called "Gemfile". These gems are loaded on
26
+ the fly when you call "rake appengine:run" or "rake appengine:deploy". Quite
27
+ elegant...
28
+
29
+ == Installation
30
+
32
31
  These are the steps for installing the Google tools plus JRuby-Enginize
33
32
  running on top of it to streamline your first steps:
34
33
 
35
- sudo gem sources -a http://gems.github.com # Only needed once!
34
+ sudo gem sources -a http://gemcutter.org # Only needed once!
36
35
  sudo gem install google-appengine
37
- sudo gem install ulbrich-jruby-enginize
36
+ sudo gem install jruby-enginize
37
+
38
+ !!Warning: As Github cancelled gem support, we moved the gem from Github.com
39
+ to Gemcutter.org. If you install from Github, you will not get the newest
40
+ version! See http://gemcutter.org/gems/jruby-enginize for details.
38
41
 
39
42
  You also need an Google AppEngine account to actually publish your code.
40
43
  Without account you can still play around with the tools and run applications
@@ -54,22 +57,15 @@ Here are the steps for creating and deploying a new Sinatra application:
54
57
 
55
58
  * Register with Google AppEngine and create a new application ID.
56
59
 
57
- * Generate your application with that new ID as directory name. Sample:
58
-
59
- <tt>jruby-enginize --template sinatra jruby-enginize</tt>
60
+ * Generate your application with that new ID as directory name and the e-mail
61
+ address of your Google account. Optionally choose a template ("sinatra" or
62
+ "merb" for now).
60
63
 
61
- * Go to the new directory and install the missing gems first (depends on the
62
- template you have chosen):
64
+ Sample:
63
65
 
64
- <tt>rake template:gems</tt>
66
+ <tt>jruby-enginize --email john@doe.com --template sinatra jruby-enginize</tt>
65
67
 
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.
68
+ * Go to the new directory
73
69
 
74
70
  * Learn about the available rake tasks
75
71
 
@@ -77,7 +73,12 @@ Here are the steps for creating and deploying a new Sinatra application:
77
73
 
78
74
  * Try out your application locally:
79
75
 
80
- <tt>sudo rake appengine:run</tt>
76
+ <tt>rake appengine:run</tt>
77
+
78
+ !!Attention: Whenever you want to require additional gems, be sure
79
+ to add them to the bundler configuration in <tt>Gemfile</tt> instead of
80
+ using <tt>jgem</tt> as the Google toole maintains a local repository per
81
+ project and bundle the files to upload from that information.
81
82
 
82
83
  * Deploy the application:
83
84
 
@@ -87,9 +88,9 @@ Here are the steps for creating and deploying a new Sinatra application:
87
88
  password to confirm your upload to the server.
88
89
 
89
90
  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.
91
+ number in the <tt>AppEngine::Rack.configure_app</tt> part of <tt>config.ru</tt>
92
+ to a new value, when you are experimenting with an unstable version and don't
93
+ want to risk your users getting exceptions.
93
94
 
94
95
  You can try the new version by opening e.g.
95
96
 
data/lib/generator.rb CHANGED
@@ -78,9 +78,8 @@ module JRubyEnginize # :nodoc:
78
78
  if not dryrun
79
79
  puts "Done with directory \"#{self.path}\"."
80
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!"
81
+ puts "\nYour next steps:\n cd #{self.path}\n\n rake\n rake --tasks"
82
+ puts "\n rake appengine:run"
84
83
  puts "\n rake appengine:deploy"
85
84
  end
86
85
  end
@@ -0,0 +1,20 @@
1
+ # Basics for using Google AppEngine.
2
+
3
+ disable_system_gems
4
+ disable_rubygems
5
+
6
+ bundle_path '.gems/bundler_gems'
7
+
8
+ source 'http://gemcutter.org'
9
+
10
+ gem 'appengine-rack'
11
+ gem 'appengine-apis'
12
+
13
+ # Dependencies for using Merb.
14
+
15
+ gem 'extlib'
16
+ gem 'rubygems-update'
17
+ gem 'merb-core'
18
+
19
+ # Add more dependencies below...
20
+
@@ -1,12 +1,31 @@
1
+ # Load rubygems update and modify load paths to help Merb do some Gem
2
+ # extension work.
3
+
1
4
  require 'rubygems'
2
- require 'appengine-rack'
5
+ gem 'rubygems-update'
6
+
7
+ $LOAD_PATH.each do |path|
8
+ if (match = path.match(/(.*)\/hide_lib_for_update/))
9
+ $LOAD_PATH << "#{match[1]}/lib"
10
+ end
11
+ end
3
12
 
13
+ # Require standard libraries plus Merb and a Merb::Bootloader patch.
14
+
15
+ require 'appengine-rack'
4
16
  require 'merb-core'
5
17
 
18
+ require 'lib/bootloader_patch'
19
+
20
+ # Configure and run the application. Attention: Modify the version number
21
+ # whenever you want to test the live environment without breaking the current
22
+ # release...
23
+
6
24
  AppEngine::Rack.configure_app(
7
25
  # :ssl_enabled => true,
8
26
  :application => '{{name}}',
9
- :version => 1)
27
+ :precompilation_enabled => true,
28
+ :version => '1')
10
29
 
11
30
  Merb::Config.setup(:merb_root => File.dirname(__FILE__),
12
31
  :environment => ENV['RACK_ENV'])
@@ -14,6 +33,8 @@ Merb::Config.setup(:merb_root => File.dirname(__FILE__),
14
33
  Merb.environment = Merb::Config[:environment]
15
34
  Merb.root = Merb::Config[:merb_root]
16
35
 
17
- Merb::BootLoader.run
18
-
19
- run Merb::Rack::Application.new
36
+ Merb::BootLoader.gaerun
37
+
38
+ use Merb::Rack::Static, Merb.dir_for(:public)
39
+
40
+ run Merb::Rack::Application.new
@@ -0,0 +1,39 @@
1
+ # Adds a reduced version of the run method of the boot loader skipping stuff
2
+ # incompatible or unneeded on Google AppEngine.
3
+
4
+ class Merb::BootLoader
5
+
6
+ # Just the same as the run method but with skipping some subclasses.
7
+
8
+ def self.gaerun
9
+ Merb.started = true
10
+
11
+ ignored = ['Merb::BootLoader::Logger',
12
+ 'Merb::BootLoader::BackgroundServices',
13
+ 'Merb::BootLoader::ReloadClasses']
14
+
15
+ subklasses = subclasses.dup
16
+
17
+ until subclasses.empty?
18
+ time = Time.now.to_i
19
+ bootloader = subclasses.shift
20
+
21
+ next if ignored.include? bootloader
22
+
23
+ if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
24
+ Merb.logger.debug!("Loading: #{bootloader}")
25
+ end
26
+
27
+ Object.full_const_get(bootloader).run
28
+
29
+ if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
30
+ Merb.logger.debug!("It took: #{Time.now.to_i - time}")
31
+ end
32
+
33
+ self.finished << bootloader
34
+ end
35
+
36
+ self.subclasses = subklasses
37
+ nil
38
+ end
39
+ end
@@ -25,18 +25,6 @@ begin
25
25
  rescue Exception
26
26
  end
27
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
28
  # Add your own tasks...
41
29
 
42
30
  namespace :merb do
@@ -1,5 +1,3 @@
1
- require "rubygems"
2
-
3
1
  # Add the local gems dir if found within the app root; any dependencies loaded
4
2
  # hereafter will try to load from the local gems before loading system gems.
5
3
  if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
@@ -0,0 +1,14 @@
1
+ # Basics for using Google AppEngine.
2
+
3
+ disable_system_gems
4
+ disable_rubygems
5
+
6
+ bundle_path '.gems/bundler_gems'
7
+
8
+ source 'http://gemcutter.org'
9
+
10
+ gem 'appengine-rack'
11
+ gem 'appengine-apis'
12
+
13
+ # Add more dependencies below...
14
+
@@ -3,18 +3,16 @@ README
3
3
  This is a generic README generated by jruby-enginize. Please replace with
4
4
  something more meaningful... ;-)
5
5
 
6
- INSTALL MISSING GEMS
6
+ DEVELOPMENT
7
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):
8
+ You can start a local development server by running the following command:
10
9
 
11
- rake template:gems
10
+ rake appengine:run
12
11
 
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!
12
+ Whenever you want to require additional gems, be sure to add them to the
13
+ bundler configuration in "Gemfile" instead of using jgem: The Google tools
14
+ maintain a local repository per project and bundle the files to upload from
15
+ that information.
18
16
 
19
17
  GOOGLE APPENGINE DEPLOYMENT
20
18
 
@@ -26,7 +24,7 @@ and open
26
24
 
27
25
  http://{{name}}.appspot.com
28
26
 
29
- to have a first test.
27
+ to test it live.
30
28
 
31
29
  Be sure to set the version number in the AppEngine::Rack.configure_app part
32
30
  of "config.ru" to a new value, when you are experimenting with an unstable
@@ -47,8 +45,8 @@ and setting a new default.
47
45
 
48
46
  SOME MORE INFO
49
47
 
50
- - Gems installed with "appcfg.rb gem" reside in directory ".gems". Again: Do
51
- not use "jgem" at all!
48
+ - Gems have to be added to bundler config in "Gemfile". Again: Do not use
49
+ "jgem" at all!
52
50
 
53
51
  - Some gems will throw exceptions during bundling: Have a look for paths
54
52
  assembled using ".." to reach the parent directory and replace with
@@ -57,15 +55,17 @@ SOME MORE INFO
57
55
 
58
56
  - Data uploaded to the server is gathered in directory "WEB-INF" as with any
59
57
  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.
58
+ is called, this directory will be created and some gems will be downloaded.
65
59
 
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".
60
+ - Java stuff is bundled in "WEB-INF/lib/gems.jar" on the fly. You might want
61
+ to enforce a rebuild from time to time by calling "rake appengine:rebundle".
69
62
 
70
63
  - Sometimes the local test server keeps running after Ctrl-C, so have a look
71
64
  at "ps" and manually kill the process if needed.
65
+
66
+ - If you get something like the following error message
67
+
68
+ Permission denied - ~/.appcfg_rb_nag (Errno::EACCES)
69
+
70
+ you need to remove that file with "rm ~/.appcfg_rb_nag" or at least change
71
+ ownership as it was created earlier with starting an app with "sudo".
@@ -52,22 +52,28 @@ end
52
52
  task :default => [:help]
53
53
 
54
54
  namespace :appengine do
55
- desc 'Start a local test server'
55
+ desc 'Start a local development server'
56
56
  task :run do
57
- puts 'Start a local test server'
57
+ puts 'Start a local development server'
58
58
  `(dev_appserver.rb .) 1>&2`
59
59
  end
60
60
 
61
+ desc 'Start a local Rack based server'
62
+ task :run do
63
+ puts 'Start a local Rack based server'
64
+ `(appcfg.rb run bin/rackup config.ru) 1>&2`
65
+ end
66
+
61
67
  desc 'Force rebuilding "WEB-INF/lib/gems.jar"'
62
- task :rebuildgems do
68
+ task :rebundle do
63
69
  puts 'Force rebuilding "WEB-INF/lib/gems.jar"'
64
- `(appcfg.rb gem help install) 2> /dev/null 1>&2`
70
+ `(appcfg.rb bundle --update .) 2> /dev/null 1>&2`
65
71
  end
66
72
 
67
73
  desc 'Build the application package'
68
74
  task :bundle do
69
75
  puts 'Build the application package.'
70
- `(appcfg.rb --email={{email}} --enable_jar_splitting bundle .) 1>&2`
76
+ `(appcfg.rb bundle .) 1>&2`
71
77
  end
72
78
 
73
79
  desc 'Upload the application code to the server'
@@ -83,5 +89,5 @@ namespace :appengine do
83
89
  end
84
90
 
85
91
  desc 'Deploy the application (build package and upload application code)'
86
- task :deploy => [:rebuildgems, :bundle, :update]
92
+ task :deploy => [:bundle, :update]
87
93
  end
@@ -0,0 +1,19 @@
1
+ # Basics for using Google AppEngine
2
+
3
+ disable_system_gems
4
+ disable_rubygems
5
+
6
+ bundle_path '.gems/bundler_gems'
7
+
8
+ source 'http://gemcutter.org'
9
+
10
+ gem 'appengine-rack'
11
+ gem 'appengine-apis'
12
+
13
+ # Dependencies for using Sinatra.
14
+
15
+ gem 'haml'
16
+ gem 'sinatra'
17
+
18
+ # Add more dependencies below...
19
+
@@ -1,12 +1,17 @@
1
- require 'rubygems'
2
- require 'appengine-rack'
1
+ # Require standard libraries plus Sinatra.
3
2
 
3
+ require 'appengine-rack'
4
4
  require 'sinatra'
5
5
 
6
+ # Configure and run the application. Attention: Modify the version number
7
+ # whenever you want to test the live environment without breaking the current
8
+ # release...
9
+
6
10
  AppEngine::Rack.configure_app(
7
11
  # :ssl_enabled => true,
8
12
  :application => '{{name}}',
9
- :version => 1)
13
+ :precompilation_enabled => true,
14
+ :version => '1')
10
15
 
11
16
  require 'app'
12
17
 
@@ -1,18 +1,3 @@
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
1
  # Add your own tasks...
17
2
 
18
3
  namespace :sinatra do
metadata CHANGED
@@ -1,7 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-enginize
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.8"
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 9
8
+ version: "0.9"
5
9
  platform: ruby
6
10
  authors:
7
11
  - Jan Ulbrich
@@ -9,7 +13,7 @@ autorequire:
9
13
  bindir: bin
10
14
  cert_chain: []
11
15
 
12
- date: 2009-11-04 00:00:00 +01:00
16
+ date: 2010-02-25 00:00:00 +01:00
13
17
  default_executable:
14
18
  dependencies: []
15
19
 
@@ -30,7 +34,7 @@ files:
30
34
  - templates/sinatra/views/index.haml
31
35
  - templates/sinatra/public/images/sinatra_logo.png
32
36
  - templates/sinatra/lib/tasks/sinatra.rake
33
- - templates/sinatra/lib/tasks/haml-2_2_2-util.patch
37
+ - templates/sinatra/Gemfile
34
38
  - templates/sinatra/config.ru
35
39
  - templates/sinatra/app.rb
36
40
  - templates/sinatra/.gitignore
@@ -39,12 +43,15 @@ files:
39
43
  - templates/shared/public/robots.txt
40
44
  - templates/shared/public/images/appengine_logo.png
41
45
  - templates/shared/public/favicon.ico
46
+ - templates/shared/Gemfile
42
47
  - templates/merb/views/layout.engine_app.html.erb
43
48
  - templates/merb/views/index.html.erb
44
49
  - templates/merb/spec/spec_helper.rb
45
50
  - templates/merb/public/stylesheets/default.css
46
51
  - templates/merb/public/images/merb_logo.png
47
52
  - templates/merb/lib/tasks/merb.rake
53
+ - templates/merb/lib/bootloader_patch.rb
54
+ - templates/merb/Gemfile
48
55
  - templates/merb/config.ru
49
56
  - templates/merb/config/init.rb
50
57
  - templates/merb/config/framework.rb
@@ -72,18 +79,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
79
  requirements:
73
80
  - - ">="
74
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
75
84
  version: "0"
76
- version:
77
85
  required_rubygems_version: !ruby/object:Gem::Requirement
78
86
  requirements:
79
87
  - - ">="
80
88
  - !ruby/object:Gem::Version
89
+ segments:
90
+ - 0
81
91
  version: "0"
82
- version:
83
92
  requirements: []
84
93
 
85
94
  rubyforge_project:
86
- rubygems_version: 1.3.5
95
+ rubygems_version: 1.3.6
87
96
  signing_key:
88
97
  specification_version: 3
89
98
  summary: A package for generating Google AppEngine compliant JRuby projects.
@@ -1,5 +0,0 @@
1
- 18c18
2
- < File.join(File.dirname(__FILE__), '..', '..', file)
3
- ---
4
- > File.join(File.dirname(File.dirname(File.dirname(__FILE__))), file)
5
-