trinidad 1.3.0 → 1.3.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 CHANGED
@@ -1,13 +1,17 @@
1
+ == Trinidad 1.3.1 (2012-01-06)
2
+
3
+ * Fix Rack handler configuration issues
4
+
5
+ == Trinidad_jars 1.0.2 (2011-12-31)
6
+
7
+ * Bump Tomcat's version to 7.0.23
8
+
1
9
  == Trinidad 1.3.0 (2011-12-30)
2
10
 
3
11
  * Support for virtual hosts
4
12
  * Ruby configuration DSL
5
13
  * Rack handler
6
14
 
7
- == Trinidad_jars 1.0.2 (2011-09-10)
8
-
9
- * Bump Tomcat's version to 7.0.21
10
-
11
15
  == Trinidad 1.2.3 (2011-07-13)
12
16
 
13
17
  * fix JRuby class loader generation with hot deploy
data/README.md CHANGED
@@ -12,13 +12,62 @@ Trinidad allows you to run a rails or rackup applications within an embedded Apa
12
12
  $ jruby -S gem install trinidad
13
13
  ```
14
14
 
15
- ## Usage
15
+ ## Quick Start
16
16
 
17
17
  ```
18
18
  $ cd myapp
19
19
  $ jruby -S trinidad
20
20
  ```
21
21
 
22
+ ### Advanced Rackup setup
23
+
24
+ **Sinatra**
25
+
26
+ You can run your Sinatra application with Trinidad from the command line like this:
27
+
28
+ ```
29
+ $ ruby app.rb -s Trinidad
30
+ ```
31
+
32
+ Or tou can configure your application to always use it:
33
+
34
+ ```ruby
35
+ require 'sinatra'
36
+ require 'trinidad'
37
+
38
+ configure do
39
+ set :server, :trinidad
40
+ end
41
+ ```
42
+
43
+ If you use Bundler, make sure you add Trinidad to your Gemfile:
44
+
45
+ ```
46
+ gem 'trinidad'
47
+ ```
48
+
49
+ **Rails**
50
+
51
+ If you already have Trinidad in your Gemfile you can start the server with the rails command:
52
+
53
+ ```
54
+ $ rails s trinidad
55
+ ```
56
+
57
+ **Rackup**
58
+
59
+ You can pass the server name as an option to `rackup`:
60
+
61
+ ```
62
+ $ rackup -s trinidad
63
+ ```
64
+
65
+ Or you can set Trinidad by default in your `config.ru` file:
66
+
67
+ ```
68
+ #\ -s trinidad
69
+ ```
70
+
22
71
  ## Configuration
23
72
 
24
73
  Trinidad allows you to configure some parameters when the server is started from the command line, the following is a list of the currently supported options:
@@ -8,26 +8,35 @@ module Rack
8
8
  module Handler
9
9
  class Trinidad < Rack::Handler::Servlet
10
10
  def self.run(app, options={})
11
- opts = options.dup
12
-
13
11
  # some libs use :Port, :port and :Host, :host, unify this
14
- opts.each {|k,v| opts[k.to_s.downcase.to_sym] = v}
12
+ opts = {}
13
+ options.each {|k, v| opts[k.to_s.downcase.to_sym] = v}
15
14
 
15
+ threads = (opts[:threads] || '1:1').split(':')
16
16
  opts[:app] = app
17
17
  opts[:port] ||= 3000
18
18
  opts[:address] = opts[:host] || 'localhost'
19
- opts[:servlet] = {:instance => servlet, :name => 'RackServlet'}
20
- opts[:jruby_max_runtimes] ||= 1
19
+ opts[:jruby_min_runtimes], opts[:jruby_max_runtimes] = threads[0].to_i, threads[1].to_i
21
20
 
22
21
  context = org.jruby.rack.embed.Context.new('Trinidad')
23
22
  dispatcher = org.jruby.rack.embed.Dispatcher.new(context, self.new(app))
24
23
  servlet = org.jruby.rack.embed.Servlet.new(dispatcher, context)
25
24
 
25
+ opts[:servlet] = {:instance => servlet, :name => 'RackServlet'}
26
+
26
27
  ::Trinidad::CommandLineParser.new.load_configuration(opts)
27
28
  ::Trinidad::Server.new.start
28
29
  end
30
+
31
+ def self.valid_options
32
+ {
33
+ "Host=HOST" => "Hostname to listen on (default: localhost)",
34
+ "Port=PORT" => "Port to listen on (default: 8080)",
35
+ "Threads=MIN:MAX" => "min:max threads to use (default 1:1, threadsafe)",
36
+ }
37
+ end
29
38
  end
39
+
40
+ register :trinidad, Trinidad
30
41
  end
31
42
  end
32
-
33
- Rack::Handler.register 'trinidad', 'Rack::Handler::Trinidad'
@@ -41,7 +41,7 @@ module Trinidad
41
41
  end
42
42
 
43
43
  def []=(name, value)
44
- send :"#{name}=", value
44
+ send :"#{name}=", value if respond_to?(:"#{name}=")
45
45
  end
46
46
 
47
47
  def has_key?(name)
data/lib/trinidad.rb CHANGED
@@ -24,5 +24,5 @@ require 'trinidad/war_web_app'
24
24
  require 'rack/handler/trinidad'
25
25
 
26
26
  module Trinidad
27
- VERSION = '1.3.0'
27
+ VERSION = '1.3.1'
28
28
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: trinidad
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.0
5
+ version: 1.3.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: 2011-12-30 00:00:00 Z
13
+ date: 2012-01-06 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: trinidad_jars