watchr 0.5.8 → 0.5.9

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/Manifest CHANGED
@@ -6,6 +6,7 @@ README.rdoc
6
6
  Rakefile
7
7
  TODO.txt
8
8
  bin/watchr
9
+ contributions.txt
9
10
  docs.watchr
10
11
  gem.watchr
11
12
  lib/watchr.rb
@@ -14,7 +15,6 @@ lib/watchr/event_handlers/base.rb
14
15
  lib/watchr/event_handlers/portable.rb
15
16
  lib/watchr/event_handlers/unix.rb
16
17
  lib/watchr/script.rb
17
- manifest.watchr
18
18
  specs.watchr
19
19
  test/README
20
20
  test/event_handlers/test_base.rb
@@ -88,8 +88,10 @@ Watchr evented.
88
88
 
89
89
  === See Also
90
90
 
91
- redgreen[http://github.com/mynyml/redgreen]:: Standalone redgreen eye candy for test results, ala autotest.
92
- phocus[http://github.com/mynyml/phocus]:: Run focused tests when running the whole file/suite is unnecessary.
91
+ redgreen[http://github.com/mynyml/redgreen]:: Standalone redgreen eye candy for test results, ala autotest.
92
+ phocus[http://github.com/mynyml/phocus]:: Run focused tests when running the whole file/suite is unnecessary.
93
+ autowatchr[http://github.com/viking/autowatchr]:: Provides some autotest-like behavior for watchr
94
+ nestor[http://github.com/francois/nestor]:: Continuous testing server for Rails
93
95
 
94
96
 
95
97
  === Links
@@ -98,11 +100,5 @@ source:: http://github.com/mynyml/watchr
98
100
  docs:: http://docs.github.com/mynyml/watchr
99
101
  wiki:: http://wiki.github.com/mynyml/watchr
100
102
  bugs:: http://github.com/mynyml/watchr/issues
101
-
102
- === Contributions
103
-
104
- macournoyer[http://github.com/macournoyer]:: suggested evented backend
105
- foca[http://github.com/foca]:: suggested automatically picking up watchr scripts bundled in gems
106
- TwP[http://github.com/TwP]:: patch, Rev gem optional in development
107
- gzuki[http://github.com/gzuki]:: patch, recognize some event types
103
+ group:: http://groups.google.com/group/watchr
108
104
 
data/Rakefile CHANGED
@@ -15,12 +15,11 @@ namespace(:test) do
15
15
 
16
16
  desc "Run all tests on multiple ruby versions (requires rvm)"
17
17
  task(:portability) do
18
- versions = %w( 1.8.6 1.8.7 )
19
- versions.each do |version|
18
+ %w( 1.8.6 1.8.7 1.9.1 1.9.2 ).each do |version|
20
19
  system <<-BASH
21
20
  bash -c 'source ~/.rvm/scripts/rvm;
22
- rvm use #{version};
23
- echo "--------- `ruby -v` ----------\n";
21
+ rvm #{version};
22
+ echo "--------- v#{version} ----------\n";
24
23
  rake -s test:all'
25
24
  BASH
26
25
  end
@@ -0,0 +1,7 @@
1
+
2
+ Suggestions:
3
+ macournoyer, foca
4
+
5
+ Patches:
6
+ TwP, gzuki, spraints, francois
7
+
@@ -13,7 +13,7 @@ require 'rbconfig'
13
13
  # See README for more details
14
14
  #
15
15
  module Watchr
16
- VERSION = '0.5.8'
16
+ VERSION = '0.5.9'
17
17
 
18
18
  begin
19
19
  require 'rev'
@@ -77,7 +77,7 @@ module Watchr
77
77
  def initialize(path = nil)
78
78
  @path = path
79
79
  @rules = []
80
- @default_action = lambda {}
80
+ @default_action = Proc.new {}
81
81
  @ec = EvalContext.new(self)
82
82
  end
83
83
 
@@ -159,7 +159,7 @@ module Watchr
159
159
  # Reset script state
160
160
  def reset
161
161
  @rules = []
162
- @default_action = lambda {}
162
+ @default_action = Proc.new {}
163
163
  end
164
164
 
165
165
  # Eval content of script file.
@@ -1,6 +1,6 @@
1
1
  require 'test/test_helper'
2
2
 
3
- class BaseEventHandlerTest < Test::Unit::TestCase
3
+ class BaseEventHandlerTest < MiniTest::Unit::TestCase
4
4
 
5
5
  class Handler
6
6
  include Watchr::EventHandler::Base
@@ -11,10 +11,10 @@ class BaseEventHandlerTest < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  test "api" do
14
- @handler.should respond_to(:notify)
15
- @handler.should respond_to(:listen)
16
- @handler.should respond_to(:refresh)
17
- @handler.class.ancestors.should include(Observable)
14
+ assert_respond_to @handler, :notify
15
+ assert_respond_to @handler, :listen
16
+ assert_respond_to @handler, :refresh
17
+ assert_includes @handler.class.ancestors, Observable
18
18
  end
19
19
 
20
20
  test "notifies observers" do
@@ -4,7 +4,7 @@ class Watchr::EventHandler::Portable
4
4
  attr_accessor :monitored_paths
5
5
  end
6
6
 
7
- class PortableEventHandlerTest < Test::Unit::TestCase
7
+ class PortableEventHandlerTest < MiniTest::Unit::TestCase
8
8
  include Watchr
9
9
 
10
10
  def setup
@@ -34,8 +34,8 @@ class PortableEventHandlerTest < Test::Unit::TestCase
34
34
 
35
35
  test "listens for events on monitored files" do
36
36
  @handler.listen [ @foo, @bar ]
37
- @handler.monitored_paths.should include(@foo)
38
- @handler.monitored_paths.should include(@bar)
37
+ assert_includes @handler.monitored_paths, @foo
38
+ assert_includes @handler.monitored_paths, @bar
39
39
  end
40
40
 
41
41
  test "doesn't trigger on start" do
@@ -118,14 +118,14 @@ class PortableEventHandlerTest < Test::Unit::TestCase
118
118
 
119
119
  test "reattaches to new monitored files" do
120
120
  @handler.listen [ @foo, @bar ]
121
- @handler.monitored_paths.should include(@foo)
122
- @handler.monitored_paths.should include(@bar)
121
+ assert_includes @handler.monitored_paths, @foo
122
+ assert_includes @handler.monitored_paths, @bar
123
123
 
124
124
  @handler.refresh [ @baz, @bax ]
125
- @handler.monitored_paths.should include(@baz)
126
- @handler.monitored_paths.should include(@bax)
127
- @handler.monitored_paths.should exclude(@foo)
128
- @handler.monitored_paths.should exclude(@bar)
125
+ assert_includes @handler.monitored_paths, @baz
126
+ assert_includes @handler.monitored_paths, @bax
127
+ refute_includes @handler.monitored_paths, @foo
128
+ refute_includes @handler.monitored_paths, @bar
129
129
  end
130
130
 
131
131
  test "retries on ENOENT errors" do
@@ -6,7 +6,7 @@ class Watchr::EventHandler::Unix::SingleFileWatcher
6
6
  public :type
7
7
  end
8
8
 
9
- class UnixEventHandlerTest < Test::Unit::TestCase
9
+ class UnixEventHandlerTest < MiniTest::Unit::TestCase
10
10
  include Watchr
11
11
 
12
12
  SingleFileWatcher = EventHandler::Unix::SingleFileWatcher
@@ -39,8 +39,8 @@ class UnixEventHandlerTest < Test::Unit::TestCase
39
39
  ## SingleFileWatcher
40
40
 
41
41
  test "watcher pathname" do
42
- @watcher.pathname.should be_kind_of(Pathname)
43
- @watcher.pathname.to_s.should be(@watcher.path)
42
+ assert_instance_of Pathname, @watcher.pathname
43
+ assert_equal @watcher.path, @watcher.pathname.to_s
44
44
  end
45
45
 
46
46
  test "stores reference times" do
@@ -49,9 +49,9 @@ class UnixEventHandlerTest < Test::Unit::TestCase
49
49
  @watcher.pathname.stubs(:ctime).returns(:time)
50
50
 
51
51
  @watcher.send(:update_reference_times)
52
- @watcher.instance_variable_get(:@reference_atime).should be(:time)
53
- @watcher.instance_variable_get(:@reference_mtime).should be(:time)
54
- @watcher.instance_variable_get(:@reference_ctime).should be(:time)
52
+ assert_equal :time, @watcher.instance_variable_get(:@reference_atime)
53
+ assert_equal :time, @watcher.instance_variable_get(:@reference_mtime)
54
+ assert_equal :time, @watcher.instance_variable_get(:@reference_ctime)
55
55
  end
56
56
 
57
57
  test "stores initial reference times" do
@@ -66,37 +66,37 @@ class UnixEventHandlerTest < Test::Unit::TestCase
66
66
 
67
67
  test "detects event type" do
68
68
  trigger_event @watcher, @now, :atime
69
- @watcher.type.should be(:accessed)
69
+ assert_equal :accessed, @watcher.type
70
70
 
71
71
  trigger_event @watcher, @now, :mtime
72
- @watcher.type.should be(:modified)
72
+ assert_equal :modified, @watcher.type
73
73
 
74
74
  trigger_event @watcher, @now, :ctime
75
- @watcher.type.should be(:changed)
75
+ assert_equal :changed, @watcher.type
76
76
 
77
77
  trigger_event @watcher, @now, :atime, :mtime
78
- @watcher.type.should be(:modified)
78
+ assert_equal :modified, @watcher.type
79
79
 
80
80
  trigger_event @watcher, @now, :mtime, :ctime
81
- @watcher.type.should be(:modified)
81
+ assert_equal :modified, @watcher.type
82
82
 
83
83
  trigger_event @watcher, @now, :atime, :ctime
84
- @watcher.type.should be(:accessed)
84
+ assert_equal :accessed, @watcher.type
85
85
 
86
86
  trigger_event @watcher, @now, :atime, :mtime, :ctime
87
- @watcher.type.should be(:modified)
87
+ assert_equal :modified, @watcher.type
88
88
 
89
89
  @watcher.pathname.stubs(:exist?).returns(false)
90
- @watcher.type.should be(:deleted)
90
+ assert_equal :deleted, @watcher.type
91
91
  end
92
92
 
93
93
  ## monitoring file events
94
94
 
95
95
  test "listens for events on monitored files" do
96
96
  @handler.listen %w( foo bar )
97
- @loop.watchers.size.should be(2)
98
- @loop.watchers.every.path.should include('foo', 'bar')
99
- @loop.watchers.every.class.uniq.should be([SingleFileWatcher])
97
+ assert_equal 2, @loop.watchers.size
98
+ assert_equal %w( foo bar ).to_set, @loop.watchers.every.path.to_set
99
+ assert_equal [SingleFileWatcher], @loop.watchers.every.class.uniq
100
100
  end
101
101
 
102
102
  test "notifies observers on file event" do
@@ -131,16 +131,16 @@ class UnixEventHandlerTest < Test::Unit::TestCase
131
131
 
132
132
  test "reattaches to new monitored files" do
133
133
  @handler.listen %w( foo bar )
134
- @loop.watchers.size.should be(2)
135
- @loop.watchers.every.path.should include('foo')
136
- @loop.watchers.every.path.should include('bar')
134
+ assert_equal 2, @loop.watchers.size
135
+ assert_includes @loop.watchers.every.path, 'foo'
136
+ assert_includes @loop.watchers.every.path, 'bar'
137
137
 
138
138
  @handler.refresh %w( baz bax )
139
- @loop.watchers.size.should be(2)
140
- @loop.watchers.every.path.should include('baz')
141
- @loop.watchers.every.path.should include('bax')
142
- @loop.watchers.every.path.should exclude('foo')
143
- @loop.watchers.every.path.should exclude('bar')
139
+ assert_equal 2, @loop.watchers.size
140
+ assert_includes @loop.watchers.every.path, 'baz'
141
+ assert_includes @loop.watchers.every.path, 'bax'
142
+ refute_includes @loop.watchers.every.path, 'foo'
143
+ refute_includes @loop.watchers.every.path, 'bar'
144
144
  end
145
145
 
146
146
  private
@@ -7,7 +7,7 @@ class MockHandler
7
7
  def refresh(paths) end
8
8
  end
9
9
 
10
- class TestController < Test::Unit::TestCase
10
+ class TestController < MiniTest::Unit::TestCase
11
11
  include Watchr
12
12
 
13
13
  def to_p(str)
@@ -33,9 +33,9 @@ class TestController < Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  test "adds itself as handler observer" do
36
- @handler.count_observers.should be(1)
36
+ assert_equal 1, @handler.count_observers
37
37
  @handler.delete_observer(@controller)
38
- @handler.count_observers.should be(0)
38
+ assert_equal 0, @handler.count_observers
39
39
  end
40
40
 
41
41
  ## monitored paths list
@@ -50,8 +50,8 @@ class TestController < Test::Unit::TestCase
50
50
  @script.watch('.\.z') { :x }
51
51
 
52
52
  contrl = Controller.new(@script, MockHandler.new)
53
- contrl.monitored_paths.should include(to_p('b/x.z'))
54
- contrl.monitored_paths.should include(to_p('b/c/y.z'))
53
+ assert_includes contrl.monitored_paths, to_p('b/x.z')
54
+ assert_includes contrl.monitored_paths, to_p('b/c/y.z')
55
55
  end
56
56
 
57
57
  test "doesn't fetch unmonitored paths" do
@@ -64,9 +64,9 @@ class TestController < Test::Unit::TestCase
64
64
  @script.watch('.\.z') { :x }
65
65
 
66
66
  contrl = Controller.new(@script, MockHandler.new)
67
- contrl.monitored_paths.should exclude(to_p('a'))
68
- contrl.monitored_paths.should exclude(to_p('b/c'))
69
- contrl.monitored_paths.should exclude(to_p('p/q.z'))
67
+ refute_includes contrl.monitored_paths, to_p('a')
68
+ refute_includes contrl.monitored_paths, to_p('b/c')
69
+ refute_includes contrl.monitored_paths, to_p('p/q.z')
70
70
  end
71
71
 
72
72
  test "monitored paths include script" do
@@ -76,7 +76,7 @@ class TestController < Test::Unit::TestCase
76
76
  path = to_p('some/file')
77
77
  script = Script.new(path)
78
78
  contrl = Controller.new(script, MockHandler.new)
79
- contrl.monitored_paths.should include(path)
79
+ assert_includes contrl.monitored_paths, path
80
80
  end
81
81
 
82
82
  ## on update
@@ -1,25 +1,23 @@
1
1
  require 'pathname'
2
2
  require 'tempfile'
3
- require 'test/unit'
3
+ require 'set'
4
4
 
5
- require 'matchy'
5
+ require 'minitest/autorun'
6
6
  require 'mocha'
7
7
  require 'every'
8
- require 'pending'
9
8
  begin
10
- require 'redgreen'
9
+ require 'redgreen' #http://gemcutter.org/gems/mynyml-redgreen
11
10
  require 'phocus'
12
11
  require 'ruby-debug'
13
12
  rescue LoadError, RuntimeError
14
13
  end
15
14
 
16
- require 'lib/watchr'
15
+ require 'watchr'
17
16
 
18
- class Test::Unit::TestCase
17
+ class MiniTest::Unit::TestCase
19
18
  class << self
20
19
  def test(name, &block)
21
- name = :"test_#{name.gsub(/\s/,'_')}"
22
- define_method(name, &block)
20
+ define_method("test_#{name.gsub(/\s/,'_')}", &block)
23
21
  end
24
22
  alias :should :test
25
23
 
@@ -28,22 +26,7 @@ class Test::Unit::TestCase
28
26
  end
29
27
  end
30
28
 
31
- # taken from minitest/unit.rb
32
- # (with modifications)
33
- def capture_io
34
- require 'stringio'
35
-
36
- orig_stdout, orig_stderr = $stdout, $stderr
37
- captured_stdout, captured_stderr = StringIO.new, StringIO.new
38
- $stdout, $stderr = captured_stdout, captured_stderr
39
-
40
- yield
41
-
42
- return Struct.new(:stdout, :stderr).new(
43
- captured_stdout.string,
44
- captured_stderr.string
45
- )
46
- ensure
47
- $stdout = orig_stdout
48
- $stderr = orig_stderr
29
+ unless Watchr::HAVE_REV
30
+ puts "Skipping Unix handler tests. Install Rev (gem install rev) to properly test full suite"
49
31
  end
32
+
@@ -1,6 +1,6 @@
1
1
  require 'test/test_helper'
2
2
 
3
- class TestScript < Test::Unit::TestCase
3
+ class TestScript < MiniTest::Unit::TestCase
4
4
  include Watchr
5
5
 
6
6
  def setup
@@ -29,52 +29,53 @@ class TestScript < Test::Unit::TestCase
29
29
  @script.ec.watch('pattern') { nil }
30
30
  @script.ec.default_action { :foo }
31
31
 
32
- @script.rules.size.should be(3)
33
- @script.default_action.call.should be(:foo)
32
+ assert_equal 3, @script.rules.size
33
+ assert_equal :foo, @script.default_action.call
34
34
  end
35
35
 
36
36
  ## functionality
37
37
 
38
38
  test "rule object" do
39
39
  rule = @script.watch('pattern', :modified) { nil }
40
- rule.pattern.should be('pattern')
41
- rule.event_type.should be(:modified)
42
- rule.action.call.should be(nil)
40
+
41
+ assert_equal 'pattern', rule.pattern
42
+ assert_equal :modified, rule.event_type
43
+ assert_equal nil, rule.action.call
43
44
  end
44
45
 
45
46
  test "default event type" do
46
47
  rule = @script.watch('pattern') { nil }
47
- rule.event_type.should be(:modified)
48
+ assert_equal :modified, rule.event_type
48
49
  end
49
50
 
50
51
  test "finds action for path" do
51
52
  @script.watch('abc') { :x }
52
53
  @script.watch('def') { :y }
53
- @script.action_for('abc').call.should be(:x)
54
+ assert_equal :x, @script.action_for('abc').call
54
55
  end
55
56
 
56
57
  test "finds action for path with event type" do
57
58
  @script.watch('abc', :accessed) { :x }
58
59
  @script.watch('abc', :modified) { :y }
59
- @script.action_for('abc', :accessed).call.should be(:x)
60
+ assert_equal :x, @script.action_for('abc', :accessed).call
60
61
  end
61
62
 
62
63
  test "finds action for path with any event type" do
63
64
  @script.watch('abc', nil) { :x }
64
65
  @script.watch('abc', :modified) { :y }
65
- @script.action_for('abc', :accessed).call.should be(:x)
66
+ assert_equal :x, @script.action_for('abc', :accessed).call
66
67
  end
67
68
 
68
69
  test "no action for path" do
69
70
  @script.watch('abc', :accessed) { :x }
70
- @script.action_for('abc', :modified).call.should be(nil)
71
+ assert_nil @script.action_for('abc', :modified).call
71
72
  end
72
73
 
73
74
  test "collects patterns" do
74
75
  @script.watch('abc')
75
76
  @script.watch('def')
76
- @script.patterns.should include('abc')
77
- @script.patterns.should include('def')
77
+ assert_includes @script.patterns, 'abc'
78
+ assert_includes @script.patterns, 'def'
78
79
  end
79
80
 
80
81
  test "parses script file" do
@@ -84,7 +85,7 @@ class TestScript < Test::Unit::TestCase
84
85
  STR
85
86
  script = Script.new(path)
86
87
  script.parse!
87
- script.action_for('abc').call.should be(:x)
88
+ assert_equal :x, script.action_for('abc').call
88
89
  end
89
90
 
90
91
  test "__FILE__ is set properly in script file" do
@@ -93,7 +94,7 @@ class TestScript < Test::Unit::TestCase
93
94
  throw __FILE__.to_sym
94
95
  STR
95
96
  script = Script.new(path)
96
- lambda { script.parse! }.should throw_symbol(path.to_s.to_sym)
97
+ assert_throws(path.to_s.to_sym) { script.parse! }
97
98
  end
98
99
 
99
100
  test "reloads script file" do
@@ -111,8 +112,8 @@ class TestScript < Test::Unit::TestCase
111
112
  @script.default_action { 'x' }
112
113
  @script.watch('foo') { 'bar' }
113
114
  @script.reset
114
- @script.default_action.call.should be(nil)
115
- @script.rules.should be([])
115
+ assert_nil @script.default_action.call
116
+ assert_equal [], @script.rules
116
117
  end
117
118
 
118
119
  test "resets state on parse" do
@@ -124,40 +125,39 @@ class TestScript < Test::Unit::TestCase
124
125
 
125
126
  test "actions receive a MatchData object" do
126
127
  @script.watch('de(.)') {|m| [m[0], m[1]] }
127
- @script.action_for('def').call.should be(%w( def f ))
128
+ assert_equal %w( def f ), @script.action_for('def').call
128
129
  end
129
130
 
130
131
  test "rule's default action" do
131
132
  @script.watch('abc')
132
- @script.action_for('abc').call.should be(nil)
133
- @script.default_action { :x }
133
+ assert_nil @script.action_for('abc').call
134
134
 
135
+ @script.default_action { :x }
135
136
  @script.watch('def')
136
- @script.action_for('def').call.should be(:x)
137
+ assert_equal :x, @script.action_for('def').call
137
138
  end
138
139
 
139
140
  test "file path" do
140
141
  Script.any_instance.stubs(:parse!)
141
142
  path = Pathname('some/file').expand_path
142
143
  script = Script.new(path)
143
- script.path.should be(path)
144
+ assert_equal path, script.path
144
145
  end
145
146
 
146
147
  test "nil file path" do
147
148
  script = Script.new
148
- script.path.should be(nil)
149
+ assert_nil script.path
149
150
  end
150
151
 
151
152
  test "later rules take precedence" do
152
153
  @script.watch('a/(.*)\.x') { :x }
153
154
  @script.watch('a/b/(.*)\.x') { :y }
154
-
155
- @script.action_for('a/b/c.x').call.should be(:y)
155
+ assert_equal :y, @script.action_for('a/b/c.x').call
156
156
  end
157
157
 
158
158
  test "rule patterns match against paths relative to pwd" do
159
159
  @script.watch('^abc') { :x }
160
160
  path = Pathname(Dir.pwd) + 'abc'
161
- @script.action_for(path).call.should be(:x)
161
+ assert_equal :x, @script.action_for(path).call
162
162
  end
163
163
  end
@@ -1,6 +1,6 @@
1
1
  require 'test/test_helper'
2
2
 
3
- class TestWatchr < Test::Unit::TestCase
3
+ class TestWatchr < MiniTest::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  Watchr.options = nil
@@ -9,52 +9,56 @@ class TestWatchr < Test::Unit::TestCase
9
9
  ## options
10
10
 
11
11
  test "debug option" do
12
- Watchr.options.debug.should be(false)
12
+ assert_equal false, Watchr.options.debug
13
13
  Watchr.options.debug = true
14
- Watchr.options.debug.should be(true)
14
+ assert_equal true, Watchr.options.debug
15
15
  end
16
16
 
17
17
  ## functionality
18
18
 
19
19
  test "debug" do
20
- capture_io { Watchr.debug('abc') }.stdout.should be('')
20
+ assert_empty capture_io { Watchr.debug('abc') }.first
21
21
  Watchr.options.debug = true
22
- capture_io { Watchr.debug('abc') }.stdout.should be("[watchr debug] abc\n")
22
+ assert_equal "[watchr debug] abc\n", capture_io { Watchr.debug('abc') }.first
23
23
  end
24
24
 
25
25
  test "picking handler" do
26
26
 
27
+ if Watchr::HAVE_REV
28
+
27
29
  Watchr.handler = nil
28
30
  ENV['HANDLER'] = 'linux'
29
- Watchr.handler.should be(Watchr::HAVE_REV ? Watchr::EventHandler::Unix : Watchr::EventHandler::Portable)
31
+ assert_equal Watchr::EventHandler::Unix, Watchr.handler
30
32
 
31
33
  Watchr.handler = nil
32
34
  ENV['HANDLER'] = 'bsd'
33
- Watchr.handler.should be(Watchr::HAVE_REV ? Watchr::EventHandler::Unix : Watchr::EventHandler::Portable)
35
+ assert_equal Watchr::EventHandler::Unix, Watchr.handler
34
36
 
35
37
  Watchr.handler = nil
36
38
  ENV['HANDLER'] = 'darwin'
37
- Watchr.handler.should be(Watchr::HAVE_REV ? Watchr::EventHandler::Unix : Watchr::EventHandler::Portable)
39
+ assert_equal Watchr::EventHandler::Unix, Watchr.handler
38
40
 
39
41
  Watchr.handler = nil
40
42
  ENV['HANDLER'] = 'unix'
41
- Watchr.handler.should be(Watchr::HAVE_REV ? Watchr::EventHandler::Unix : Watchr::EventHandler::Portable)
43
+ assert_equal Watchr::EventHandler::Unix, Watchr.handler
44
+
45
+ end
42
46
 
43
47
  Watchr.handler = nil
44
48
  ENV['HANDLER'] = 'mswin'
45
- Watchr.handler.should be(Watchr::EventHandler::Portable)
49
+ assert_equal Watchr::EventHandler::Portable, Watchr.handler
46
50
 
47
51
  Watchr.handler = nil
48
52
  ENV['HANDLER'] = 'cygwin'
49
- Watchr.handler.should be(Watchr::EventHandler::Portable)
53
+ assert_equal Watchr::EventHandler::Portable, Watchr.handler
50
54
 
51
55
  Watchr.handler = nil
52
56
  ENV['HANDLER'] = 'portable'
53
- Watchr.handler.should be(Watchr::EventHandler::Portable)
57
+ assert_equal Watchr::EventHandler::Portable, Watchr.handler
54
58
 
55
59
  Watchr.handler = nil
56
60
  ENV['HANDLER'] = 'other'
57
- Watchr.handler.should be(Watchr::EventHandler::Portable)
61
+ assert_equal Watchr::EventHandler::Portable, Watchr.handler
58
62
  end
59
63
  end
60
64
 
@@ -17,9 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.version = Watchr::VERSION
18
18
  s.files = File.read("Manifest").strip.split("\n")
19
19
 
20
+ s.add_development_dependency 'minitest'
20
21
  s.add_development_dependency 'mocha'
21
- s.add_development_dependency 'jeremymcanally-matchy'
22
- s.add_development_dependency 'jeremymcanally-pending'
23
- s.add_development_dependency 'mynyml-every'
24
- s.add_development_dependency 'mynyml-redgreen'
22
+ s.add_development_dependency 'every' #http://gemcutter.org/gems/every
25
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watchr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - mynyml
@@ -9,21 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-12 00:00:00 -05:00
12
+ date: 2009-11-25 00:00:00 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: mocha
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: jeremymcanally-matchy
16
+ name: minitest
27
17
  type: :development
28
18
  version_requirement:
29
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -33,17 +23,7 @@ dependencies:
33
23
  version: "0"
34
24
  version:
35
25
  - !ruby/object:Gem::Dependency
36
- name: jeremymcanally-pending
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
45
- - !ruby/object:Gem::Dependency
46
- name: mynyml-every
26
+ name: mocha
47
27
  type: :development
48
28
  version_requirement:
49
29
  version_requirements: !ruby/object:Gem::Requirement
@@ -53,7 +33,7 @@ dependencies:
53
33
  version: "0"
54
34
  version:
55
35
  - !ruby/object:Gem::Dependency
56
- name: mynyml-redgreen
36
+ name: every
57
37
  type: :development
58
38
  version_requirement:
59
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -79,6 +59,7 @@ files:
79
59
  - Rakefile
80
60
  - TODO.txt
81
61
  - bin/watchr
62
+ - contributions.txt
82
63
  - docs.watchr
83
64
  - gem.watchr
84
65
  - lib/watchr.rb
@@ -87,7 +68,6 @@ files:
87
68
  - lib/watchr/event_handlers/portable.rb
88
69
  - lib/watchr/event_handlers/unix.rb
89
70
  - lib/watchr/script.rb
90
- - manifest.watchr
91
71
  - specs.watchr
92
72
  - test/README
93
73
  - test/event_handlers/test_base.rb
@@ -1,70 +0,0 @@
1
- # Run me with:
2
- #
3
- # $ watchr manifest.watchr
4
- #
5
- # This script will remove a file from from the Manifest when it gets deleted,
6
- # and will rebuild the Manifest on Ctrl-\
7
- #
8
- # Mostly serves as a demo for the :delete event type (and eventually for the
9
- # :added event type). In reality this is much better implemented as a git
10
- # post-commit script.
11
- #
12
-
13
- require 'pathname'
14
- # --------------------------------------------------
15
- # Helpers
16
- # --------------------------------------------------
17
- module Project
18
- extend self
19
- def files
20
- `git ls-files --full-name`.strip.split($/).sort
21
- end
22
- end
23
-
24
- class Manifest
25
- attr_accessor :path
26
-
27
- def initialize(path)
28
- @path = Pathname(path).expand_path
29
- create!
30
- end
31
-
32
- def remove(path)
33
- paths = @path.read.strip.split($/)
34
- @path.open('w') {|f| f << (paths - [path]).join("\n") }
35
- end
36
-
37
- def add(path)
38
- paths = @path.read.strip.split($/)
39
- @path.open('w') {|f| f << paths.push(path).sort.join("\n") }
40
- end
41
-
42
- private
43
- def create!
44
- File.open(@path.to_s, 'w') {} unless @path.exist?
45
- end
46
- end
47
-
48
-
49
- @manifest = Manifest.new('Manifest')
50
-
51
- # --------------------------------------------------
52
- # Watchr Rules
53
- # --------------------------------------------------
54
- watch('.*', :deleted ) do |md|
55
- @manifest.remove(md[0])
56
- puts "removed #{md[0].inspect} from Manifest"
57
- end
58
-
59
- # --------------------------------------------------
60
- # Signal Handling
61
- # --------------------------------------------------
62
- # Ctrl-\
63
- Signal.trap('QUIT') do
64
- puts " --- Updated Manifest ---\n"
65
- @manifest.path.open('w') {|m| m << Project.files.join("\n").strip }
66
- end
67
-
68
- # Ctrl-C
69
- Signal.trap('INT') { abort("\n") }
70
-