trinidad 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,12 @@
1
+ == 0.6.0 (2009-11-02)
2
+
3
+ * Rackup compatibe frameworks support
4
+
5
+ == 0.5.0 (2009-10-27)
6
+
7
+ * JRuby-rack updated to version 0.9.5
8
+ * Added Rack dependency to avoid using vendorized version
9
+
1
10
  == 0.4.1 (2009-07-26)
2
11
 
3
12
  * using jruby-rack development version to solve some bugs related with it.
@@ -1,6 +1,6 @@
1
1
  = trinidad
2
2
 
3
- Trinidad allows you to run a rails application within an embedded Apache Tomcat container.
3
+ Trinidad allows you to run a rails or rackup applications within an embedded Apache Tomcat container.
4
4
 
5
5
  This project was initially called "Tomcat-rails" but due to legal issues with the ASF and the Tomcat trademark it has been renamed.
6
6
 
@@ -23,6 +23,8 @@ Trinidad allows you to configure some parameters when the server is started from
23
23
  * -c, --context CONTEXT => application context path.
24
24
  * --lib, --jars LIBS_DIR => directory containing jars.
25
25
  * --classes CLASSES_DIR => directory containing classes.
26
+ * --rackup [RACKUP_FILE] => run a provided rackup file instead of a rails application, by default it's config.ru.
27
+ * --public PUBLIC_DIR => specify the public directory for your application, by default it's 'public'.
26
28
 
27
29
  The server can also be configured from a yaml file. If a file is not especified, the server tries to load the file <em>config/tomcat.yml</em>. Within this file you can add other options like jruby.min.runtimes(:jruby_min_runtimes) or jruby.max.runtimes(:jruby_max_runtimes).
28
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -10,7 +10,9 @@ require 'trinidad/command_line_parser'
10
10
  require 'trinidad/jars'
11
11
  require 'trinidad/server'
12
12
  require 'trinidad/web_app'
13
+ require 'trinidad/rails_web_app'
14
+ require 'trinidad/rackup_web_app'
13
15
 
14
16
  module Trinidad
15
17
  TRINIDAD_LIBS = File.dirname(__FILE__) + "/../trinidad-libs" unless defined?(TRINIDAD_LIBS)
16
- end
18
+ end
@@ -60,6 +60,15 @@ module Trinidad
60
60
  default_options[:config] = v if v
61
61
  default_options.deep_merge! YAML.load_file(default_options[:config])
62
62
  end
63
+
64
+ opts.on('-r', '--rackup [RACKUP_FILE]', 'Rackup configuration file',
65
+ 'default: config.ru') do |v|
66
+ default_options[:rackup] = v || 'config.ru'
67
+ end
68
+
69
+ opts.on('--public', '--public DIRECTORY', 'Public directory', 'default: public') do |v|
70
+ default_options[:public] = v
71
+ end
63
72
 
64
73
  opts.on('-v', '--version', 'display the current version') do
65
74
  puts File.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).chomp
@@ -77,4 +86,4 @@ module Trinidad
77
86
  default_options
78
87
  end
79
88
  end
80
- end
89
+ end
@@ -0,0 +1,17 @@
1
+ module Trinidad
2
+ class RackupWebApp < WebApp
3
+
4
+ def add_init_params
5
+ super
6
+ @context.addParameter('rackup', rackup_script) unless @context.findParameter('rackup')
7
+ end
8
+
9
+ def context_listener
10
+ 'org.jruby.rack.RackServletContextListener'
11
+ end
12
+
13
+ def rackup_script
14
+ IO.read(File.join(@config[:web_app_dir], @config[:rackup]))
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ module Trinidad
2
+ class RailsWebApp < WebApp
3
+
4
+ def add_init_params
5
+ super
6
+ @context.addParameter('rails.env', @config[:environment].to_s) unless @context.findParameter('rails.env')
7
+ @context.addParameter('rails.root', '/') unless @context.findParameter('rails.root')
8
+ end
9
+
10
+ def context_listener
11
+ 'org.jruby.rack.rails.RailsServletContextListener'
12
+ end
13
+ end
14
+ end
@@ -41,7 +41,7 @@ module Trinidad
41
41
  end
42
42
 
43
43
  def create_web_app
44
- web_app = WebApp.new(@tomcat.addWebapp(@config[:context_path].to_s, @config[:web_app_dir]), @config)
44
+ web_app = WebApp.create(@tomcat.addWebapp(@config[:context_path].to_s, @config[:web_app_dir]), @config)
45
45
 
46
46
  web_app.load_default_web_xml
47
47
  web_app.add_rack_filter
@@ -1,6 +1,10 @@
1
1
  module Trinidad
2
2
  class WebApp
3
3
  attr_reader :context, :config
