Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Hello! I've added autoflushing on filesystem changes! #13

Closed
wants to merge 4 commits into from

4 participants

@vintikzzz

I made it via embedding rb-fsevent
I updated specs and docs
It works fine on my mac...

@iangreenleaf

I like this idea a lot. I frequently get hung up by forgetting to flush. I think this would be especially cool if it was cross-platform - maybe https://github.com/guard/guard would work?

@iangreenleaf iangreenleaf commented on the diff
@@ -0,0 +1 @@
+rvm use ruby-1.8.7-p334@commandt

Guessing you didn't mean to include this in the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@gmile

+1 on this one

@wincent
Owner

Sorry for not chiming in on this one earlier. I think it's a great initiative, but the reason I haven't merged it is because of the cross-platform issue. I'm also wary of anything that is not single-threaded, as Vim itself is a single-threaded application and I worry about the stability of changing that model from inside a plug-in.

@wincent
Owner

Going to close this for the reasons in my last comment.

#15 is slightly more promising as it is somewhat cross-platform, although the stability issues mean I'll probably close that too.

@wincent wincent closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 21, 2011
  1. @vintikzzz

    added fsevent

    vintikzzz authored
Commits on Jun 23, 2011
  1. @vintikzzz

    rb-fsevent embedded

    vintikzzz authored
  2. @vintikzzz
  3. @vintikzzz

    doc updated

    vintikzzz authored
This page is out of date. Refresh to see the latest.
View
1  .bundle/config
@@ -1,3 +1,2 @@
---
BUNDLE_BIN: bin
-BUNDLE_DISABLE_SHARED_GEMS: "1"
View
1  .gitignore
@@ -1,2 +1,3 @@
.release-notes.txt
command-t.recipe
+.DS_Store
View
1  .rvmrc
@@ -0,0 +1 @@
+rvm use ruby-1.8.7-p334@commandt

