public this repo is viewable by everyone
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Merge branch 'coreteam'

* coreteam:
  Add changelog for last commit
  Add changelog entry for last commit
  Allow rackup .rb files by getting a conventionally named constant as the 
  app
markbates (author)
23 days ago
commit  5d0a3a0bfd9d3e9d0ea3c0f14a6873f58a6e35ce
tree    b79388293e37c34dd95e4bfe4cf3655ac8747c7b
parent  ce6d00751644715c82044d1194a34fc61ca0823d parent  c8c527bef69c6b795739c6efd0849c41c55c37de
...
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
+== 0.8.2 ??? release
0
+ * Added Mack adapter [markbates]
0
+ * Allow rackup .rb files by getting a conventionally named constant as the app [bmizerany]
0
+
0
 == 0.8.1 Rebel Porpoise release
0
  * [bug] Rescue all types of errors when processing request, fixes #62
0
  * [bug] Use Swiftiply backend when -y option is specified, fixes #63 and #64
...
 
0
...
1
2
0
@@ -0,0 +1 @@
0
+Myapp = lambda { |env| [200, {}, 'this is my app!'] }
0
\ No newline at end of file
...
161
162
163
164
165
 
 
 
 
 
 
 
 
 
 
166
167
168
...
161
162
163
 
 
164
165
166
167
168
169
170
171
172
173
174
175
176
0
@@ -161,8 +161,16 @@ module Thin
0
         end
0
         
0
         def load_rackup_config
0
- rackup_code = File.read(@options[:rackup])
0
- eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, @options[:rackup])
0
+ case @options[:rackup]
0
+ when /\.rb$/
0
+ Kernel.load(@options[:rackup])
0
+ Object.const_get(File.basename(@options[:rackup], '.rb').capitalize.to_sym)
0
+ when /\.ru$/
0
+ rackup_code = File.read(@options[:rackup])
0
+ eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, @options[:rackup])
0
+ else
0
+ raise "Invalid rackup file. please specify either a .ru or .rb file"
0
+ end
0
         end
0
     end
0
   end
...
63
64
65
66
 
67
68
69
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
72
73
...
75
76
77
 
78
79
80
...
63
64
65
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
89
90
91
92
93
94
95
0
@@ -63,11 +63,25 @@ describe Controller, 'start' do
0
   end
0
   
0
   it "should load app from Rack config" do
0
- @controller.options[:rackup] = 'example/config.ru'
0
+ @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
0
     @controller.start
0
     
0
     @server.app.class.should == Proc
0
   end
0
+
0
+ it "should load app from ruby file" do
0
+ @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.rb'
0
+ @controller.start
0
+
0
+ @server.app.should == Myapp
0
+ end
0
+
0
+ it "should throwup if rackup is not a .ru or .rb file" do
0
+ proc do
0
+ @controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.foo'
0
+ @controller.start
0
+ end.should raise_error(RuntimeError, /please/)
0
+ end
0
   
0
   it "should set server as threaded" do
0
     @controller.options[:threaded] = true
0
@@ -75,6 +89,7 @@ describe Controller, 'start' do
0
     
0
     @server.threaded.should be_true
0
   end
0
+
0
 end
0
 
0
 describe Controller do

Comments

    No one has commented yet.