trinidad 0.7.0 → 0.7.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.
@@ -33,7 +33,7 @@ The server can also be configured from a yaml file. If a file is not especified,
33
33
 
34
34
  You can also specify a default web.xml to config your web application. By default the server tries to load the file <em>config/web.xml</em> but you can modify this path adding the option <em>default_web_xml</em> within your configuration file.
35
35
 
36
- Other <a href="http://wiki.github.com/calavera/trinidad/advanced-configuration">advanced options</a> can be found in the wiki.
36
+ Other advanced options can be found in the wiki: http://wiki.github.com/calavera/trinidad/advanced-configuration
37
37
 
38
38
  == Copyright
39
39
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -130,21 +130,14 @@ module Trinidad
130
130
  private
131
131
 
132
132
  def add_default_web_app!(config)
133
- if (!config.has_key?(:web_apps))
134
- default_app = if (config.has_key?(:rackup))
135
- {:rackup => config[:rackup]}
136
- else
137
- {
138
- :context_path => config[:context_path] || '/',
139
- :web_app_dir => config[:web_app_dir] || Dir.pwd
140
- }
141
- end
133
+ unless (config.has_key?(:web_apps))
134
+ default_app = {
135
+ :context_path => config[:context_path] || '/',
136
+ :web_app_dir => config[:web_app_dir] || Dir.pwd
137
+ }
138
+ default_app[:rackup] = config[:rackup] if (config.has_key?(:rackup))
142
139
 
143
- config.merge!({
144
- :web_apps => {
145
- :default => default_app
146
- }
147
- })
140
+ config[:web_apps] = { :default => default_app }
148
141
  end
149
142
  end
150
143
 
@@ -15,4 +15,6 @@ require 'mocha'
15
15
 
16
16
  Spec::Runner.configure do |config|
17
17
  config.mock_with :mocha
18
- end
18
+ end
19
+
20
+ MOCK_WEB_APP_DIR = File.join(File.dirname(__FILE__), 'web_app_mock')
@@ -23,7 +23,7 @@ describe Trinidad::CommandLineParser do
23
23
  end
24
24
 
25
25
  it "should override the config file when it's especified" do
26
- ARGV = "-f #{File.join(File.dirname(__FILE__), '..', 'web_app_mock', 'tomcat.yml')}".split
26
+ ARGV = "-f #{File.join(MOCK_WEB_APP_DIR, 'tomcat.yml')}".split
27
27
 
28
28
  options = Trinidad::CommandLineParser.parse
29
29
  options[:environment].should == 'production'
@@ -58,7 +58,7 @@ describe Trinidad::CommandLineParser do
58
58
  end
59
59
 
60
60
  it "should merge ajp options from the config file" do
61
- ARGV = "--ajp 8099 -f #{File.join(File.dirname(__FILE__), '..', 'web_app_mock', 'tomcat.yml')}".split
61
+ ARGV = "--ajp 8099 -f #{File.join(MOCK_WEB_APP_DIR, 'tomcat.yml')}".split
62
62
 
63
63
  options = Trinidad::CommandLineParser.parse
64
64
  options[:ajp][:port].should == 8099
@@ -14,7 +14,7 @@ describe Trinidad::Server do
14
14
 
15
15
  it "should have ssl enabled when config param is a number" do
16
16
  server = Trinidad::Server.new({:ssl => {:port => 8443},
17
- :web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock')})
17
+ :web_app_dir => MOCK_WEB_APP_DIR})
18
18
 
19
19
  server.ssl_enabled?.should == true
20
20
  end
@@ -27,7 +27,7 @@ describe Trinidad::Server do
27
27
 
28
28
  it "should have a connector with https scheme" do
29
29
  server = Trinidad::Server.new({:ssl => {:port => 8443},
30
- :web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock')})
30
+ :web_app_dir => MOCK_WEB_APP_DIR})
31
31
 
32
32
  server.tomcat.service.findConnectors().should have(1).connectors
33
33
  server.tomcat.service.findConnectors()[0].scheme.should == 'https'
@@ -45,24 +45,46 @@ describe Trinidad::Server do
45
45
  :web_apps => {
46
46
  :mock1 => {
47
47
  :context_path => '/mock1',
48
- :web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock')
48
+ :web_app_dir => MOCK_WEB_APP_DIR
49
49
  },
50
50
  :mock2 => {
51
- :context_path => '/mock2',
52
- :web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock')
51
+ :web_app_dir => MOCK_WEB_APP_DIR
52
+ },
53
+ :default => {
54
+ :web_app_dir => MOCK_WEB_APP_DIR
53
55
  }
54
56
  }
55
57
  })
56
58
 
