autotest-inotify 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/lib/autotest/inotify.rb +17 -27
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -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[1], and Sven
|
35
|
+
Inspiration for this gem came from work done by Alban Peignier's[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)
|
45
|
+
Copyright (c) 2009 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
|
data/lib/autotest/inotify.rb
CHANGED
@@ -5,13 +5,16 @@ require "autotest"
|
|
5
5
|
require "rbconfig"
|
6
6
|
require "rb-inotify"
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
|
10
|
+
Autotest.add_hook :initialize do |at|
|
9
11
|
include Autotest::Inotify
|
10
|
-
setup_inotify_if_running_linux
|
12
|
+
at.setup_inotify_if_running_linux
|
11
13
|
end
|
12
14
|
|
15
|
+
|
13
16
|
##
|
14
|
-
# Autotest::
|
17
|
+
# Autotest::Inotify
|
15
18
|
#
|
16
19
|
# == FEATURES:
|
17
20
|
# * Use Linux's inotify instead of filesystem polling
|
@@ -21,14 +24,16 @@ end
|
|
21
24
|
# require "autotest/inotify"
|
22
25
|
module Autotest::Inotify
|
23
26
|
|
24
|
-
private
|
25
|
-
|
26
27
|
def setup_inotify_if_running_linux
|
27
28
|
if running_linux?
|
28
29
|
override_autotest_methods
|
30
|
+
setup_inotify
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
|
35
|
+
private
|
36
|
+
|
32
37
|
def running_linux?
|
33
38
|
/linux/i === RbConfig::CONFIG["host_os"]
|
34
39
|
end
|
@@ -41,17 +46,14 @@ module Autotest::Inotify
|
|
41
46
|
def wait_for_changes
|
42
47
|
@changed_files = {}
|
43
48
|
hook :waiting
|
44
|
-
@notifier.process
|
49
|
+
@notifier.process
|
45
50
|
end
|
46
51
|
|
47
52
|
def find_files_to_test(files=nil)
|
48
53
|
if first_time_run?
|
49
|
-
|
50
|
-
unless options[:no_full_after_start]
|
51
|
-
select_all_tests
|
52
|
-
end
|
54
|
+
select_all_tests
|
53
55
|
else
|
54
|
-
p @changed_files if
|
56
|
+
p @changed_files if options[:verbose]
|
55
57
|
hook :updated, @changed_files
|
56
58
|
select_tests_for_changed_files
|
57
59
|
end
|
@@ -61,30 +63,18 @@ module Autotest::Inotify
|
|
61
63
|
end
|
62
64
|
|
63
65
|
def first_time_run?
|
64
|
-
|
66
|
+
self.last_mtime.to_i.zero?
|
65
67
|
end
|
66
68
|
|
67
69
|
def setup_inotify
|
68
70
|
@notifier = INotify::Notifier.new
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
71
|
+
self.find_files.keys.each do |filename|
|
72
|
+
@notifier.watch(filename, :modify) do |event|
|
73
|
+
handle_file_event(event)
|
79
74
|
end
|
80
75
|
end
|
81
76
|
end
|
82
77
|
|
83
|
-
def event_of_interest?(flags)
|
84
|
-
flags.include?(:modify) ||
|
85
|
-
flags.include?(:moved_to)
|
86
|
-
end
|
87
|
-
|
88
78
|
def handle_file_event(event)
|
89
79
|
@changed_files[event.absolute_name] = Time.now
|
90
80
|
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:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eric Wollesen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-12 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -94,6 +94,6 @@ rubyforge_project:
|
|
94
94
|
rubygems_version: 1.3.7
|
95
95
|
signing_key:
|
96
96
|
specification_version: 3
|
97
|
-
summary:
|
97
|
+
summary: Use libinotify (on Linux) instead of filesystem polling.
|
98
98
|
test_files: []
|
99
99
|
|