Module: StartingBlocks::Watcher
- Defined in:
- lib/starting_blocks/watcher.rb
Constant Summary collapse
- TEST_FILE_CLUES =
["_test", "test_", "_spec"]
Class Method Summary collapse
- .add_it(file_that_changed) ⇒ Object
- .delete_it(file_that_changed) ⇒ Object
- .run_it(file_that_changed) ⇒ Object
- .start_watching(dir, options) ⇒ Object
Class Method Details
.add_it(file_that_changed) ⇒ Object
31 32 33 34 35 |
# File 'lib/starting_blocks/watcher.rb', line 31 def add_it(file_that_changed) return if not_concerned_about? file_that_changed StartingBlocks.display "Adding: #{file_that_changed}" @all_files << file_that_changed end |
.delete_it(file_that_changed) ⇒ Object
46 47 48 49 50 |
# File 'lib/starting_blocks/watcher.rb', line 46 def delete_it(file_that_changed) return if not_concerned_about? file_that_changed StartingBlocks.display "Deleting: #{file_that_changed}" @all_files.delete(file_that_changed) end |
.run_it(file_that_changed) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/starting_blocks/watcher.rb', line 37 def run_it(file_that_changed) @running = true specs = get_the_specs_to_run file_that_changed StartingBlocks.display "Matches: #{specs.inspect}" results = @runner.run_files specs store_the_specs_if_they_failed results, specs @running = false end |
.start_watching(dir, options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/starting_blocks/watcher.rb', line 11 def start_watching(dir, ) StartingBlocks.display("Start watching #{dir.getwd} with #{options.inspect}") set_up_the_runner location = dir.getwd @all_files = Dir['**/*'] puts "Listening to: #{location}" callback = Proc.new do |modified, added, removed| StartingBlocks.display("File counts: #{[modified.count, added.count, removed.count].inspect}") StartingBlocks::Watcher.add_it(added[0]) if added.count > 0 StartingBlocks::Watcher.delete_it(removed[0]) if removed.count > 0 next if @running StartingBlocks::Watcher.run_it(modified[0]) if modified.count > 0 end ::Listen::Listener.new location, &callback end |