Skip to content

Commit

Permalink
Merge branch 'master' into async_for_rack
Browse files Browse the repository at this point in the history
* master:
  Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved]
  Add CHANGELOG entry for last merge [#85 state:resolved]
  Add more sites to users page
  Support new Rails 2.1.1 method of setting relative_url_root as well as older Rails via a respond_to? check
  Rails now uses ActionController::Base.relative_url_root to set relative_url_root.
  • Loading branch information
raggi committed Nov 19, 2008
2 parents 6a66889 + 1e90d63 commit 20a46fb
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,4 +1,6 @@
== 1.0.1 ? release
* Set RACK_ENV based on environment option when loading rackup file [Curtis Summers] [#83 state:resolved]
* Fixes a warning RE relative_url_root when using a prefix with Rails 2.1.1 [seriph] [#85 state:resolved]
* --only can work as a sequence number (if < 80) or a port number (if >= 80) [jmay] [#81 state:resolved]

== 1.0.0 That's What She Said release
Expand Down
8 changes: 7 additions & 1 deletion lib/rack/adapter/rails.rb
Expand Up @@ -31,7 +31,13 @@ def load_application
require "#{@root}/config/environment"
require 'dispatcher'

ActionController::AbstractRequest.relative_url_root = @prefix if @prefix
if @prefix
if ActionController::Base.respond_to?('relative_url_root=')
ActionController::Base.relative_url_root = @prefix # Rails 2.1.1
else
ActionController::AbstractRequest.relative_url_root = @prefix
end
end
end

# TODO refactor this in File#can_serve?(path) ??
Expand Down
1 change: 1 addition & 0 deletions lib/thin/controllers/controller.rb
Expand Up @@ -166,6 +166,7 @@ def load_adapter
end

def load_rackup_config
ENV['RACK_ENV'] = @options[:environment]
case @options[:rackup]
when /\.rb$/
Kernel.load(@options[:rackup])
Expand Down
12 changes: 10 additions & 2 deletions site/thin.rb
Expand Up @@ -188,19 +188,20 @@ def users_page

ul do
li { a 'RefactorMyCode.com', :href => 'http://refactormycode.com/' }
li { a "Joao Pedrosa's Blog", :href => 'http://www.deze9.com/jp/blog/post?p=enabling-thin-support-for-this-site-replacing' }
li { a "Standout Jobs", :href => 'http://standoutjobs.com/'}
li { a "Kevin Williams Blog", :href => 'http://www.almostserio.us/articles/tag/thin' }
li { a "Gitorious", :href => 'http://gitorious.org/' }
li { a "Dinooz", :href => 'http://www.nicomoayudarte.com/' }
li { a "Mobile Dyne Systems", :href => 'http://www.mobiledyne.com/' }
li { a "feelfree.homelinux.com", :href => 'http://feelfree.homelinux.com' }
li { a "to2posts.com", :href => 'http://to2blogs.com/' }
li { a "James on Software", :href => 'http://jamesgolick.com/' }
li { a "FlashDen", :href => 'http://flashden.net/' }
li { a "Calico Web Development", :href => 'http://www.calicowebdev.com/' }
li { a "Gitorious", :href => 'http://gitorious.org/' }
li { a "Cornerstone Web", :href => 'http://www.cornerstoneweb.org/' }
li { a "Osmos", :href => 'http://www.getosmos.com/' }
li { a "Lipomics", :href => 'http://www.lipomics.com/' }
li { a "Joao Pedrosa's Blog", :href => 'http://www.deze9.com/jp/blog/post?p=enabling-thin-support-for-this-site-replacing' }
li { a "RaPlanet", :href => 'http://planet.zhekov.net/' }
li { a "Ninja Hideout blog", :href => 'http://blog.ninjahideout.com/' }
li { a "Hoodows Blog", :href => 'http://blog.hoodow.de/articles/2008/02/09/thin' }
Expand All @@ -226,6 +227,13 @@ def users_page
li { a "Hacknight", :href => 'http://hacknight.gangplankhq.com/'}
li { a "Sizzix", :href => 'http://www.sizzix.com/'}
li { a "Ellison Retailers", :href => 'http://www.ellisonretailers.com/'}
li { a "ShareMeme", :href => 'http://sharememe.com/'}
li { a "ylastic", :href => 'http://ylastic.com/'}
li { a "hello2morrow", :href => 'http://www.hello2morrow.com/'}
li { a "TimmyOnTime", :href => 'http://www.timmyontime.com/'}
li { a "Generous", :href => 'http://generous.org.uk/'}
li { a "Catapult Magazine", :href => 'http://www.catapultmagazine.com/'}
li { a "Good-Tutorials", :href => 'http://www.good-tutorials.com/'}
end

p { "If you'd like to have your site listed here, #{a 'drop me an email', :href => 'mailto:macournoyer@gmail.com'}" }
Expand Down
14 changes: 11 additions & 3 deletions spec/controllers/controller_spec.rb
Expand Up @@ -63,22 +63,22 @@
end

it "should load app from Rack config" do
@controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
@controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
@controller.start

@server.app.class.should == Proc
end

it "should load app from ruby file" do
@controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.rb'
@controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.rb'
@controller.start

@server.app.should == Myapp
end

it "should throwup if rackup is not a .ru or .rb file" do
proc do
@controller.options[:rackup] = filename = File.dirname(__FILE__) + '/../../example/myapp.foo'
@controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.foo'
@controller.start
end.should raise_error(RuntimeError, /please/)
end
Expand All @@ -89,6 +89,14 @@

@server.threaded.should be_true
end

it "should set RACK_ENV" do
@controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru'
@controller.options[:environment] = "lolcat"
@controller.start

ENV['RACK_ENV'].should == "lolcat"
end

end

Expand Down

0 comments on commit 20a46fb

Please sign in to comment.