Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port patches #65

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/serve/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def extract_environment(args)
end

def extract_port(args)
(args.delete(args.find {|a| /^\d\d\d*$/.match(a) }) || ((rails_app? or rack_app?) ? 3000 : 4000)).to_i
(args.delete(args.find {|a| /^\d\d\d*$/.match(a) }) || ENV['PORT'] || 4000).to_i
end

def extract_address(args)
Expand Down Expand Up @@ -234,15 +234,15 @@ def extract_export(args)
}
end
end

def rails_script_server
@rails_server_script ||= options[:root] + '/script/server'
end

def rails_app?
File.file?(rails_script_server) and File.executable?(rails_script_server)
end

def run_rails_app
system "#{rails_script_server} -p #{options[:port]} -b #{options[:address]} -e #{options[:environment]}"
end
Expand Down
4 changes: 1 addition & 3 deletions lib/serve/bootstrap/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#\ -p 4000

require 'rubygems'
require 'bundler'
begin
Expand Down Expand Up @@ -44,4 +42,4 @@ else
Serve::RackAdapter.new(root + '/views'),
Rack::Directory.new(root + '/public')
])
end
end
7 changes: 6 additions & 1 deletion spec/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
parse('http://1.1.1.1:2000').should == @options.update(:address => "1.1.1.1", :port=>2000)
end

it "with port set in ENV" do
ENV["PORT"] = "4321"
parse[:port].should == 4321
end

it "help" do
parse('')[:help].should be_false
parse('-h')[:help].should be_true
Expand Down Expand Up @@ -150,4 +155,4 @@ def parse(*args)

end

end
end
2 changes: 0 additions & 2 deletions website/config.ru
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#\ -p 4000

require 'rubygems'
require 'bundler'
begin
Expand Down