4
+
5
+ def self.create(context, config)
6
+ config.has_key?(:rackup) ? RackupWebApp.new(context, config) : RailsWebApp.new(context, config)
7
+ end
4
8
 
5
9
  def initialize(context, config)
6
10
  @context = context
@@ -41,18 +45,16 @@ module Trinidad
41
45
  end
42
46
 
43
47
  @context.addParameter('jruby.initial.runtimes', @config[:jruby_min_runtimes].to_s) unless @context.findParameter('jruby.initial.runtimes')
44
- @context.addParameter('rails.env', @config[:environment].to_s) unless @context.findParameter('rails.env')
45
- @context.addParameter('rails.root', '/') unless @context.findParameter('rails.root')
46
- @context.addParameter('public.root', '/public') unless @context.findParameter('public.root')
48
+ @context.addParameter('public.root', File.join('/', public_root)) unless @context.findParameter('public.root')
47
49
  end
48
50
 
49
51
  def add_web_dir_resources
50
- @context.setDocBase(File.join(@config[:web_app_dir], "public/"))
52
+ @context.setDocBase(File.join(@config[:web_app_dir], public_root)) if File.exist?(File.join(@config[:web_app_dir], public_root))
51
53
  end
52
54
 
53
55
  def add_rack_context_listener
54
56
  unless rack_listener_configured?
55
- @context.addApplicationListener('org.jruby.rack.rails.RailsServletContextListener')
57
+ @context.addApplicationListener(context_listener)
56
58
  end
57
59
  end
58
60
 
@@ -86,7 +88,7 @@ module Trinidad
86
88
  def rack_filter_configured?
87
89
  return false if @context.getDefaultWebXml().nil?
88
90
 
89
- web_xml = IO.read(@context.getDefaultWebXml())
91
+ web_xml = IO.read(@context.getDefaultWebXml()).gsub(/\s+/, '')
90
92
 
91
93
  return web_xml.include?('<servlet-class>org.jruby.rack.RackServlet') ||
92
94
  web_xml.include?('<filter-class>org.jruby.rack.RackFilter')
@@ -95,9 +97,13 @@ module Trinidad
95
97
  def rack_listener_configured?
96
98
  return false if @context.getDefaultWebXml().nil?
97
99
 
98
- web_xml = IO.read(@context.getDefaultWebXml())
100
+ web_xml = IO.read(@context.getDefaultWebXml()).gsub(/\s+/, '')
101
+
102
+ return web_xml.include?("<listener-class>#{context_listener}")
103
+ end
99
104
 
100
- return web_xml.include?('<listener-class>org.jruby.rack.rails.RailsServletContextListener')
105
+ def public_root
106
+ @context.findParameter('public.root') || @config[:public] || 'public'
101
107
  end
102
108
  end
103
- end
109
+ end
@@ -64,4 +64,22 @@ describe Trinidad::CommandLineParser do
64
64
  options[:ajp][:port].should == 8099
65
65
  options[:ajp][:secure].should == true
66
66
  end
67
- end
67
+
68
+ it "uses default rackup file to configure the server" do
69
+ ARGV = "--rackup".split
70
+ options = Trinidad::CommandLineParser.parse
71
+ options[:rackup].should == 'config.ru'
72
+ end
73
+
74
+ it "uses a custom rackup file if it's provided" do
75
+ ARGV = "--rackup custom_config.ru".split
76
+ options = Trinidad::CommandLineParser.parse
77
+ options[:rackup].should == 'custom_config.ru'
78
+ end
79
+
80
+ it "uses a custom public directory" do
81
+ ARGV = "--public web".split
82
+ options = Trinidad::CommandLineParser.parse
83
+ options[:public].should == 'web'
84
+ end
85
+ end
@@ -3,8 +3,8 @@ require File.dirname(__FILE__) + '/../spec_helper'
3
3
  describe Trinidad::WebApp do
4
4
  before do
5
5
  @tomcat = Trinidad::Tomcat::Tomcat.new