Guessing you didn't mean to include this in the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
1  Gemfile
@@ -3,3 +3,4 @@ gem 'mechanize'
gem 'rake'
gem 'rr'
gem 'rspec', '>= 2.0.0.rc'
+gem 'rb-fsevent'
View
2  Gemfile.lock
@@ -6,6 +6,7 @@ GEM
nokogiri (>= 1.2.1)
nokogiri (1.4.4)
rake (0.8.7)
+ rb-fsevent (0.4.0)
rr (1.0.2)
rspec (2.5.0)
rspec-core (~> 2.5.0)
@@ -22,5 +23,6 @@ PLATFORMS
DEPENDENCIES
mechanize
rake
+ rb-fsevent
rr
rspec (>= 2.0.0.rc)
View
1  command-t
View
2  doc/command-t.txt
@@ -146,6 +146,8 @@ you can build the extension with:
cd ~/.vim/ruby/command-t
ruby extconf.rb
make
+ cd ../rb-fsevent/ext
+ ruby extconf.rb
Note: If you are an RVM user, you must perform the build using the same
version of Ruby that Vim itself is linked against. This will often be the
View
4 plugin/command-t.vim
@@ -145,7 +145,7 @@ ruby << EOF
require 'command-t/vim'
require 'command-t/controller'
$command_t = CommandT::Controller.new
- rescue LoadError
+ rescue LoadError => e
load_path_modified = false
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
lib = "#{path}/ruby"
@@ -159,6 +159,6 @@ ruby << EOF
# could get here if C extension was not compiled, or was compiled
# for the wrong architecture or Ruby version
require 'command-t/stub'
- $command_t = CommandT::Stub.new
+ $command_t = CommandT::Stub.new(e)
end
EOF
View
6 ruby/command-t/finder/file_finder.rb
@@ -24,12 +24,18 @@
require 'command-t/ext' # CommandT::Matcher
require 'command-t/finder'
require 'command-t/scanner/file_scanner'
+require 'rb-fsevent/lib/rb-fsevent'
module CommandT
class FileFinder < Finder
def initialize path = Dir.pwd, options = {}
@scanner = FileScanner.new path, options
@matcher = Matcher.new @scanner, options
+ fsevent = FSEvent.new
+ fsevent.watch Dir.pwd, { :latency => 1 } do |directories|
+ flush
+ end
+ Thread.new { fsevent.run }
end
end # class FileFinder
end # CommandT
View
10 ruby/command-t/stub.rb
@@ -28,11 +28,17 @@ class Stub
'For more information type: :help command-t']
def show_file_finder
- warn *@@load_error
+ warn *error_message
end
def flush
- warn *@@load_error
+ warn *error_message
+ end
+ def initialize(e)
+ @e = e
+ end
+ def error_message
+ [@e.message] + @e.backtrace
end
private
View
20 ruby/rb-fsevent/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2011 Thibaud Guillaume-Gentil
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
BIN  ruby/rb-fsevent/bin/fsevent_watch
Binary file not shown
View
128 ruby/rb-fsevent/ext/Makefile
@@ -0,0 +1,128 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0
+hdrdir = $(topdir)
+VPATH = $(srcdir):$(topdir):$(hdrdir)
+exec_prefix = $(prefix)
+prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
+sharedstatedir = $(prefix)/com
+mandir = $(DESTDIR)/usr/share/man
+psdir = $(docdir)
+oldincludedir = $(DESTDIR)/usr/include
+localedir = $(datarootdir)/locale
+bindir = $(exec_prefix)/bin
+libexecdir = $(exec_prefix)/libexec
+sitedir = $(DESTDIR)/Library/Ruby/Site
+htmldir = $(docdir)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+includedir = $(prefix)/include
+infodir = $(DESTDIR)/usr/share/info
+vendorlibdir = $(vendordir)/$(ruby_version)
+sysconfdir = $(prefix)/etc
+libdir = $(exec_prefix)/lib
+sbindir = $(exec_prefix)/sbin
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+docdir = $(datarootdir)/doc/$(PACKAGE)
+dvidir = $(docdir)
+vendordir = $(libdir)/ruby/vendor_ruby
+datarootdir = $(prefix)/share
+pdfdir = $(docdir)
+archdir = $(rubylibdir)/$(arch)
+sitearchdir = $(sitelibdir)/$(sitearch)
+datadir = $(datarootdir)
+localstatedir = $(prefix)/var
+sitelibdir = $(sitedir)/$(ruby_version)
+
+CC = gcc
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
+
+RUBY_EXTCONF_H =
+CFLAGS = -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common $(cflags)
+INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE $(DEFS) $(cppflags)
+CXXFLAGS = $(CFLAGS)
+ldflags = -L. -arch i386 -arch x86_64
+dldflags =
+archflag =
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = ruby
+RUBY_SO_NAME = ruby
+arch = universal-darwin10.0
+sitearch = universal-darwin10.0
+ruby_version = 1.8
+ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
+RUBY = $(ruby)
+RM = rm -f
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(libdir)
+LIBPATH = -L. -L$(libdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+extout =
+extout_prefix =
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl
+SRCS =
+OBJS =
+TARGET =
+DLLIB =
+EXTSTATIC =
+STATIC_LIB =
+
+BINDIR = $(bindir)
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = $(sitelibdir)$(target_prefix)
+RUBYARCHDIR = $(sitearchdir)$(target_prefix)
+
+TARGET_SO = $(DLLIB)
+CLEANLIBS = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
+CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
+
+all: Makefile
+static: $(STATIC_LIB)
+
+clean:
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean: clean
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: Makefile
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
View
50 ruby/rb-fsevent/ext/extconf.rb
@@ -0,0 +1,50 @@
+# Workaround to make Rubygems believe it builds a native gem
+require 'mkmf'
+create_makefile('none')
+
+if `uname -s`.chomp != 'Darwin'
+ puts "Warning! Only Darwin (Mac OS X) systems are supported, nothing will be compiled"
+else
+ gem_root = File.expand_path(File.join('..'))
+ darwin_version = `uname -r`.to_i
+ sdk_version = { 9 => '10.5', 10 => '10.6', 11 => '10.7' }[darwin_version]
+
+ raise "Only Darwin systems greater than 8 (Mac OS X 10.5+) are supported" unless sdk_version
+
+ core_flags = %W{
+ -isysroot /Developer/SDKs/MacOSX#{sdk_version}.sdk
+ -mmacosx-version-min=#{sdk_version} -mdynamic-no-pic -std=gnu99
+ }
+
+ cflags = core_flags + %w{-Os -pipe}
+
+ wflags = %w{
+ -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch
+ -Wunused-function -Wunused-label -Wunused-parameter -Wunused-variable
+ -Wunused-value -Wuninitialized -Wunknown-pragmas -Wshadow
+ -Wfour-char-constants -Wsign-compare -Wnewline-eof -Wconversion
+ -Wshorten-64-to-32 -Wglobal-constructors -pedantic
+ }
+
+ ldflags = %w{
+ -dead_strip -framework CoreServices
+ }
+
+ gcc_opts = core_flags + ldflags
+
+ gcc_opts += %w{
+ -D DEBUG=true
+ } if ENV['FWDEBUG'] == "true"
+
+ compile_command = "CFLAGS='#{cflags.join(' ')} #{wflags.join(' ')}' /usr/bin/gcc #{gcc_opts.join(' ')} -o '#{gem_root}/bin/fsevent_watch' fsevent/fsevent_watch.c"
+
+ STDERR.puts(compile_command)
+
+ # Compile the actual fsevent_watch binary
+ system "mkdir -p #{File.join(gem_root, 'bin')}"
+ system compile_command
+
+ unless File.executable?("#{gem_root}/bin/fsevent_watch")
+ raise "Compilation of fsevent_watch failed (see README)"
+ end
+end
View
197 ruby/rb-fsevent/ext/fsevent/fsevent_watch.c
@@ -0,0 +1,197 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <CoreServices/CoreServices.h>
+
+
+// Structure for storing metadata parsed from the commandline
+static struct {
+ FSEventStreamEventId sinceWhen;
+ CFTimeInterval latency;
+ FSEventStreamCreateFlags flags;
+ CFMutableArrayRef paths;
+} config = {
+ (UInt64) kFSEventStreamEventIdSinceNow,
+ (double) 0.3,
+ (UInt32) kFSEventStreamCreateFlagNone,
+ NULL
+};
+
+// Prototypes
+static void append_path(const char *path);
+static inline void parse_cli_settings(int argc, const char *argv[]);
+static void callback(FSEventStreamRef streamRef,
+ void *clientCallBackInfo,
+ size_t numEvents,
+ void *eventPaths,
+ const FSEventStreamEventFlags eventFlags[],
+ const FSEventStreamEventId eventIds[]);
+
+
+// Resolve a path and append it to the CLI settings structure
+// The FSEvents API will, internally, resolve paths using a similar scheme.
+// Performing this ahead of time makes things less confusing, IMHO.
+static void append_path(const char *path)
+{
+#ifdef DEBUG
+ fprintf(stderr, "\n");
+ fprintf(stderr, "append_path called for: %s\n", path);
+#endif
+
+ char fullPath[PATH_MAX];
+
+ if (realpath(path, fullPath) == NULL) {
+#ifdef DEBUG
+ fprintf(stderr, " realpath not directly resolvable from path\n");
+#endif
+
+ if (path[0] != '/') {
+#ifdef DEBUG
+ fprintf(stderr, " passed path is not absolute\n");
+#endif
+ size_t len;
+ getcwd(fullPath, sizeof(fullPath));
+#ifdef DEBUG
+ fprintf(stderr, " result of getcwd: %s\n", fullPath);
+#endif
+ len = strlen(fullPath);
+ fullPath[len] = '/';
+ strlcpy(&fullPath[len + 1], path, sizeof(fullPath) - (len + 1));
+ } else {
+#ifdef DEBUG
+ fprintf(stderr, " assuming path does not YET exist\n");
+#endif
+ strlcpy(fullPath, path, sizeof(fullPath));
+ }
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, " resolved path to: %s\n", fullPath);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+#endif
+
+ CFStringRef pathRef = CFStringCreateWithCString(kCFAllocatorDefault,
+ fullPath,
+ kCFStringEncodingUTF8);
+ CFArrayAppendValue(config.paths, pathRef);
+ CFRelease(pathRef);
+}
+
+// Parse commandline settings
+static inline void parse_cli_settings(int argc, const char *argv[])
+{
+ config.paths = CFArrayCreateMutable(NULL,
+ (CFIndex)0,
+ &kCFTypeArrayCallBacks);
+
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--since-when") == 0) {
+ config.sinceWhen = strtoull(argv[++i], NULL, 0);
+ } else if (strcmp(argv[i], "--latency") == 0) {
+ config.latency = strtod(argv[++i], NULL);
+ } else if (strcmp(argv[i], "--no-defer") == 0) {
+ config.flags |= kFSEventStreamCreateFlagNoDefer;
+ } else if (strcmp(argv[i], "--watch-root") == 0) {
+ config.flags |= kFSEventStreamCreateFlagWatchRoot;
+ } else if (strcmp(argv[i], "--ignore-self") == 0) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+ config.flags |= kFSEventStreamCreateFlagIgnoreSelf;
+#else
+ fprintf(stderr, "MacOSX10.6.sdk is required for --ignore-self\n");
+#endif
+ } else {
+ append_path(argv[i]);
+ }
+ }
+
+ if (CFArrayGetCount(config.paths) == 0) {
+ append_path(".");
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "config.sinceWhen %llu\n", config.sinceWhen);
+ fprintf(stderr, "config.latency %f\n", config.latency);
+ fprintf(stderr, "config.flags %#.8x\n", config.flags);
+ fprintf(stderr, "config.paths\n");
+
+ long numpaths = CFArrayGetCount(config.paths);
+
+ for (long i = 0; i < numpaths; i++) {
+ char path[PATH_MAX];
+ CFStringGetCString(CFArrayGetValueAtIndex(config.paths, i),
+ path,
+ PATH_MAX,
+ kCFStringEncodingUTF8);
+ fprintf(stderr, " %s\n", path);
+ }
+
+ fprintf(stderr, "\n");
+ fflush(stderr);
+#endif
+}
+
+static void callback(FSEventStreamRef streamRef,
+ void *clientCallBackInfo,
+ size_t numEvents,
+ void *eventPaths,
+ const FSEventStreamEventFlags eventFlags[],
+ const FSEventStreamEventId eventIds[])
+{
+ char **paths = eventPaths;
+
+#ifdef DEBUG
+ fprintf(stderr, "\n");
+ fprintf(stderr, "FSEventStreamCallback fired!\n");
+ fprintf(stderr, " numEvents: %lu\n", numEvents);
+
+ for (size_t i = 0; i < numEvents; i++) {
+ fprintf(stderr, " event path: %s\n", paths[i]);
+ fprintf(stderr, " event flags: %#.8x\n", eventFlags[i]);
+ fprintf(stderr, " event ID: %llu\n", eventIds[i]);
+ }
+
+ fprintf(stderr, "\n");
+ fflush(stderr);
+#endif
+
+ for (size_t i = 0; i < numEvents; i++) {
+ fprintf(stdout, "%s", paths[i]);
+ fprintf(stdout, ":");
+ }
+
+ fprintf(stdout, "\n");
+ fflush(stdout);
+}
+
+int main(int argc, const char *argv[])
+{
+ parse_cli_settings(argc, argv);
+
+ FSEventStreamContext context = {0, NULL, NULL, NULL, NULL};
+ FSEventStreamRef stream;
+ stream = FSEventStreamCreate(kCFAllocatorDefault,
+ (FSEventStreamCallback)&callback,
+ &context,
+ config.paths,
+ config.sinceWhen,
+ config.latency,
+ config.flags);
+
+#ifdef DEBUG
+ FSEventStreamShow(stream);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+#endif
+
+ FSEventStreamScheduleWithRunLoop(stream,
+ CFRunLoopGetCurrent(),
+ kCFRunLoopDefaultMode);
+ FSEventStreamStart(stream);
+ CFRunLoopRun();
+ FSEventStreamFlushSync(stream);
+ FSEventStreamStop(stream);
+
+ return 0;
+}
View
2  ruby/rb-fsevent/lib/rb-fsevent.rb
@@ -0,0 +1,2 @@
+require 'rb-fsevent/lib/rb-fsevent/fsevent'
+require 'rb-fsevent/lib/rb-fsevent/version'
View
102 ruby/rb-fsevent/lib/rb-fsevent/fsevent.rb
@@ -0,0 +1,102 @@
+class FSEvent
+ class << self
+ class_eval <<-END
+ def root_path
+ "#{File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))}"
+ end
+ END
+ class_eval <<-END
+ def watcher_path
+ "#{File.join(FSEvent.root_path, 'bin', 'fsevent_watch')}"
+ end
+ END
+ end
+
+ attr_reader :paths, :callback
+
+ def watch(watch_paths, options=nil, &block)
+ @paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths]
+ @callback = block
+
+ if options.kind_of?(Hash)
+ @options = parse_options(options)
+ elsif options.kind_of?(Array)
+ @options = options
+ else
+ @options = []
+ end
+ end
+
+ def run
+ while !pipe.eof?
+ if line = pipe.readline
+ modified_dir_paths = line.split(":").select { |dir| dir != "\n" }
+ callback.call(modified_dir_paths)
+ end
+ end
+ rescue Interrupt, IOError
+ ensure
+ stop
+ end
+
+ def stop
+ if pipe
+ Process.kill("KILL", pipe.pid)
+ pipe.close
+ end
+ rescue IOError
+ ensure
+ @pipe = false
+ end
+
+ if RUBY_VERSION < '1.9'
+ def pipe
+ @pipe ||= IO.popen("#{self.class.watcher_path} #{options_string} #{shellescaped_paths}")
+ end
+
+ private
+
+ def options_string
+ @options.join(' ')
+ end
+
+ def shellescaped_paths
+ @paths.map {|path| shellescape(path)}.join(' ')
+ end
+
+ # for Ruby 1.8.6 support
+ def shellescape(str)
+ # An empty argument will be skipped, so return empty quotes.
+ return "''" if str.empty?
+
+ str = str.dup
+
+ # Process as a single byte sequence because not all shell
+ # implementations are multibyte aware.
+ str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/n, "\\\\\\1")
+
+ # A LF cannot be escaped with a backslash because a backslash + LF
+ # combo is regarded as line continuation and simply ignored.
+ str.gsub!(/\n/, "'\n'")
+
+ return str
+ end
+ else
+ def pipe
+ @pipe ||= IO.popen([self.class.watcher_path] + @options + @paths)
+ end
+ end
+
+ private
+
+ def parse_options(options={})
+ opts = []
+ opts.concat(['--since-when', options[:since_when]]) if options[:since_when]
+ opts.concat(['--latency', options[:latency]]) if options[:latency]
+ opts.push('--no-defer') if options[:no_defer]
+ opts.push('--watch-root') if options[:watch_root]
+ # ruby 1.9's IO.popen(array-of-stuff) syntax requires all items to be strings
+ opts.map {|opt| "#{opt}"}
+ end
+
+end
View
3  ruby/rb-fsevent/lib/rb-fsevent/version.rb
@@ -0,0 +1,3 @@
+class FSEvent
+ VERSION = "0.4.0"
+end
View
15 spec/command-t/finder/file_finder_spec.rb
@@ -41,6 +41,10 @@ module VIM; end
)
end
+ before :each do
+ @finder.flush
+ end
+
before do
# scanner will call VIM's expand() function for exclusion filtering
stub(::VIM).evaluate(/expand\(.+\)/) { '0' }
@@ -66,6 +70,17 @@ module VIM; end
@finder.sorted_matches_for('a').
should == %w(baz bar/abc bar/xyz foo/alpha/t1 foo/alpha/t2 foo/beta)
end
+ it 'should return new file that was added to a directory' do
+ file = File.join(File.dirname(__FILE__), '..', '..', '..', 'fixtures', 'bam')
+ File.delete file if File.exists? file
+ @finder.sorted_matches_for('ba').
+ should == %w(baz bar/abc bar/xyz foo/beta)
+ FileUtils.touch(file)
+ sleep 2
+ @finder.sorted_matches_for('ba').
+ should == %w(bam baz bar/abc bar/xyz foo/beta)
+ File.delete file
+ end
it 'obeys the :limit option for empty search strings' do
@finder.sorted_matches_for('', :limit => 2).
Something went wrong with that request. Please try again.