Permalink
Browse files

Launchy and alternative in Rakefile

  • Loading branch information...
1 parent efd25f0 commit 0181ef8ce59300770dd5bb8d8593a434062df4fb bry4n committed Nov 14, 2009
Showing with 18 additions and 2 deletions.
  1. +7 −2 README.md
  2. +11 −0 Rakefile
View
@@ -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/
---
View
@@ -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
@@ -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

0 comments on commit 0181ef8

Please sign in to comment.