6
- tomcat_web_app = @tomcat.addWebapp('/', File.dirname(__FILE__) + '/../../')
7
- config = {
6
+ @tomcat_web_app = @tomcat.addWebapp('/', File.dirname(__FILE__) + '/../../')
7
+ @config = {
8
8
  :libs_dir => 'lib',
9
9
  :classes_dir => 'classes',
10
10
  :default_web_xml => 'config/web.xml',
@@ -13,9 +13,17 @@ describe Trinidad::WebApp do
13
13
  :jruby_max_runtimes => 6,
14
14
  :context_path => '/'
15
15
  }
16
- @web_app = Trinidad::WebApp.new(tomcat_web_app, config)
16
+ @web_app = Trinidad::RailsWebApp.new(@tomcat_web_app, @config)
17
17
  end
18
18
 
19
+ it "creates a RailsWebApp if rackup option is not present" do
20
+ Trinidad::WebApp.create(@tomcat_web_app, @config).is_a?(Trinidad::RailsWebApp).should be_true
21
+ end
22
+
23
+ it "creates a RackupWebApp if rackup option is present" do
24
+ Trinidad::WebApp.create(@tomcat_web_app, @config.merge(:rackup => 'config.ru')).is_a?(Trinidad::RackupWebApp).should be_true
25
+ end
26
+
19
27
  it "should load custom jars" do
20
28
  class_loader = org.jruby.util.JRubyClassLoader.new(JRuby.runtime.jruby_class_loader)
21
29
  @web_app.add_application_libs(class_loader)
@@ -94,4 +102,4 @@ describe Trinidad::WebApp do
94
102
  @web_app.add_context_loader
95
103
  end
96
104
 
97
- end
105
+ end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
- name: trinidad
3
- version: !ruby/object:Gem::Version
4
- version: 0.5.0
5
- platform: ruby
6
- authors:
7
- - David Calavera
8
- autorequire:
9
- bindir: bin
10
- cert_chain: []
11
-
12
- date: 2009-10-26 00:00:00 +01:00
13
- default_executable: trinidad
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rack
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "1.0"
24
- version:
25
- description:
2
+ required_ruby_version: !ruby/object:Gem::Requirement
3
+ requirements:
4
+ - - '>='
5
+ - !ruby/object:Gem::Version
6
+ version: "0"
7
+ version:
26
8
  email: calavera@apache.org
27
- executables:
28
- - trinidad
29
- extensions: []
9
+ cert_chain: []
30
10
 
11
+ summary: Simple library to run rails applications into an embedded Tomcat
12
+ post_install_message:
31
13
  extra_rdoc_files:
32
14
  - LICENSE
33
15
  - README.rdoc
16
+ homepage: http://calavera.github.com/trinidad
17
+ signing_key:
18
+ name: trinidad
19
+ rdoc_options:
20
+ - --charset=UTF-8
21
+ rubyforge_project: trinidad
22
+ autorequire:
23
+ licenses: []
24
+
25
+ executables:
26
+ - trinidad
27
+ description:
28
+ specification_version: 3
29
+ default_executable: trinidad
34
30
  files:
35
31
  - History.txt
36
32
  - LICENSE
@@ -42,6 +38,8 @@ files:
42
38
  - lib/trinidad/command_line_parser.rb
43
39
  - lib/trinidad/core_ext.rb
44
40
  - lib/trinidad/jars.rb
41
+ - lib/trinidad/rackup_web_app.rb
42
+ - lib/trinidad/rails_web_app.rb
45
43
  - lib/trinidad/server.rb
46
44
  - lib/trinidad/web_app.rb
47
45
  - trinidad-libs/core-3.1.1.jar
@@ -56,36 +54,40 @@ files:
56
54
  - trinidad-libs/tomcat-core.jar
57
55
  - trinidad-libs/tomcat-dbcp.jar
58
56
  - trinidad-libs/tomcat-jasper.jar
59
- has_rdoc: true
60
- homepage: http://calavera.github.com/trinidad
61
- licenses: []
62
-
63
- post_install_message:
64
- rdoc_options:
65
- - --charset=UTF-8
66
- require_paths:
67
- - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: "0"
73
- version:
74
57
  required_rubygems_version: !ruby/object:Gem::Requirement
75
58
  requirements:
76
- - - ">="
59
+ - - '>='
77
60
  - !ruby/object:Gem::Version
78
61
  version: "0"
79
62
  version:
80
- requirements: []
63
+ extensions: []
81
64
 
82
- rubyforge_project: trinidad
83
65
  rubygems_version: 1.3.5
84
- signing_key:
85
- specification_version: 3
86
- summary: Simple library to run rails applications into an embedded Tomcat
66
+ requirements: []
67
+
68
+ authors:
69
+ - David Calavera
70
+ date: 2009-11-01 23:00:00 +00:00
71
+ platform: ruby
87
72
  test_files:
88
73
  - spec/spec_helper.rb
89
- - spec/trinidad/server_spec.rb
90
74
  - spec/trinidad/command_line_parser_spec.rb
75
+ - spec/trinidad/server_spec.rb
91
76
  - spec/trinidad/web_app_spec.rb
77
+ version: !ruby/object:Gem::Version
78
+ version: 0.6.0
79
+ require_paths:
80
+ - lib
81
+ dependencies:
82
+ - !ruby/object:Gem::Dependency
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: "1.0"
88
+ version:
89
+ type: :runtime
90
+ version_requirement:
91
+ name: rack
92
+ bindir: bin
93
+ has_rdoc: true