trinidad 1.4.0 → 1.4.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.
- data/History.txt +15 -0
 - data/lib/trinidad/extensions.rb +75 -33
 - data/lib/trinidad/lifecycle/host.rb +1 -1
 - data/lib/trinidad/logging.rb +5 -5
 - data/lib/trinidad/server.rb +21 -13
 - data/lib/trinidad/version.rb +1 -1
 - data/lib/trinidad/web_app.rb +22 -4
 - metadata +2 -2
 
    
        data/History.txt
    CHANGED
    
    | 
         @@ -1,3 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            == Trinidad 1.4.1 (2012-08-17)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * make sure file logging rotates correctly when file handler attempts rolling 
         
     | 
| 
      
 4 
     | 
    
         
            +
              after midnight (#81)
         
     | 
| 
      
 5 
     | 
    
         
            +
            * refined (backwards-compatible) extension API 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - options attr reader 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - override_tomcat? no longer needed simply return a tomcat duck 
         
     | 
| 
      
 8 
     | 
    
         
            +
              - expose camelize + symbolize helpers
         
     | 
| 
      
 9 
     | 
    
         
            +
              - WebAppExtension should only get a single context argument on configure
         
     | 
| 
      
 10 
     | 
    
         
            +
            * better rails (2.3/3.x) detection with environment.rb
         
     | 
| 
      
 11 
     | 
    
         
            +
            * minor server updates 
         
     | 
| 
      
 12 
     | 
    
         
            +
              - expose configured web_apps 
         
     | 
| 
      
 13 
     | 
    
         
            +
              - add a trap? helper (for easier overrides) 
         
     | 
| 
      
 14 
     | 
    
         
            +
              - introduce a stop! for stopping and destroying a the server
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       1 
16 
     | 
    
         
             
            == Trinidad 1.4.0 (2012-07-24)
         
     | 
| 
       2 
17 
     | 
    
         | 
| 
       3 
18 
     | 
    
         
             
            * fix incorrect context-param parsing and only configure logging when 
         
     | 
    
        data/lib/trinidad/extensions.rb
    CHANGED
    
    | 
         @@ -1,77 +1,119 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Trinidad
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Extensions
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                      end
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
                def self.configure_options_extensions(extensions, parser, default_options)
         
     | 
| 
      
 5 
     | 
    
         
            +
                  extensions.each do |name, options|
         
     | 
| 
      
 6 
     | 
    
         
            +
                    if extension = extension(name, 'OptionsExtension', options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                      extension.configure(parser, default_options)
         
     | 
| 
       9 
8 
     | 
    
         
             
                    end
         
     | 
| 
       10 
     | 
    
         
            -
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end if extensions
         
     | 
| 
       11 
10 
     | 
    
         
             
                end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
                
         
     | 
| 
       13 
12 
     | 
    
         
             
                def self.configure_server_extensions(extensions, tomcat)
         
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
       16 
     | 
    
         
            -
                       
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                        tomcat =  
     | 
| 
      
 13 
     | 
    
         
            +
                  extensions.each do |name, options|
         
     | 
| 
      
 14 
     | 
    
         
            +
                    if extension = extension(name, 'ServerExtension', options)
         
     | 
| 
      
 15 
     | 
    
         
            +
                      outcome = extension.configure(tomcat)
         
     | 
| 
      
 16 
     | 
    
         
            +
                      if tomcat_like?(outcome) || extension.override_tomcat?
         
     | 
| 
      
 17 
     | 
    
         
            +
                        tomcat = outcome
         
     | 
| 
       19 
18 
     | 
    
         
             
                      end
         
     | 
| 
       20 
19 
     | 
    
         
             
                    end
         
     | 
| 
       21 
     | 
    
         
            -
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end if extensions
         
     | 
| 
       22 
21 
     | 
    
         
             
                  tomcat
         
     | 
| 
       23 
22 
     | 
    
         
             
                end
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                def self. 
     | 
| 
       26 
     | 
    
         
            -
                   
     | 
| 
       27 
     | 
    
         
            -
                     
     | 
| 
       28 
     | 
    
         
            -
                       
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                def self.configure_webapp_extensions(extensions, tomcat, context)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  extensions.each do |name, options|
         
     | 
| 
      
 26 
     | 
    
         
            +
                    if extension = extension(name, 'WebAppExtension', options)
         
     | 
| 
      
 27 
     | 
    
         
            +
                      extension.tomcat = tomcat
         
     | 
| 
      
 28 
     | 
    
         
            +
                      if extension.method(:configure).arity == 2
         
     | 
| 
      
 29 
     | 
    
         
            +
                        extension.configure(tomcat, context) # #deprecated old way
         
     | 
| 
      
 30 
     | 
    
         
            +
                      else
         
     | 
| 
      
 31 
     | 
    
         
            +
                        extension.configure(context)
         
     | 
| 
       30 
32 
     | 
    
         
             
                      end
         
     | 
| 
       31 
33 
     | 
    
         
             
                    end
         
     | 
| 
       32 
     | 
    
         
            -
                  end
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end if extensions
         
     | 
| 
       33 
35 
     | 
    
         
             
                end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                
         
     | 
| 
      
 37 
     | 
    
         
            +
                protected
         
     | 
| 
      
 38 
     | 
    
         
            +
                
         
     | 
| 
       35 
39 
     | 
    
         
             
                def self.extension(name, type, options)
         
     | 
| 
       36 
40 
     | 
    
         
             
                  class_name = (camelize(name.to_s) << type).to_sym
         
     | 
| 
       37 
41 
     | 
    
         
             
                  load_extension(name) unless const_defined?(class_name)
         
     | 
| 
       38 
42 
     | 
    
         
             
                  clazz = const_get(class_name) rescue nil
         
     | 
| 
       39 
     | 
    
         
            -
                  clazz.new(options) if clazz
         
     | 
| 
      
 43 
     | 
    
         
            +
                  clazz.new(options) if clazz # MyExtension.new(options)
         
     | 
| 
       40 
44 
     | 
    
         
             
                end
         
     | 
| 
       41 
45 
     | 
    
         | 
| 
       42 
46 
     | 
    
         
             
                def self.load_extension(name)
         
     | 
| 
       43 
47 
     | 
    
         
             
                  require "trinidad_#{name}_extension"
         
     | 
| 
       44 
48 
     | 
    
         
             
                end
         
     | 
| 
       45 
49 
     | 
    
         | 
| 
      
 50 
     | 
    
         
            +
                private
         
     | 
| 
      
 51 
     | 
    
         
            +
                
         
     | 
| 
      
 52 
     | 
    
         
            +
                def self.tomcat_like?(tomcat)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  tomcat.respond_to?(:server) && tomcat.respond_to?(:start) && tomcat.respond_to?(:stop)
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
                
         
     | 
| 
      
 56 
     | 
    
         
            +
                def self.camelize(string)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  string.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
                
         
     | 
| 
      
 60 
     | 
    
         
            +
                def self.camelize(string)
         
     | 
| 
      
 61 
     | 
    
         
            +
                  string = string.sub(/^[a-z\d]*/) { $&.capitalize }
         
     | 
| 
      
 62 
     | 
    
         
            +
                  string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
         
     | 
| 
      
 63 
     | 
    
         
            +
                  string.gsub!('/', '::')
         
     | 
| 
      
 64 
     | 
    
         
            +
                  string
         
     | 
| 
      
 65 
     | 
    
         
            +
                end
         
     | 
| 
      
 66 
     | 
    
         
            +
                
         
     | 
| 
       46 
67 
     | 
    
         
             
                class Extension
         
     | 
| 
      
 68 
     | 
    
         
            +
                  
         
     | 
| 
      
 69 
     | 
    
         
            +
                  attr_reader :options
         
     | 
| 
      
 70 
     | 
    
         
            +
                  
         
     | 
| 
       47 
71 
     | 
    
         
             
                  def initialize(options = {})
         
     | 
| 
       48 
72 
     | 
    
         
             
                    @options = options ? options.dup : {}
         
     | 
| 
       49 
73 
     | 
    
         
             
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                  
         
     | 
| 
      
 75 
     | 
    
         
            +
                  private
         
     | 
| 
      
 76 
     | 
    
         
            +
                  
         
     | 
| 
      
 77 
     | 
    
         
            +
                  # Hash#symbolize
         
     | 
| 
      
 78 
     | 
    
         
            +
                  def symbolize(options, deep = false)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    Trinidad::Configuration.symbolize_options(options, deep)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                  # String#camelize
         
     | 
| 
      
 83 
     | 
    
         
            +
                  def camelize(string)
         
     | 
| 
      
 84 
     | 
    
         
            +
                    Trinidad::Extensions.send :camelize, string
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
                  
         
     | 
| 
       50 
87 
     | 
    
         
             
                end
         
     | 
| 
       51 
88 
     | 
    
         | 
| 
       52 
89 
     | 
    
         
             
                class WebAppExtension < Extension
         
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 90 
     | 
    
         
            +
                  
         
     | 
| 
      
 91 
     | 
    
         
            +
                  attr_accessor :tomcat
         
     | 
| 
      
 92 
     | 
    
         
            +
                  
         
     | 
| 
      
 93 
     | 
    
         
            +
                  def configure(context)
         
     | 
| 
      
 94 
     | 
    
         
            +
                    raise NotImplementedError, "#{self.class.name}#configure(context) not implemented"
         
     | 
| 
       55 
95 
     | 
    
         
             
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
                  
         
     | 
| 
       56 
97 
     | 
    
         
             
                end
         
     | 
| 
       57 
98 
     | 
    
         | 
| 
       58 
99 
     | 
    
         
             
                class ServerExtension < Extension
         
     | 
| 
      
 100 
     | 
    
         
            +
                  
         
     | 
| 
       59 
101 
     | 
    
         
             
                  def configure(tomcat)
         
     | 
| 
       60 
     | 
    
         
            -
                    raise NotImplementedError, "#{self.class}#configure not implemented"
         
     | 
| 
      
 102 
     | 
    
         
            +
                    raise NotImplementedError, "#{self.class.name}#configure(tomcat) not implemented"
         
     | 
| 
       61 
103 
     | 
    
         
             
                  end
         
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
                   
     | 
| 
      
 104 
     | 
    
         
            +
                  
         
     | 
| 
      
 105 
     | 
    
         
            +
                  # #deprecated override tomcat by returning it from #configure
         
     | 
| 
      
 106 
     | 
    
         
            +
                  def override_tomcat?; false; end
         
     | 
| 
      
 107 
     | 
    
         
            +
                  
         
     | 
| 
       64 
108 
     | 
    
         
             
                end
         
     | 
| 
       65 
109 
     | 
    
         | 
| 
       66 
110 
     | 
    
         
             
                class OptionsExtension < Extension
         
     | 
| 
      
 111 
     | 
    
         
            +
                  
         
     | 
| 
       67 
112 
     | 
    
         
             
                  def configure(parser, default_options)
         
     | 
| 
       68 
     | 
    
         
            -
                    raise NotImplementedError, "#{self.class}#configure not implemented"
         
     | 
| 
      
 113 
     | 
    
         
            +
                    raise NotImplementedError, "#{self.class.name}#configure(parser, default_options) not implemented"
         
     | 
| 
       69 
114 
     | 
    
         
             
                  end
         
     | 
| 
      
 115 
     | 
    
         
            +
                  
         
     | 
| 
       70 
116 
     | 
    
         
             
                end
         
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                private
         
     | 
| 
       73 
     | 
    
         
            -
                def self.camelize(string)
         
     | 
| 
       74 
     | 
    
         
            -
                  string.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
         
     | 
| 
       75 
     | 
    
         
            -
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
                
         
     | 
| 
       76 
118 
     | 
    
         
             
              end
         
     | 
| 
       77 
119 
     | 
    
         
             
            end
         
     | 
    
        data/lib/trinidad/logging.rb
    CHANGED
    
    | 
         @@ -160,7 +160,8 @@ module Trinidad 
     | 
|
| 
       160 
160 
     | 
    
         
             
                  end
         
     | 
| 
       161 
161 
     | 
    
         | 
| 
       162 
162 
     | 
    
         
             
                  def closeWriter
         
     | 
| 
       163 
     | 
    
         
            -
                     
     | 
| 
      
 163 
     | 
    
         
            +
                    date = _date
         
     | 
| 
      
 164 
     | 
    
         
            +
                    super # sets `date = null`
         
     | 
| 
       164 
165 
     | 
    
         
             
                    # the additional trick here is to rotate the closed file
         
     | 
| 
       165 
166 
     | 
    
         
             
                    synchronized do
         
     | 
| 
       166 
167 
     | 
    
         
             
                      # we're normally in the lock here (from #publish) 
         
     | 
| 
         @@ -168,11 +169,10 @@ module Trinidad 
     | 
|
| 
       168 
169 
     | 
    
         
             
                      dir = java.io.File.new(directory).getAbsoluteFile
         
     | 
| 
       169 
170 
     | 
    
         
             
                      log = java.io.File.new(dir, prefix + "" + suffix)
         
     | 
| 
       170 
171 
     | 
    
         
             
                      if log.exists
         
     | 
| 
       171 
     | 
    
         
            -
                        date  
     | 
| 
       172 
     | 
    
         
            -
                        if date.empty?
         
     | 
| 
      
 172 
     | 
    
         
            +
                        if ! date || date.empty?
         
     | 
| 
       173 
173 
     | 
    
         
             
                          date = log.lastModified
         
     | 
| 
       174 
     | 
    
         
            -
                          # we 
     | 
| 
       175 
     | 
    
         
            -
                          # just like  
     | 
| 
      
 174 
     | 
    
         
            +
                          # we abuse Timestamp to get a date formatted !
         
     | 
| 
      
 175 
     | 
    
         
            +
                          # just like super does internally (just in case)
         
     | 
| 
       176 
176 
     | 
    
         
             
                          date = java.sql.Timestamp.new(date).toString[0, 10]
         
     | 
| 
       177 
177 
     | 
    
         
             
                        end
         
     | 
| 
       178 
178 
     | 
    
         
             
                        today = java.lang.System.currentTimeMillis
         
     | 
    
        data/lib/trinidad/server.rb
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Trinidad
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Server
         
     | 
| 
       3 
     | 
    
         
            -
                attr_reader :tomcat, : 
     | 
| 
      
 3 
     | 
    
         
            +
                attr_reader :config, :tomcat, :web_apps
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                def initialize(config = Trinidad.configuration)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  load_config(config)
         
     | 
| 
       7 
7 
     | 
    
         
             
                  configure_logging(@config[:log])
         
     | 
| 
       8 
8 
     | 
    
         
             
                  load_tomcat_server
         
     | 
| 
       9 
     | 
    
         
            -
                   
     | 
| 
       10 
     | 
    
         
            -
                  load_host_monitor( 
     | 
| 
      
 9 
     | 
    
         
            +
                  @web_apps = create_web_apps
         
     | 
| 
      
 10 
     | 
    
         
            +
                  load_host_monitor(@web_apps)
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def load_config(config)
         
     | 
| 
         @@ -114,7 +114,7 @@ module Trinidad 
     | 
|
| 
       114 
114 
     | 
    
         
             
                end
         
     | 
| 
       115 
115 
     | 
    
         | 
| 
       116 
116 
     | 
    
         
             
                def start
         
     | 
| 
       117 
     | 
    
         
            -
                  trap_signals if  
     | 
| 
      
 117 
     | 
    
         
            +
                  trap_signals if trap?
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
       119 
119 
     | 
    
         
             
                  @tomcat.start
         
     | 
| 
       120 
120 
     | 
    
         
             
                  @tomcat.server.await
         
     | 
| 
         @@ -122,16 +122,24 @@ module Trinidad 
     | 
|
| 
       122 
122 
     | 
    
         | 
| 
       123 
123 
     | 
    
         
             
                def stop
         
     | 
| 
       124 
124 
     | 
    
         
             
                  @tomcat.stop
         
     | 
| 
       125 
     | 
    
         
            -
                  @tomcat.destroy
         
     | 
| 
       126 
125 
     | 
    
         
             
                end
         
     | 
| 
       127 
126 
     | 
    
         | 
| 
      
 127 
     | 
    
         
            +
                def stop!
         
     | 
| 
      
 128 
     | 
    
         
            +
                  stop
         
     | 
| 
      
 129 
     | 
    
         
            +
                  @tomcat.destroy
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
                
         
     | 
| 
       128 
132 
     | 
    
         
             
                protected
         
     | 
| 
       129 
133 
     | 
    
         | 
| 
      
 134 
     | 
    
         
            +
                def trap?
         
     | 
| 
      
 135 
     | 
    
         
            +
                  !!@config[:trap]
         
     | 
| 
      
 136 
     | 
    
         
            +
                end
         
     | 
| 
      
 137 
     | 
    
         
            +
                
         
     | 
| 
       130 
138 
     | 
    
         
             
                def create_web_apps
         
     | 
| 
       131 
     | 
    
         
            -
                  apps = []
         
     | 
| 
       132 
     | 
    
         
            -
                  apps << create_from_web_apps
         
     | 
| 
      
 139 
     | 
    
         
            +
                  apps = [ create_from_web_apps ]
         
     | 
| 
       133 
140 
     | 
    
         
             
                  apps << create_from_apps_base
         
     | 
| 
       134 
     | 
    
         
            -
                  apps.flatten.compact
         
     | 
| 
      
 141 
     | 
    
         
            +
                  apps.flatten!; apps.compact!
         
     | 
| 
      
 142 
     | 
    
         
            +
                  apps
         
     | 
| 
       135 
143 
     | 
    
         
             
                end
         
     | 
| 
       136 
144 
     | 
    
         | 
| 
       137 
145 
     | 
    
         
             
                def create_from_web_apps
         
     | 
| 
         @@ -232,9 +240,8 @@ module Trinidad 
     | 
|
| 
       232 
240 
     | 
    
         
             
                def generate_default_keystore(config)
         
     | 
| 
       233 
241 
     | 
    
         
             
                  keystore_file = java.io.File.new(config[:keystoreFile])
         
     | 
| 
       234 
242 
     | 
    
         | 
| 
       235 
     | 
    
         
            -
                  if  
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
                      raise "Unable to create keystore folder: " + keystore_file.parent_file.canonical_path
         
     | 
| 
      
 243 
     | 
    
         
            +
                  if ! keystore_file.parent_file.exists && ! keystore_file.parent_file.mkdir
         
     | 
| 
      
 244 
     | 
    
         
            +
                      raise "Unable to create keystore folder: #{keystore_file.parent_file.canonical_path}"
         
     | 
| 
       238 
245 
     | 
    
         
             
                  end
         
     | 
| 
       239 
246 
     | 
    
         | 
| 
       240 
247 
     | 
    
         
             
                  key_tool_args = ["-genkey",
         
     | 
| 
         @@ -252,8 +259,9 @@ module Trinidad 
     | 
|
| 
       252 
259 
     | 
    
         
             
                end
         
     | 
| 
       253 
260 
     | 
    
         | 
| 
       254 
261 
     | 
    
         
             
                def trap_signals
         
     | 
| 
       255 
     | 
    
         
            -
                  trap('INT') { stop }
         
     | 
| 
       256 
     | 
    
         
            -
                  trap('TERM') { stop }
         
     | 
| 
      
 262 
     | 
    
         
            +
                  trap('INT') { stop! }
         
     | 
| 
      
 263 
     | 
    
         
            +
                  trap('TERM') { stop! }
         
     | 
| 
       257 
264 
     | 
    
         
             
                end
         
     | 
| 
      
 265 
     | 
    
         
            +
                
         
     | 
| 
       258 
266 
     | 
    
         
             
              end
         
     | 
| 
       259 
267 
     | 
    
         
             
            end
         
     | 
    
        data/lib/trinidad/version.rb
    CHANGED
    
    
    
        data/lib/trinidad/web_app.rb
    CHANGED
    
    | 
         @@ -179,7 +179,7 @@ module Trinidad 
     | 
|
| 
       179 
179 
     | 
    
         
             
                private
         
     | 
| 
       180 
180 
     | 
    
         | 
| 
       181 
181 
     | 
    
         
             
                def web_xml_doc
         
     | 
| 
       182 
     | 
    
         
            -
                  return @web_xml_doc || nil  
     | 
| 
      
 182 
     | 
    
         
            +
                  return @web_xml_doc || nil unless @web_xml_doc.nil?
         
     | 
| 
       183 
183 
     | 
    
         
             
                  if deployment_descriptor
         
     | 
| 
       184 
184 
     | 
    
         
             
                    begin
         
     | 
| 
       185 
185 
     | 
    
         
             
                      require 'rexml/document'
         
     | 
| 
         @@ -200,14 +200,32 @@ module Trinidad 
     | 
|
| 
       200 
200 
     | 
    
         
             
                  web_app_dir = config[:web_app_dir] || 
         
     | 
| 
       201 
201 
     | 
    
         
             
                    (default_config && default_config[:web_app_dir]) || Dir.pwd
         
     | 
| 
       202 
202 
     | 
    
         
             
                  config_ru = (default_config && default_config[:rackup]) || 'config.ru'
         
     | 
| 
       203 
     | 
    
         
            -
                  #  
     | 
| 
      
 203 
     | 
    
         
            +
                  # check for rackup (but still use config/environment.rb for rails 3)
         
     | 
| 
       204 
204 
     | 
    
         
             
                  if File.exists?(File.join(web_app_dir, config_ru)) && 
         
     | 
| 
       205 
     | 
    
         
            -
                      !  
     | 
| 
      
 205 
     | 
    
         
            +
                      ! rails?(config, default_config) # do not :rackup a rails app
         
     | 
| 
       206 
206 
     | 
    
         
             
                    config[:rackup] = config_ru
         
     | 
| 
       207 
207 
     | 
    
         
             
                  end
         
     | 
| 
       208 
208 
     | 
    
         
             
                  config[:rackup] || ! Dir[File.join(web_app_dir, 'WEB-INF/**/config.ru')].empty?
         
     | 
| 
       209 
209 
     | 
    
         
             
                end
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
      
 210 
     | 
    
         
            +
                
         
     | 
| 
      
 211 
     | 
    
         
            +
                def self.rails?(config, default_config = nil)
         
     | 
| 
      
 212 
     | 
    
         
            +
                  web_app_dir = config[:web_app_dir] || 
         
     | 
| 
      
 213 
     | 
    
         
            +
                    (default_config && default_config[:web_app_dir]) || Dir.pwd
         
     | 
| 
      
 214 
     | 
    
         
            +
                  # standart Rails 3.x `class Application < Rails::Application`
         
     | 
| 
      
 215 
     | 
    
         
            +
                  if File.exists?(application = File.join(web_app_dir, 'config/application.rb'))
         
     | 
| 
      
 216 
     | 
    
         
            +
                    application_rb = File.read(application)
         
     | 
| 
      
 217 
     | 
    
         
            +
                    return true if application_rb =~ /^[^#]*Rails::Application/
         
     | 
| 
      
 218 
     | 
    
         
            +
                  end
         
     | 
| 
      
 219 
     | 
    
         
            +
                  if File.exists?(environment = File.join(web_app_dir, 'config/environment.rb'))
         
     | 
| 
      
 220 
     | 
    
         
            +
                    environment_rb = File.read(environment)
         
     | 
| 
      
 221 
     | 
    
         
            +
                    # customized Rails 3.x, expect a `Rails::Application` subclass
         
     | 
| 
      
 222 
     | 
    
         
            +
                    return true if environment_rb =~ /^[^#]*Rails::Application/
         
     | 
| 
      
 223 
     | 
    
         
            +
                    # plain-old Rails 2.3 `RAILS_GEM_VERSION = '2.3.14'` ...
         
     | 
| 
      
 224 
     | 
    
         
            +
                    return true if environment_rb =~ /^[^#]*RAILS_GEM_VERSION/
         
     | 
| 
      
 225 
     | 
    
         
            +
                  end
         
     | 
| 
      
 226 
     | 
    
         
            +
                  false
         
     | 
| 
      
 227 
     | 
    
         
            +
                end
         
     | 
| 
      
 228 
     | 
    
         
            +
                
         
     | 
| 
       211 
229 
     | 
    
         
             
                def self.war?(config, default_config = nil)
         
     | 
| 
       212 
230 
     | 
    
         
             
                  config[:context_path] && config[:context_path][-4..-1] == '.war'
         
     | 
| 
       213 
231 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            name: trinidad
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
4 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       5 
     | 
    
         
            -
              version: 1.4. 
     | 
| 
      
 5 
     | 
    
         
            +
              version: 1.4.1
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors: 
         
     | 
| 
       8 
8 
     | 
    
         
             
              - David Calavera
         
     | 
| 
         @@ -10,7 +10,7 @@ autorequire: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            date: 2012- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2012-08-17 00:00:00 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
              - !ruby/object:Gem::Dependency 
         
     | 
| 
       16 
16 
     | 
    
         
             
                name: trinidad_jars
         
     |