fsevent 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/fsevent.gemspec +6 -2
- data/lib/fsevent.rb +5 -0
- data/lib/fsevent/abstractdevice.rb +33 -13
- data/lib/fsevent/debugdumper.rb +33 -0
- data/lib/fsevent/failsafedevice.rb +8 -6
- data/lib/fsevent/framework.rb +325 -145
- data/lib/fsevent/processdevice.rb +1 -1
- data/lib/fsevent/processdevicec.rb +4 -4
- data/lib/fsevent/simpledevice.rb +2 -2
- data/lib/fsevent/util.rb +34 -6
- data/lib/fsevent/watchset.rb +133 -0
- data/sample/repeat.rb +1 -1
- data/sample/repeat2.rb +1 -1
- data/test/test_failsafedevice.rb +6 -6
- data/test/test_framework.rb +188 -12
- data/test/test_watch.rb +52 -43
- metadata +33 -3
data/test/test_watch.rb
CHANGED
@@ -25,9 +25,9 @@ class TestFSEventWatch < Test::Unit::TestCase
|
|
25
25
|
values = [9,2,3,5,1]
|
26
26
|
src_sched = values.map.with_index {|v, i| t + (i+1)*10 }
|
27
27
|
srcdevice = FSEvent::SimpleDevice.new("src", {"s"=>0}, [], 1, src_sched) {
|
28
|
-
|
|
28
|
+
|watched_status, changed_status|
|
29
29
|
fsevent.set_elapsed_time(5)
|
30
|
-
fsevent.
|
30
|
+
fsevent.modify_status "s", values.shift
|
31
31
|
}
|
32
32
|
fsevent.register_device(srcdevice)
|
33
33
|
fsevent.start
|
@@ -39,17 +39,17 @@ class TestFSEventWatch < Test::Unit::TestCase
|
|
39
39
|
t = Time.utc(2000)
|
40
40
|
fsevent = FSEvent.new(t)
|
41
41
|
values = [9,2,3,5,1]
|
42
|
-
src_sched = values.map.with_index {|v,
|
42
|
+
src_sched = values.map.with_index {|v, j| t + (j+1)*10 }
|
43
43
|
srcdevice = FSEvent::SimpleDevice.new("src", {"s"=>0}, [], 1, src_sched) {
|
44
|
-
|
|
44
|
+
|watched_status, changed_status|
|
45
45
|
fsevent.set_elapsed_time(5)
|
46
|
-
fsevent.
|
46
|
+
fsevent.modify_status "s", values.shift
|
47
47
|
}
|
48
48
|
test_result = []
|
49
49
|
dstdevice = FSEvent::SimpleDevice.new("dst", {}, [["src","s"]], 1) {
|
50
|
-
|
|
50
|
+
|watched_status, changed_status|
|
51
51
|
fsevent.set_elapsed_time(1)
|
52
|
-
test_result << [fsevent.current_time,
|
52
|
+
test_result << [fsevent.current_time, watched_status]
|
53
53
|
}
|
54
54
|
if i == 0
|
55
55
|
fsevent.register_device(srcdevice)
|
@@ -74,15 +74,15 @@ class TestFSEventWatch < Test::Unit::TestCase
|
|
74
74
|
t = Time.utc(2000)
|
75
75
|
fsevent = FSEvent.new(t)
|
76
76
|
srcdevice = FSEvent::SimpleDevice.new("src", {"s"=>0}, [], 1, [t+10]) {
|
77
|
-
|
|
77
|
+
|watched_status, changed_status|
|
78
78
|
fsevent.set_elapsed_time(5)
|
79
|
-
fsevent.
|
79
|
+
fsevent.modify_status "s", 100
|
80
80
|
}
|
81
81
|
test_result = []
|
82
82
|
dstdevice = FSEvent::SimpleDevice.new("dst", {}, [["src","s", :immediate]], 1, [t+20]) {
|
83
|
-
|
|
83
|
+
|watched_status, changed_status|
|
84
84
|
fsevent.set_elapsed_time(1)
|
85
|
-
test_result << [fsevent.current_time,
|
85
|
+
test_result << [fsevent.current_time, watched_status]
|
86
86
|
}
|
87
87
|
fsevent.register_device(srcdevice)
|
88
88
|
fsevent.register_device(dstdevice)
|
@@ -93,42 +93,19 @@ class TestFSEventWatch < Test::Unit::TestCase
|
|
93
93
|
test_result)
|
94
94
|
end
|
95
95
|
|
96
|
-
def test_wakeup_immediate_only_at_beginning
|
97
|
-
t = Time.utc(2000)
|
98
|
-
fsevent = FSEvent.new(t)
|
99
|
-
srcdevice = FSEvent::SimpleDevice.new("src", {"s"=>0}, [], 1, [t+10]) {
|
100
|
-
|watched_status_change|
|
101
|
-
fsevent.set_elapsed_time(5)
|
102
|
-
fsevent.status_changed "s", 100
|
103
|
-
}
|
104
|
-
test_result = []
|
105
|
-
dstdevice = FSEvent::SimpleDevice.new("dst", {}, [["src","s", :immediate_only_at_beginning]], 1, [t+20]) {
|
106
|
-
|watched_status_change|
|
107
|
-
fsevent.set_elapsed_time(1)
|
108
|
-
test_result << [fsevent.current_time, watched_status_change]
|
109
|
-
}
|
110
|
-
fsevent.register_device(srcdevice)
|
111
|
-
fsevent.register_device(dstdevice)
|
112
|
-
fsevent.start
|
113
|
-
assert_equal(
|
114
|
-
[[t + 1, {"src"=>{"s"=>0}}],
|
115
|
-
[t + 20, {"src"=>{"s"=>100}}]],
|
116
|
-
test_result)
|
117
|
-
end
|
118
|
-
|
119
96
|
def test_wakeup_schedule
|
120
97
|
t = Time.utc(2000)
|
121
98
|
fsevent = FSEvent.new(t)
|
122
99
|
srcdevice = FSEvent::SimpleDevice.new("src", {"s"=>0}, [], 1, [t+10]) {
|
123
|
-
|
|
100
|
+
|watched_status, changed_status|
|
124
101
|
fsevent.set_elapsed_time(5)
|
125
|
-
fsevent.
|
102
|
+
fsevent.modify_status "s", 100
|
126
103
|
}
|
127
104
|
test_result = []
|
128
105
|
dstdevice = FSEvent::SimpleDevice.new("dst", {}, [["src","s", :schedule]], 1, [t+20]) {
|
129
|
-
|
|
106
|
+
|watched_status, changed_status|
|
130
107
|
fsevent.set_elapsed_time(1)
|
131
|
-
test_result << [fsevent.current_time,
|
108
|
+
test_result << [fsevent.current_time, watched_status]
|
132
109
|
}
|
133
110
|
fsevent.register_device(srcdevice)
|
134
111
|
fsevent.register_device(dstdevice)
|
@@ -143,27 +120,59 @@ class TestFSEventWatch < Test::Unit::TestCase
|
|
143
120
|
fsevent = FSEvent.new(t)
|
144
121
|
s = 0
|
145
122
|
srcdevice = FSEvent::SimpleDevice.new("src", {"s"=>0}, [], 1, [t+10, t+20]) {
|
146
|
-
|
|
123
|
+
|watched_status, changed_status|
|
147
124
|
fsevent.set_elapsed_time(5)
|
148
125
|
s += 100
|
149
|
-
fsevent.
|
126
|
+
fsevent.modify_status "s", s
|
150
127
|
}
|
151
128
|
test_result = []
|
152
129
|
dstdevice = FSEvent::SimpleDevice.new("dst", {}, [["src","s", :schedule]], 1, [t+17, t+27]) {
|
153
|
-
|
|
130
|
+
|watched_status, changed_status|
|
154
131
|
fsevent.set_elapsed_time(1)
|
155
132
|
if fsevent.current_time == t+17
|
156
133
|
fsevent.del_watch("src", "s")
|
157
134
|
end
|
158
|
-
test_result << [fsevent.current_time,
|
135
|
+
test_result << [fsevent.current_time, watched_status]
|
159
136
|
}
|
160
137
|
fsevent.register_device(srcdevice)
|
161
138
|
fsevent.register_device(dstdevice)
|
162
139
|
fsevent.start
|
163
140
|
assert_equal(
|
164
141
|
[[t+17, {"src"=>{"s"=>100}}],
|
165
|
-
[t+27,
|
142
|
+
[t+27, {}]],
|
166
143
|
test_result)
|
167
144
|
end
|
168
145
|
|
146
|
+
def test_lookup_watchers_exact1
|
147
|
+
ws = FSEvent::WatchSet.new
|
148
|
+
ws.add("src", "status", "d", :immediate)
|
149
|
+
assert_equal([["d", :immediate]], ws.lookup_watchers("src", "status"))
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_lookup_watchers_exact2
|
153
|
+
ws = FSEvent::WatchSet.new
|
154
|
+
ws.add("src", "s", "d1", :immediate)
|
155
|
+
ws.add("src", "s", "d2", :schedule)
|
156
|
+
assert_equal([["d1", :immediate], ["d2", :schedule]],
|
157
|
+
ws.lookup_watchers("src", "s"))
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_lookup_watchers_prefix_exact
|
161
|
+
ws = FSEvent::WatchSet.new
|
162
|
+
ws.add("sr*", "status", "d", :immediate)
|
163
|
+
assert_equal([["d", :immediate]], ws.lookup_watchers("src", "status"))
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_lookup_watchers_exact_prefix
|
167
|
+
ws = FSEvent::WatchSet.new
|
168
|
+
ws.add("src", "st*", "d", :immediate)
|
169
|
+
assert_equal([["d", :immediate]], ws.lookup_watchers("src", "status"))
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_lookup_watchers_prefix_prefix
|
173
|
+
ws = FSEvent::WatchSet.new
|
174
|
+
ws.add("sr*", "st*", "d", :immediate)
|
175
|
+
assert_equal([["d", :immediate]], ws.lookup_watchers("src", "status"))
|
176
|
+
end
|
177
|
+
|
169
178
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fsevent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanaka Akira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
12
|
-
dependencies:
|
11
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: depq
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.5'
|
13
41
|
description: |
|
14
42
|
fail safe event driven framework
|
15
43
|
email: tanaka-akira@aist.go.jp
|
@@ -23,6 +51,7 @@ files:
|
|
23
51
|
- fsevent.gemspec
|
24
52
|
- lib/fsevent.rb
|
25
53
|
- lib/fsevent/abstractdevice.rb
|
54
|
+
- lib/fsevent/debugdumper.rb
|
26
55
|
- lib/fsevent/failsafedevice.rb
|
27
56
|
- lib/fsevent/framework.rb
|
28
57
|
- lib/fsevent/periodicschedule.rb
|
@@ -31,6 +60,7 @@ files:
|
|
31
60
|
- lib/fsevent/schedulemerger.rb
|
32
61
|
- lib/fsevent/simpledevice.rb
|
33
62
|
- lib/fsevent/util.rb
|
63
|
+
- lib/fsevent/watchset.rb
|
34
64
|
- sample/repeat.rb
|
35
65
|
- sample/repeat2.rb
|
36
66
|
- test/test_failsafedevice.rb
|