autotest-inotify 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README.rdoc +2 -2
  2. data/lib/autotest/inotify.rb +21 -11
  3. metadata +4 -4
@@ -32,7 +32,7 @@ file:
32
32
 
33
33
  == THANK YOU:
34
34
 
35
- Inspiration for this gem came from work done by Alban Peignier's[1], and Sven
35
+ Inspiration for this gem came from work done by Alban Peignier[1], and Sven
36
36
  Schwyn[2]
37
37
 
38
38
  1. http://blog.tryphon.org/alban/archives/2007/10/26/inotify-support-for-autotest/
@@ -42,7 +42,7 @@ Schwyn[2]
42
42
 
43
43
  (The MIT License)
44
44
 
45
- Copyright (c) 2009 Eric A. Wollesen
45
+ Copyright (c) 2010 Eric A. Wollesen
46
46
 
47
47
  Permission is hereby granted, free of charge, to any person obtaining
48
48
  a copy of this software and associated documentation files (the
@@ -6,7 +6,6 @@ require "rbconfig"
6
6
  require "rb-inotify"
7
7
 
8
8
 
9
-
10
9
  Autotest.add_hook :initialize do |at|
11
10
  include Autotest::Inotify
12
11
  at.setup_inotify_if_running_linux
@@ -45,13 +44,16 @@ module Autotest::Inotify
45
44
 
46
45
  def wait_for_changes
47
46
  @changed_files = {}
47
+ @waited = true
48
48
  hook :waiting
49
- @notifier.process
49
+ @notifier.process while @changed_files.empty?
50
50
  end
51
51
 
52
52
  def find_files_to_test(files=nil)
53
- if first_time_run?
54
- select_all_tests
53
+ if not @waited
54
+ unless options[:no_full_after_start]
55
+ select_all_tests
56
+ end
55
57
  else
56
58
  p @changed_files if options[:verbose]
57
59
  hook :updated, @changed_files
@@ -62,19 +64,27 @@ module Autotest::Inotify
62
64
  end
63
65
  end
64
66
 
65
- def first_time_run?
66
- self.last_mtime.to_i.zero?
67
- end
68
-
69
67
  def setup_inotify
70
68
  @notifier = INotify::Notifier.new
71
- self.find_files.keys.each do |filename|
72
- @notifier.watch(filename, :modify) do |event|
73
- handle_file_event(event)
69
+ files = self.find_files.keys
70
+ dirs = files.map{|f| File.dirname( f )}.uniq
71
+ # Watch directories to catch delete/move swap patterns as well as direct
72
+ # modifications. This handles, e.g. :w in vim.
73
+ dirs.each do |dir|
74
+ @notifier.watch(dir, :all_events) do |event|
75
+ if event_of_interest?(event.flags) &&
76
+ files.include?(event.absolute_name)
77
+ handle_file_event(event)
78
+ end
74
79
  end
75
80
  end
76
81
  end
77
82
 
83
+ def event_of_interest?(flags)
84
+ flags.include?(:modify) ||
85
+ flags.include?(:moved_to)
86
+ end
87
+
78
88
  def handle_file_event(event)
79
89
  @changed_files[event.absolute_name] = Time.now
80
90
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autotest-inotify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Wollesen
@@ -94,6 +94,6 @@ rubyforge_project:
94
94
  rubygems_version: 1.3.7
95
95
  signing_key:
96
96
  specification_version: 3
97
- summary: Use libinotify (on Linux) instead of filesystem polling.
97
+ summary: Teaches autotest to use libinotify (on Linux) instead of filesystem polling.
98
98
  test_files: []
99
99