trinidad 1.4.4 → 1.4.5.B1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Trinidad
2
- VERSION = '1.4.4'
2
+ VERSION = '1.4.5.B1'
3
3
  end
@@ -13,7 +13,7 @@ module Trinidad
13
13
  RailsWebApp.new(config, default_config)
14
14
  end
15
15
 
16
- def initialize(config, default_config)
16
+ def initialize(config, default_config = Trinidad.configuration)
17
17
  @config, @default_config = config, default_config || {}
18
18
  complete_config!
19
19
  # NOTE: we should maybe @config.freeze here ?!
@@ -30,13 +30,16 @@ module Trinidad
30
30
  use_default ? default_config.key?(key) : false
31
31
  end
32
32
 
33
- %w{ root_dir rackup log async_supported reload_strategy }.each do |method|
33
+ %w{ root_dir rackup async_supported reload_strategy host_name }.each do |method|
34
34
  class_eval "def #{method}; self[:'#{method}']; end"
35
35
  end
36
- alias_method :web_app_dir, :root_dir # is getting deprecated soon
37
36
 
37
+ alias_method :web_app_dir, :root_dir # is getting deprecated soon
38
38
  def app_root; root_dir; end
39
39
 
40
+ # @deprecated use `self[:log]` instead
41
+ def log; self[:log]; end
42
+
40
43
  def context_path
41
44
  path = self[:context_path] || self[:path]
42
45
  path ? path.to_s : path
@@ -87,7 +90,7 @@ module Trinidad
87
90
  def environment; self[:environment] || @@defaults[:environment]; end # TODO check web.xml
88
91
 
89
92
  def public_dir
90
- @public_dir ||= expand_path(public_root)
93
+ @public_dir ||= ( public_root == '/' ? root_dir : expand_path(public_root) )
91
94
  end
92
95
 
93
96
  # by (a "Rails") convention use '[RAILS_ROOT]/tmp'
@@ -144,6 +147,7 @@ module Trinidad
144
147
  add_context_param 'jruby.compat.version', jruby_compat_version
145
148
  add_context_param 'public.root', public_root
146
149
  add_context_param 'jruby.rack.layout_class', layout_class
150
+ add_context_param 'jruby.rack.error', false # do not start error app on errors
147
151
  @context_params
148
152
  end
149
153
  # @deprecated replaced with {#context_params}
@@ -388,20 +392,8 @@ module Trinidad
388
392
  raise NotImplementedError.new "context_listener expected to be redefined"
389
393
  end
390
394
 
391
- if Gem::Version.create(JRuby::Rack::VERSION) > Gem::Version.create('1.1.10')
392
- def layout_class
393
- 'JRuby::Rack::FileSystemLayout' # handles Rails as well as Rack
394
- end
395
- else
396
- def layout_class
397
- # NOTE: we'll also need to do a GEM_PATH hack to avoid a bug :
398
- if gem_path = ENV['GEM_PATH']
399
- add_context_param 'gem.path', gem_path
400
- # ENV['GEM_PATH'] will contain twice the same entry(ies) ...
401
- end
402
- add_context_param 'rails.root', app_root # still boots a rack app
403
- 'JRuby::Rack::RailsFilesystemLayout' # no plain FS layout defined !
404
- end
395
+ def layout_class
396
+ 'JRuby::Rack::FileSystemLayout' # handles Rails as well as Rack
405
397
  end
406
398
 
407
399
  def complete_config!
@@ -538,17 +530,20 @@ module Trinidad
538
530
  end
539
531
 
540
532
  def self.war?(config, default_config = nil)
541
- config[:context_path] && config[:context_path].to_s[-4..-1] == '.war'
533
+ root_dir = root_dir(config, default_config)
534
+ return true if root_dir && root_dir.to_s[-4..-1] == '.war'
535
+ context_path = config[:context_path] # backwards-compatibility :
536
+ context_path && context_path.to_s[-4..-1] == '.war'
542
537
  end
543
538
 
544
539
  private
545
540
 
546
- def self.root_dir(config, default_config)
541
+ def self.root_dir(config, default_config, default_dir = Dir.pwd)
547
542
  # for backwards compatibility accepts the :web_app_dir "alias"
548
543
  config[:root_dir] || config[:web_app_dir] ||
