From d8fd2308a640b4762ec1e6abe595eac40d9253b2 Mon Sep 17 00:00:00 2001 From: Vladislav Gangan Date: Mon, 10 Mar 2014 12:12:41 +1100 Subject: [PATCH] Adapted the API calss to match the most recent listen gem version --- emory.gemspec | 4 ++-- lib/emory/runner.rb | 7 +++---- spec/emory/runner_spec.rb | 10 ++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/emory.gemspec b/emory.gemspec index 1065f1e..bb4386a 100644 --- a/emory.gemspec +++ b/emory.gemspec @@ -21,6 +21,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'simplecov', '~> 0.6.4' if RUBY_VERSION =~ /1.9/ s.add_development_dependency 'rake' - s.add_runtime_dependency 'logging' - s.add_runtime_dependency 'listen' + s.add_runtime_dependency 'logging', '1.8.2' + s.add_runtime_dependency 'listen', '2.7.0' end diff --git a/lib/emory/runner.rb b/lib/emory/runner.rb index 0bd2987..ce691db 100644 --- a/lib/emory/runner.rb +++ b/lib/emory/runner.rb @@ -42,11 +42,10 @@ def configure_listeners(config, config_location) watched_path = normalize_watched_path(config_location, teleport.watched_path) LOGGER.info("Watching directory: #{watched_path}") - listener = Listen.to(watched_path) + listener = Listen.to(watched_path, &get_handler_callback(teleport.handler)) listener.ignore(teleport.ignore) unless teleport.ignore.nil? - listener.filter(teleport.filter) unless teleport.filter.nil? - listener.change(&get_handler_callback(teleport.handler)) - listener.start(false) + listener.only(teleport.filter) unless teleport.filter.nil? + listener.start end end diff --git a/spec/emory/runner_spec.rb b/spec/emory/runner_spec.rb index ebfc4c4..769a32d 100644 --- a/spec/emory/runner_spec.rb +++ b/spec/emory/runner_spec.rb @@ -29,9 +29,8 @@ module Emory mock_listener = double("listener") Listen.stub(:to).with('watched_path').and_return(mock_listener) mock_listener.should_receive(:ignore).with(teleport.ignore) - mock_listener.should_receive(:filter).with(teleport.filter) - mock_listener.should_receive(:change) - mock_listener.should_receive(:start).with(false) + mock_listener.should_receive(:only).with(teleport.filter) + mock_listener.should_receive(:start) Thread.should_receive(:stop).once @@ -58,9 +57,8 @@ module Emory mock_listener = double("listener") Listen.stub(:to).with('/path/to/config/watched_path').and_return(mock_listener) mock_listener.should_receive(:ignore).with(teleport.ignore) - mock_listener.should_receive(:filter).with(teleport.filter) - mock_listener.should_receive(:change) - mock_listener.should_receive(:start).with(false) + mock_listener.should_receive(:only).with(teleport.filter) + mock_listener.should_receive(:start) Thread.should_receive(:stop).once