Skip to content

Commit

Permalink
Launchy and alternative in Rakefile
Browse files Browse the repository at this point in the history
  • Loading branch information
bry4n committed Nov 14, 2009
1 parent efd25f0 commit 0181ef8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ Want an agile MVC structured app in Sinatra?

1) `cd firstapp`

2) `ruby app.rb`
2) rake gems:install

3) go to http://localhost:8080/
3) rake app:launch # Start app and Launch browser

or

3) rake app:run # Start app without browser
4) go to http://localhost:8080/

---

Expand Down
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ require 'yaml'
begin
require "launchy"
rescue
module Launchy
class << self
def open(url)
system "open #{url}"
end
end
end
end

task :default => :test
Expand All @@ -29,11 +36,15 @@ end
namespace :app do
desc "Start app and launch browser"
task :launch do
if defined?("Launchy")
config = YAML.load_file("configs/config.yml")
app = Thread.new { system "ruby app.rb" }
web = Thread.new { sleep(1); Launchy.open("http://#{config["host"]}:#{config["port"]}/") }
app.join
web.join
else
puts "please install launchy or run rake gems:install"
end
end
desc "Start app"
task :run do
Expand Down

0 comments on commit 0181ef8

Please sign in to comment.