549
544
  ( default_config &&
550
545
  ( default_config[:root_dir] || default_config[:web_app_dir] ) ) ||
551
- Dir.pwd
546
+ default_dir
552
547
  end
553
548
 
554
549
  def self.context_path(config, default_config = nil)
@@ -629,7 +624,7 @@ module Trinidad
629
624
 
630
625
  end
631
626
 
632
- # Rack web application (looks for a rackup config.ru file).
627
+ # Rack web application (looks for a "rackup" *config.ru* file).
633
628
  class RackupWebApp < WebApp
634
629
 
635
630
  def context_params
@@ -646,7 +641,7 @@ module Trinidad
646
641
 
647
642
  end
648
643
 
649
- # Rails web app specifics. Supports the same versions as jruby-rack !
644
+ # Rails web application specifics (supports same versions as JRuby-Rack).
650
645
  class RailsWebApp < WebApp
651
646
 
652
647
  def context_params
@@ -680,7 +675,12 @@ module Trinidad
680
675
  end
681
676
 
682
677
  def self.threadsafe_match?(file)
683
- File.exist?(file) && file_line_match?(file, /^[^#]*threadsafe!/)
678
+ File.exist?(file) && (
679
+ file_line_match?(file, /^[^#]*threadsafe!/) || ( # Rails 4.0
680
+ file_line_match?(file, /^[^#]*config\.eager_load = true/) &&
681
+ file_line_match?(file, /^[^#]*config\.cache_classes = true/)
682
+ )
683
+ )
684
684
  end
685
685
 
686
686
  end
@@ -688,30 +688,64 @@ module Trinidad
688
688
  # A web application for deploying (java) .war files.
689
689
  class WarWebApp < WebApp
690
690
 
691
- def context_path
692
- super.gsub(/\.war$/, '')
691
+ def root_dir
692
+ @root_dir ||= ( config[:root_dir] || begin
693
+ path = config[:context_path]
694
+ path.to_s if path.to_s[-4..-1] == '.war'
695
+ end || default_confit[:root_dir] )
693
696
  end
694
-
695
- def log_dir
696
- @log_dir ||= self[:log_dir] || File.join(work_dir, 'log')
697
+
698
+ def context_path
699
+ @path ||= begin
700
+ path = File.basename(super)
701
+ context_name = Trinidad::Tomcat::ContextName.new(path)
702
+ context_name.path # removes .war handles ## versioning
703
+ end
697
704
  end
698
-
705
+
699
706
  def work_dir
700
- @work_dir ||= File.join(root_dir.gsub(/\.war$/, ''), 'WEB-INF')
707
+ self[:work_dir]
701
708
  end
702
709
 
710
+ def log_dir
711
+ @log_dir ||= self[:log_dir] || begin
712
+ if work_dir then work_dir
713
+ else
714
+ if root_dir[-4..-1] == '.war'
715
+ parent_dir = File.dirname(root_dir)
716
+ expanded_dir = File.join(parent_dir, context_path)
717
+ File.exist?(expanded_dir) ? expanded_dir : parent_dir
718
+ else
719
+ File.join(root_dir, 'log')
720
+ end
721
+ end
722
+ end
723
+ end
724
+
703
725
  def monitor
704
- File.expand_path(root_dir)
726
+ root_dir ? File.expand_path(root_dir) : nil # the .war file itself
727
+ end
728
+
729
+ def class_loader
730
+ @class_loader ||= nil # lifecycle will setup JRuby CL
705
731
  end
706
732
 
707
- def define_lifecycle
708
- Trinidad::Lifecycle::WebApp::War.new(self)
733
+ def context_params
734
+ warbler? ? super : @context_params ||= {}
709
735
  end
710
-
736
+
711
737
  def layout_class
712
738
  'JRuby::Rack::WebInfLayout'
713
739
  end
714
740
 
741
+ def define_lifecycle
742
+ Trinidad::Lifecycle::WebApp::War.new(self)
743
+ end
744
+
745
+ private
746
+
747
+ def warbler?; nil; end # TODO detect warbler created .war ?!
748
+
715
749
  end
716
750
 
717
751
  end
@@ -67,6 +67,7 @@ end
67
67
  namespace :'tomcat-core' do
68
68
 
69
69
  task :compile do
70
+ mkdir_p TOMCAT_CORE_TARGET_DIR unless File.exist?(TOMCAT_CORE_TARGET_DIR)
70
71
  javac "src/tomcat-core/java", TOMCAT_CORE_TARGET_DIR
71
72
  end
72
73
 
@@ -21,15 +21,13 @@ Gem::Specification.new do |s|
21
21
  s.rdoc_options = ["--charset=UTF-8"]
22
22
  s.extra_rdoc_files = %w[README.md LICENSE]
23
23
 
24
- s.add_dependency('trinidad_jars', ">= 1.1.0")
25
- s.add_dependency('jruby-rack', ">= 1.1.10")
24
+ s.add_dependency('trinidad_jars', ">= 1.2.2")
25
+ s.add_dependency('jruby-rack', ">= 1.1.13")
26
26
 
27
- s.add_development_dependency('rack')
28
27
  s.add_development_dependency('rake')
29
- s.add_development_dependency('rspec', '~> 2.10')
30
- s.add_development_dependency('mocha')
28
+ s.add_development_dependency('rspec', '~> 2.12.0')
29
+ s.add_development_dependency('mocha', '~> 0.12.1')
31
30
  s.add_development_dependency('fakefs', '>= 0.4.0')
32
- s.add_development_dependency('sinatra')
33
31
 
34
32
  s.files = `git ls-files`.split("\n").sort.
35
33
  reject { |file| file =~ /^\./ }. # .gitignore, .travis.yml
metadata CHANGED
@@ -1,171 +1,176 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: trinidad
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.4.4
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 6
5
+ version: 1.4.5.B1
6
6
  platform: ruby
7
- authors:
8
- - David Calavera
9
- autorequire:
7
+ authors:
8
+ - David Calavera
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-10-19 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: trinidad_jars
17
- version_requirements: &id001 !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 1.1.0
23
- requirement: *id001
24
- prerelease: false
25
- type: :runtime
26
- - !ruby/object:Gem::Dependency
27
- name: jruby-rack
28
- version_requirements: &id002 !ruby/object:Gem::Requirement
29
- none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.1.10
34
- requirement: *id002
35
- prerelease: false
36
- type: :runtime
37
- - !ruby/object:Gem::Dependency
38
- name: rack
39
- version_requirements: &id003 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
45
- requirement: *id003
46
- prerelease: false
47
- type: :development
48
- - !ruby/object:Gem::Dependency
49
- name: rake
50
- version_requirements: &id004 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
56
- requirement: *id004
57
- prerelease: false
58
- type: :development
59
- - !ruby/object:Gem::Dependency
60
- name: rspec
61
- version_requirements: &id005 !ruby/object:Gem::Requirement
62
- none: false
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
66
- version: "2.10"
67
- requirement: *id005
68
- prerelease: false
69
- type: :development
70
- - !ruby/object:Gem::Dependency
71
- name: mocha
72
- version_requirements: &id006 !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
78
- requirement: *id006
79
- prerelease: false
80
- type: :development
81
- - !ruby/object:Gem::Dependency
82
- name: fakefs
83
- version_requirements: &id007 !ruby/object:Gem::Requirement
84
- none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: 0.4.0
89
- requirement: *id007
90
- prerelease: false
91
- type: :development
92
- - !ruby/object:Gem::Dependency
93
- name: sinatra
94
- version_requirements: &id008 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
100
- requirement: *id008
101
- prerelease: false
102
- type: :development
12
+ date: 2013-03-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: trinidad_jars
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.2.2
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.2
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ name: jruby-rack
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.1.13
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.1.13
43
+ none: false
44
+ prerelease: false
45
+ type: :runtime
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: !binary |-
53
+ MA==
54
+ none: false
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: !binary |-
60
+ MA==
61
+ none: false
62
+ prerelease: false
63
+ type: :development
64
+ - !ruby/object:Gem::Dependency
65
+ name: rspec
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: 2.12.0
71
+ none: false
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 2.12.0
77
+ none: false
78
+ prerelease: false
79
+ type: :development
80
+ - !ruby/object:Gem::Dependency
81
+ name: mocha
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: 0.12.1
87
+ none: false
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: 0.12.1
93
+ none: false
94
+ prerelease: false
95
+ type: :development
96
+ - !ruby/object:Gem::Dependency
97
+ name: fakefs
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 0.4.0
103
+ none: false
104
+ requirement: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 0.4.0
109
+ none: false
110
+ prerelease: false
111
+ type: :development
103
112
  description: Trinidad allows you to run Rails or Rack applications within an embedded Apache Tomcat container. Serves your requests with the elegance of a cat !
104
113
  email: calavera@apache.org
105
- executables:
106
- - trinidad
114
+ executables:
115
+ - trinidad
107
116
  extensions: []
108
-
109
- extra_rdoc_files:
110
- - README.md
111
- - LICENSE
112
- files:
113
- - Gemfile
114
- - History.txt
115
- - LICENSE
116
- - README.md
117
- - Rakefile
118
- - bin/trinidad
119
- - lib/rack/handler/trinidad.rb
120
- - lib/trinidad.rb
121
- - lib/trinidad/command_line_parser.rb
122
- - lib/trinidad/configuration.rb
123
- - lib/trinidad/extensions.rb
124
- - lib/trinidad/lifecycle/base.rb
125
- - lib/trinidad/lifecycle/host.rb
126
- - lib/trinidad/lifecycle/host/restart_reload.rb
127
- - lib/trinidad/lifecycle/host/rolling_reload.rb
128
- - lib/trinidad/lifecycle/web_app/default.rb
129
- - lib/trinidad/lifecycle/web_app/shared.rb
130
- - lib/trinidad/lifecycle/web_app/war.rb
131
- - lib/trinidad/logging.rb
132
- - lib/trinidad/server.rb
133
- - lib/trinidad/version.rb
134
- - lib/trinidad/web_app.rb
135
- - rakelib/tomcat.rake
136
- - trinidad.gemspec
117
+ extra_rdoc_files:
118
+ - README.md
119
+ - LICENSE
120
+ files:
121
+ - Gemfile
122
+ - History.txt
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - bin/trinidad
127
+ - lib/rack/handler/trinidad.rb
128
+ - lib/trinidad.rb
129
+ - lib/trinidad/command_line_parser.rb
130
+ - lib/trinidad/configuration.rb
131
+ - lib/trinidad/extensions.rb
132
+ - lib/trinidad/helpers.rb
133
+ - lib/trinidad/lifecycle/base.rb
134
+ - lib/trinidad/lifecycle/host.rb
135
+ - lib/trinidad/lifecycle/host/restart_reload.rb
136
+ - lib/trinidad/lifecycle/host/rolling_reload.rb
137
+ - lib/trinidad/lifecycle/web_app/default.rb
138
+ - lib/trinidad/lifecycle/web_app/shared.rb
139
+ - lib/trinidad/lifecycle/web_app/war.rb
140
+ - lib/trinidad/logging.rb
141
+ - lib/trinidad/server.rb
142
+ - lib/trinidad/version.rb
143
+ - lib/trinidad/web_app.rb
144
+ - rakelib/tomcat.rake
145
+ - trinidad.gemspec
137
146
  homepage: http://github.com/trinidad/trinidad
138
147
  licenses: []
139
-
140
- post_install_message:
141
- rdoc_options:
142
- - --charset=UTF-8
143
- require_paths:
144
- - lib
145
- required_ruby_version: !ruby/object:Gem::Requirement
148
+ post_install_message:
149
+ rdoc_options:
150
+ - "--charset=UTF-8"
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ segments:
158
+ - 0
159
+ hash: 2
160
+ version: !binary |-
161
+ MA==
146
162
  none: false
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- hash: 2
151
- segments:
152
- - 0
153
- version: "0"
154
- required_rubygems_version: !ruby/object:Gem::Requirement
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - !binary |-
166
+ Pg==
167
+ - !ruby/object:Gem::Version
168
+ version: 1.3.1
155
169
  none: false
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- hash: 2
160
- segments:
161
- - 0
162
- version: "0"
163
170
  requirements: []
164
-
165
- rubyforge_project:
171
+ rubyforge_project:
166
172
  rubygems_version: 1.8.24
167
- signing_key:
173
+ signing_key:
168
174
  specification_version: 3
169
175
  summary: Web server for Rails/Rack applications built upon JRuby::Rack and Apache Tomcat
170
176
  test_files: []
171
-