#!/usr/bin/env ruby #require File.expand_path(File.dirname(__FILE__) + '/../lib/starting_blocks.rb') require 'starting_blocks' options = {} arguments = ARGV config_file = File.expand_path('~/.sb') if File.exists?(config_file) additional_arguments = File.read(config_file).split(' ') arguments += additional_arguments end require 'starting_blocks-blinky' if arguments.include? '--blinky' require 'starting_blocks-growl' if arguments.include? '--growl' require 'starting_blocks-stopplicht' if arguments.include? '--stopplicht' StartingBlocks.verbose = arguments.include? '--verbose' options[:no_vendor] = arguments.include?('--vendor') == false options[:use_bundler] = Dir['Gemfile'].count > 0 def run_all_specs options files = ['**/*_spec.rb*', '**/*_test.rb*', '**/test_*.rb*'].map do |d| Dir[d]. select { |f| File.file?(f) }. map { |x| File.expand_path(x) } end.flatten StartingBlocks::Runner.new(options).run_files files end if arguments.include? '--watch' listener = StartingBlocks::Watcher.start_watching Dir, options StartingBlocks.display "Going to sleep, waiting for changes" puts 'Enter "stop" to stop the listener' puts 'Enter a blank line to run all of the tests' listener.start loop do user_input = STDIN.gets if user_input == "stop\n" exit elsif user_input == "\n" run_all_specs options end end elsif arguments.include? '--off' StartingBlocks::Extensions::BlinkyLighting.turn_off! else results = run_all_specs options parsed_results = StartingBlocks::Publisher.result_parser.parse(results) success = parsed_results[:color] == :green exit success end