smparkes-watchr 0.5.7.1 → 0.5.7.2
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.
- data/lib/watchr/controller.rb +2 -0
- data/lib/watchr/event_handlers/em.rb +0 -1
- data/lib/watchr/script.rb +6 -3
- data/test/test_script.rb +2 -2
- data/watchr.gemspec +1 -1
- metadata +1 -1
data/lib/watchr/controller.rb
CHANGED
data/lib/watchr/script.rb
CHANGED
@@ -22,7 +22,9 @@ module Watchr
|
|
22
22
|
|
23
23
|
class Rule
|
24
24
|
def match path
|
25
|
-
|
25
|
+
pattern = self.pattern
|
26
|
+
( pattern.class == String ) and ( pattern = Regexp.new pattern )
|
27
|
+
( md = pattern.match(path) ) &&
|
26
28
|
( self.predicate == nil || self.predicate.call(md) )
|
27
29
|
end
|
28
30
|
end
|
@@ -160,8 +162,9 @@ module Watchr
|
|
160
162
|
# p path
|
161
163
|
rules_for(path).each do |rule|
|
162
164
|
# p rule
|
163
|
-
rule.event_types
|
164
|
-
|
165
|
+
types = rule.event_types
|
166
|
+
!types.empty? or types = [ nil ]
|
167
|
+
types.each do |rule_event_type|
|
165
168
|
if ( rule_event_type.nil? && ( event_type != :load ) ) || ( rule_event_type == event_type )
|
166
169
|
data = path.match(rule.pattern)
|
167
170
|
return rule.action.call(data)
|
data/test/test_script.rb
CHANGED
@@ -25,13 +25,13 @@ class TestScript < Test::Unit::TestCase
|
|
25
25
|
test "rule object" do
|
26
26
|
rule = @script.watch('pattern', :modified) { nil }
|
27
27
|
rule.pattern.should be('pattern')
|
28
|
-
rule.
|
28
|
+
rule.event_types[0].should be(:modified)
|
29
29
|
rule.action.call.should be(nil)
|
30
30
|
end
|
31
31
|
|
32
32
|
test "default event type" do
|
33
33
|
rule = @script.watch('pattern') { nil }
|
34
|
-
rule.
|
34
|
+
rule.event_types[0].should be(:modified)
|
35
35
|
end
|
36
36
|
|
37
37
|
test "finds action for path" do
|
data/watchr.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'smparkes-watchr'
|
4
|
-
s.version = '0.5.7.
|
4
|
+
s.version = '0.5.7.2'
|
5
5
|
s.summary = "Modern continious testing (flexible alternative to autotest)"
|
6
6
|
s.description = "Modern continious testing (flexible alternative to autotest)."
|
7
7
|
s.author = "mynyml"
|