using -b over -h option from cli for bind address

I've also renamed all occurrences of options.host
to options.bind
This commit is contained in:
Blake Mizerany 2010-02-04 17:16:05 -08:00
parent 3cfd06ad86
commit 849a5a95fc
4 changed files with 8 additions and 8 deletions

View File

@ -833,7 +833,7 @@ module Sinatra
private
def route(verb, path, options={}, &block)
# Because of self.options.host
host_name(options.delete(:host)) if options.key?(:host)
host_name(options.delete(:bind)) if options.key?(:host)
options.each {|option, args| send(option, *args)}
@ -927,7 +927,7 @@ module Sinatra
handler_name = handler.name.gsub(/.*::/, '')
puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " +
"on #{port} for #{environment} with backup from #{handler_name}" unless handler_name =~/cgi/i
handler.run self, :Host => host, :Port => port do |server|
handler.run self, :Host => bind, :Port => port do |server|
trap(:INT) do
## Use thins' hard #stop! if available, otherwise just #stop
server.respond_to?(:stop!) ? server.stop! : server.stop
@ -1040,7 +1040,7 @@ module Sinatra
set :run, false # start server via at-exit hook?
set :running, false # is the built-in server running now?
set :server, %w[thin mongrel webrick]
set :host, '0.0.0.0'
set :bind, '0.0.0.0'
set :port, 4567
set :app_file, nil

View File

@ -17,7 +17,7 @@ module Sinatra
op.on('-e env') { |val| set :environment, val.to_sym }
op.on('-s server') { |val| set :server, val }
op.on('-p port') { |val| set :port, val.to_i }
op.on('-h addr') { |val| set :host, val }
op.on('-b addr') { |val| set :bind, val }
}.parse!(ARGV.dup)
end
end

View File

@ -22,7 +22,7 @@ class ServerTest < Test::Unit::TestCase
setup do
mock_app {
set :server, 'mock'
set :host, 'foo.local'
set :bind, 'foo.local'
set :port, 9001
}
$stdout = File.open('/dev/null', 'wb')

View File

@ -306,10 +306,10 @@ class SettingsTest < Test::Unit::TestCase
end
end
describe 'host' do
describe 'bind' do
it 'defaults to 0.0.0.0' do
assert_equal '0.0.0.0', @base.host
assert_equal '0.0.0.0', @application.host
assert_equal '0.0.0.0', @base.bind
assert_equal '0.0.0.0', @application.bind
end
end