bin/sb in starting_blocks-0.0.7 vs bin/sb in starting_blocks-0.0.8

- old
+ new

@@ -1,64 +1,26 @@ #!/usr/bin/env ruby -require 'fssm' +require File.expand_path(File.dirname(__FILE__) + '/../lib/starting_blocks.rb') +options = {} + def display value end if ARGV.include? '--verbose' - def display value - puts value - end + options[:verbose] = true end -def run_all_specs - specs = Dir['**/*_spec.rb*'].select { |f| File.file?(f) }.map do |x| - File.expand_path(x) - end +def run_all_specs options + specs = Dir['**/*_spec.rb*']. + select { |f| File.file?(f) }. + map { |x| File.expand_path(x) } - run_these_specs specs + StartingBlocks::Runner.new(options).run_files specs end -def run_these_specs specs - requires = specs.map { |x| "require '#{x}'" }.join("\n") - display "Specs to run: #{specs.inspect}" - puts `ruby -e "#{requires}"` -end - - -def add_it(file, files) - return if file.index('.git') == 0 - display "Adding: #{file}" - files << file -end - -def run_it(file, files) - filename = file.downcase.split('/')[-1].gsub('_spec', '') - display "File to run is: #{file}" - display "Filename: #{filename}" - matches = files.select { |x| x.gsub('_spec.rb', '.rb').include?(filename) && x != file } - matches << file - specs = matches.select { |x| x.include?('_spec') && File.file?(x) }.map { |x| File.expand_path x } - display "Matches: #{specs.inspect}" - run_these_specs specs -end - -def delete_it(file, files) - return if file.index('.git') == 0 - display "Deleting: #{file}" - files.delete(file) -end - if ARGV.include? '--watch' - files = Dir['**/*'] - segments = File.expand_path(Dir['*'].first).split('/') - segments.pop - location = segments.join('/') - FSSM.monitor(location, '**/*') do - update {|base, relative| run_it relative, files } - delete {|base, relative| delete_it relative, files } - create {|base, relative| add_it relative, files } - end + StartingBlocks::Watcher.start_watching Dir, options else - run_all_specs + run_all_specs options end