57
- server.tomcat.host.findChildren().should have(2).web_apps
58
- server.tomcat.host.findChildren().each do |child|
59
- puts child.getPath()
59
+ context_loaded = server.tomcat.host.findChildren()
60
+ context_loaded.should have(3).web_apps
61
+
62
+ expected = ['/mock1', '/mock2', '/']
63
+ context_loaded.each do |context|
64
+ expected.delete(context.getPath()).should == context.getPath()
60
65
  end
61
66
  end
62
67
 
63
68
  it "loads the default application from the current directory if :web_apps is not present" do
64
- server = Trinidad::Server.new({:web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock')})
69
+ server = Trinidad::Server.new({:web_app_dir => MOCK_WEB_APP_DIR})
70
+
71
+ default_context_should_be_loaded(server.tomcat.host.findChildren())
72
+ end
73
+
74
+ it "loads the default application from the current directory using the rackup file if :web_apps is not present" do
75
+ server = Trinidad::Server.new({
76
+ :web_app_dir => MOCK_WEB_APP_DIR,
77
+ :rackup => 'config.ru'
78
+ })
79
+
80
+ context = default_context_should_be_loaded(server.tomcat.host.findChildren())
81
+ context.findParameter('rackup').gsub(/\s+/, ' ').should == "require 'rubygems' require 'sinatra'"
82
+ end
65
83
 
66
- server.tomcat.host.findChildren().should have(1).web_apps
84
+ def default_context_should_be_loaded(children)
85
+ children.should have(1).web_apps
86
+ children[0].getDocBase().should == MOCK_WEB_APP_DIR
87
+ children[0].getPath().should == '/'
88
+ children[0]
67
89
  end
68
90
  end
@@ -5,7 +5,7 @@ describe Trinidad::WebApp do
5
5
  @tomcat = Trinidad::Tomcat::Tomcat.new
6
6
  @tomcat_web_app = @tomcat.addWebapp('/', File.dirname(__FILE__) + '/../../')
7
7
  @app = {
8
- :web_app_dir => File.join(File.dirname(__FILE__), '..', 'web_app_mock'),
8
+ :web_app_dir => MOCK_WEB_APP_DIR,
9
9
  :context_path => '/'
10
10
  }
11
11
  @config = {
metadata CHANGED
@@ -1,32 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
- required_ruby_version: !ruby/object:Gem::Requirement
3
- requirements:
4
- - - '>='
5
- - !ruby/object:Gem::Version
6
- version: "0"
7
- version:
8
- email: calavera@apache.org
9
- cert_chain: []
10
-
11
- summary: Simple library to run rails applications into an embedded Tomcat
12
- post_install_message:
13
- extra_rdoc_files:
14
- - LICENSE
15
- - README.rdoc
16
- homepage: http://calavera.github.com/trinidad
17
- signing_key:
18
2
  name: trinidad
19
- rdoc_options:
20
- - --charset=UTF-8
21
- rubyforge_project: trinidad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.1
5
+ platform: ruby
6
+ authors:
7
+ - David Calavera
22
8
  autorequire:
23
- licenses: []
9
+ bindir: bin
10
+ cert_chain: []
24
11
 
12
+ date: 2009-12-01 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:
26
+ email: calavera@apache.org
25
27
  executables:
26
28
  - trinidad
27
- description:
28
- specification_version: 3
29
- default_executable: trinidad
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
30
34
  files:
31
35
  - History.txt
32
36
  - LICENSE
@@ -54,40 +58,36 @@ files:
54
58
  - trinidad-libs/tomcat-core.jar
55
59
  - trinidad-libs/tomcat-dbcp.jar
56
60
  - trinidad-libs/tomcat-jasper.jar
61
+ has_rdoc: true
62
+ homepage: http://calavera.github.com/trinidad
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --charset=UTF-8
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
57
76
  required_rubygems_version: !ruby/object:Gem::Requirement
58
77
  requirements:
59
- - - '>='
78
+ - - ">="
60
79
  - !ruby/object:Gem::Version
61
80
  version: "0"
62
81
  version:
63
- extensions: []
64
-
65
- rubygems_version: 1.3.5
66
82
  requirements: []
67
83
 
68
- authors:
69
- - David Calavera
70
- date: 2009-11-30 23:00:00 +00:00
71
- platform: ruby
84
+ rubyforge_project: trinidad
85
+ rubygems_version: 1.3.2
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Simple library to run rails applications into an embedded Tomcat
72
89
  test_files:
73
90
  - spec/spec_helper.rb
74
- - spec/trinidad/server_spec.rb
75
91
  - spec/trinidad/command_line_parser_spec.rb
92
+ - spec/trinidad/server_spec.rb
76
93
  - spec/trinidad/web_app_spec.rb
77
- version: !ruby/object:Gem::Version
78
- version: 0.7.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