Skip to content

Commit

Permalink
get rid of launchy and its dependencies; depend only on rack
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomayko committed Jan 26, 2010
1 parent 182c887 commit 4a82737
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 15 additions & 4 deletions bin/shotgun
Expand Up @@ -130,14 +130,25 @@ app_wrapper =

ENV['RACK_ENV'] = env

# use the BROWSER environment variable or fall back to a more or less standard
# set of commands
ENV['BROWSER'] ||=
%w[open xdg-open x-www-browser firefox opera mozilla netscape].find do |comm|
next if comm == 'open' && `uname` =~ 'Darwin'
ENV['PATH'].split(':').any? { |dir| File.executable?("#{dir}/#{comm}") }
end

require 'shotgun'
app = Shotgun.new(config, app_wrapper)

base_url = "http://#{options[:Host]}:#{options[:Port]}"
puts "== Shotgun starting #{server.to_s} at #{base_url}"
server.run app, options do |inst|
puts "== Shotgun starting #{server.to_s} on http://#{options[:Host]}:#{options[:Port]}"

if browse
require 'launchy'
Launchy.open("http://#{options[:Host]}:#{options[:Port]}#{options[:Path]}")
if ENV['BROWSER']
system "#{ENV['BROWSER']} '#{base_url}#{options[:Path]}'"
else
abort "BROWSER environment variable not set and no browser detected"
end
end
end
1 change: 0 additions & 1 deletion shotgun.gemspec
Expand Up @@ -27,7 +27,6 @@ Gem::Specification.new do |s|

s.extra_rdoc_files = %w[README]
s.add_dependency 'rack', '>= 0.9.1'
s.add_dependency 'launchy', '>= 0.3.3', '< 1.0'

s.homepage = "http://github.com/rtomayko/shotgun/"
s.require_paths = %w[lib]
Expand Down

0 comments on commit 4a82737

Please sign in to comment.