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.
@@ -83,8 +83,10 @@ module Watchr
83
83
  #
84
84
  def monitored_paths
85
85
  paths = Dir['**/*'].select do |path|
86
+ p path
86
87
  @script.rules.any? {|r| r.match(path) }
87
88
  end
89
+ p paths
88
90
  paths.push(@script.path).compact!
89
91
  paths.map {|path| Pathname(path).expand_path }
90
92
  end
@@ -47,7 +47,6 @@ module Watchr
47
47
  end
48
48
 
49
49
  def file_deleted
50
- stop_watching
51
50
  SingleFileWatcher.handler.notify(path, type)
52
51
  end
53
52
 
data/lib/watchr/script.rb CHANGED
@@ -22,7 +22,9 @@ module Watchr
22
22
 
23
23
  class Rule
24
24
  def match path
25
- ( md = self.pattern.match(path) ) &&
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.each do |rule_event_type|
164
- # p rule_event_type
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.event_type.should be(:modified)
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.event_type.should be(:modified)
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.1'
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smparkes-watchr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.1
4
+ version: 0.5.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mynyml