Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1cdde868c5
Fetching contributors…

Cannot retrieve contributors at this time

file 53 lines (48 sloc) 1.081 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
require 'spec/rake/spectask'
require 'yaml'

begin
 require "launchy"
rescue
  module Launchy
    class << self
      def open(url)
        system "open #{url}"
      end
    end
  end
end

task :default => :test
task :test => :spec

if !defined?(Spec)
  puts "rspec is required! - rake gems:install"
else
 desc "do the test first"
 Spec::Rake::SpecTask.new('spec') do |t|
  t.spec_files = FileList['spec/**/*.rb']
  t.spec_opts = ['-cfs']
 end
end

namespace :gems do
  desc "install gems"
  task :install do
    %w{ sinatra rspec rack-test launchy }.each {|gem| system "sudo gem install #{gem}" }
  end
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
    system "ruby app.rb"
  end
end
Something went wrong with that request. Please try again.