mynyml-watchr 0.3.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +46 -24
- data/Rakefile +10 -55
- data/TODO.txt +30 -26
- data/bin/watchr +9 -6
- data/docs.watchr +26 -0
- data/lib/watchr.rb +62 -123
- data/lib/watchr/controller.rb +79 -0
- data/lib/watchr/event_handlers/base.rb +48 -0
- data/lib/watchr/event_handlers/portable.rb +55 -0
- data/lib/watchr/event_handlers/unix.rb +62 -0
- data/lib/watchr/script.rb +192 -0
- data/lib/watchr/version.rb +4 -4
- data/specs.watchr +21 -12
- data/test/event_handlers/test_base.rb +24 -0
- data/test/event_handlers/test_portable.rb +58 -0
- data/test/event_handlers/test_unix.rb +56 -0
- data/test/test_controller.rb +104 -0
- data/test/test_helper.rb +20 -37
- data/test/test_script.rb +88 -0
- data/test/test_watchr.rb +32 -155
- data/watchr.gemspec +61 -70
- metadata +99 -29
- data/rdoc.watchr +0 -15
- data/yard.watchr +0 -18
data/test/test_watchr.rb
CHANGED
@@ -8,175 +8,52 @@ class TestWatchr < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
## options
|
10
10
|
|
11
|
-
test "debug" do
|
11
|
+
test "debug option" do
|
12
12
|
Watchr.options.debug.should be(false)
|
13
13
|
Watchr.options.debug = true
|
14
14
|
Watchr.options.debug.should be(true)
|
15
15
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class TestScript < Test::Unit::TestCase
|
19
|
-
include Watchr
|
20
|
-
|
21
|
-
## api
|
22
|
-
|
23
|
-
test "watch" do
|
24
|
-
script = Script.new
|
25
|
-
script.watch('pattern') { nil }
|
26
|
-
|
27
|
-
script.map.first[0].should be('pattern')
|
28
|
-
script.map.first[1].call.should be(nil)
|
29
|
-
end
|
30
|
-
|
31
|
-
test "default action" do
|
32
|
-
script = Script.new
|
33
|
-
script.default_action { nil }
|
34
|
-
script.watch('pattern')
|
35
|
-
|
36
|
-
script.map.first[0].should be('pattern')
|
37
|
-
script.map.first[1].call.should be(nil)
|
38
|
-
end
|
39
|
-
|
40
|
-
test "automatically picks up changes to script file" do
|
41
|
-
file = Fixture.create('script.watchr', "watch('abc')")
|
42
|
-
script = Script.new(file)
|
43
|
-
script.changed?.should be(false)
|
44
|
-
|
45
|
-
script.stubs(:reference_time).returns(Time.now - 10) #mock sleep
|
46
|
-
|
47
|
-
Fixture.create('script.watchr', "watch('def')")
|
48
|
-
script.changed?.should be(true)
|
49
|
-
end
|
50
|
-
|
51
|
-
test "reparses script file" do
|
52
|
-
file = Fixture.create('script.watchr', "watch('abc')")
|
53
|
-
script = Script.new(file)
|
54
|
-
script.map.first.should include('abc')
|
55
|
-
script.map.first.should exclude('def')
|
56
|
-
|
57
|
-
script.stubs(:reference_time).returns(Time.now - 10) #mock sleep
|
58
|
-
Fixture.create('script.watchr', "watch('def')")
|
59
|
-
script.parse!
|
60
|
-
script.map.first.should include('def')
|
61
|
-
script.map.first.should exclude('abc')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class TestRunner < Test::Unit::TestCase
|
66
|
-
include Watchr
|
67
|
-
|
68
|
-
def teardown
|
69
|
-
Fixture.delete_all
|
70
|
-
Watchr.options = nil
|
71
|
-
end
|
72
16
|
|
73
|
-
|
74
|
-
file_a = Fixture.create('a.rb')
|
75
|
-
file_b = Fixture.create('b.rb')
|
76
|
-
script = Script.new
|
77
|
-
script.watch(file_a.pattern) { 'ohaie' }
|
78
|
-
script.watch(file_b.pattern) { 'kthnx' }
|
17
|
+
## functionality
|
79
18
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
runner.map[file_b.rel][1].call.should be('kthnx')
|
85
|
-
end
|
86
|
-
|
87
|
-
test "latest mtime" do
|
88
|
-
file_a = Fixture.create('a.rb')
|
89
|
-
file_b = Fixture.create('b.rb')
|
90
|
-
script = Script.new
|
91
|
-
script.watch(file_a.pattern) { 'ohaie' }
|
92
|
-
script.watch(file_b.pattern) { 'kthnx' }
|
93
|
-
|
94
|
-
runner = Runner.new(script)
|
95
|
-
file_a.touch
|
96
|
-
|
97
|
-
runner.last_updated_file.rel.should be(file_a.rel)
|
98
|
-
end
|
99
|
-
|
100
|
-
test "monitors file changes" do
|
101
|
-
file_a = Fixture.create('a.rb')
|
102
|
-
script = Script.new
|
103
|
-
script.watch(file_a.pattern) { nil }
|
104
|
-
|
105
|
-
runner = Runner.new(script)
|
106
|
-
runner.changed?.should be(false)
|
107
|
-
|
108
|
-
# fake Kernel.sleep(2)
|
109
|
-
file_a.mtime = Time.now - 2
|
110
|
-
runner.init_time = Time.now - 2
|
111
|
-
|
112
|
-
file_a.touch
|
113
|
-
runner.changed?.should be(true)
|
114
|
-
end
|
115
|
-
|
116
|
-
test "calls action corresponding to file changed" do
|
117
|
-
script = Script.new
|
118
|
-
script.watch(Fixture.create.pattern) { throw(:ohaie) }
|
119
|
-
|
120
|
-
runner = Runner.new(script)
|
121
|
-
runner.init_time = Time.now - 2
|
122
|
-
runner.changed?
|
123
|
-
assert_throws(:ohaie) do
|
124
|
-
runner.instance_eval { call_action! }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
test "passes match data to action" do
|
129
|
-
file_a = Fixture.create('a.rb')
|
130
|
-
script = Script.new
|
131
|
-
pattern = Fixture::DIR.join('(.*)\.(.*)$').rel
|
132
|
-
script.watch((pattern)) {|md| [md[1], md[2]].join('|') }
|
133
|
-
|
134
|
-
runner = Runner.new(script)
|
135
|
-
runner.init_time = Time.now - 2
|
136
|
-
file_a.touch
|
137
|
-
runner.changed?
|
138
|
-
runner.instance_eval { call_action! }.should be('a|rb')
|
19
|
+
test "debug" do
|
20
|
+
capture_io { Watchr.debug('abc') }.stdout.should be('')
|
21
|
+
Watchr.options.debug = true
|
22
|
+
capture_io { Watchr.debug('abc') }.stdout.should be("[watchr debug] abc\n")
|
139
23
|
end
|
140
24
|
|
141
|
-
test "
|
142
|
-
|
143
|
-
|
144
|
-
|
25
|
+
test "picking handler" do
|
26
|
+
Watchr.handler = nil
|
27
|
+
ENV['HANDLER'] = 'linux'
|
28
|
+
Watchr.handler.should be(Watchr::EventHandler::Unix)
|
145
29
|
|
146
|
-
|
147
|
-
|
148
|
-
|
30
|
+
Watchr.handler = nil
|
31
|
+
ENV['HANDLER'] = 'bsd'
|
32
|
+
Watchr.handler.should be(Watchr::EventHandler::Unix)
|
149
33
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
script = Script.new
|
154
|
-
script.watch('fix_a\.rb') { throw(:ohaie) }
|
155
|
-
script.watch('fix_.*\.rb') { throw(:kkthx) }
|
34
|
+
Watchr.handler = nil
|
35
|
+
ENV['HANDLER'] = 'darwin'
|
36
|
+
Watchr.handler.should be(Watchr::EventHandler::Unix)
|
156
37
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
runner.changed?
|
161
|
-
assert_throws(:kkthx) do
|
162
|
-
runner.instance_eval { call_action! }
|
163
|
-
end
|
164
|
-
end
|
38
|
+
Watchr.handler = nil
|
39
|
+
ENV['HANDLER'] = 'unix'
|
40
|
+
Watchr.handler.should be(Watchr::EventHandler::Unix)
|
165
41
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
script = Fixture.create('script.watchr', "watch('aaa')")
|
42
|
+
Watchr.handler = nil
|
43
|
+
ENV['HANDLER'] = 'mswin'
|
44
|
+
Watchr.handler.should be(Watchr::EventHandler::Portable)
|
170
45
|
|
171
|
-
|
172
|
-
|
46
|
+
Watchr.handler = nil
|
47
|
+
ENV['HANDLER'] = 'cygwin'
|
48
|
+
Watchr.handler.should be(Watchr::EventHandler::Portable)
|
173
49
|
|
174
|
-
|
175
|
-
|
50
|
+
Watchr.handler = nil
|
51
|
+
ENV['HANDLER'] = 'portable'
|
52
|
+
Watchr.handler.should be(Watchr::EventHandler::Portable)
|
176
53
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
assert runner.paths.first.match('bbb')
|
54
|
+
Watchr.handler = nil
|
55
|
+
ENV['HANDLER'] = 'other'
|
56
|
+
Watchr.handler.should be(Watchr::EventHandler::Portable)
|
181
57
|
end
|
182
58
|
end
|
59
|
+
|
data/watchr.gemspec
CHANGED
@@ -1,71 +1,62 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
name: watchr
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0
|
5
|
-
platform: ruby
|
6
|
-
authors:
|
7
|
-
- Martin Aumont
|
8
|
-
autorequire:
|
9
|
-
bindir: bin
|
10
|
-
cert_chain: []
|
11
|
-
|
12
|
-
date: 2009-08-26 00:00:00 -04:00
|
13
|
-
default_executable:
|
14
|
-
dependencies: []
|
15
|
-
|
16
|
-
description: Continious anything; project files observer/trigger.
|
17
|
-
email: mynyml@gmail.com
|
18
|
-
executables:
|
19
|
-
- watchr
|
20
|
-
extensions: []
|
21
|
-
|
22
|
-
extra_rdoc_files: []
|
23
|
-
|
24
|
-
files:
|
25
|
-
- Rakefile
|
26
|
-
- test
|
27
|
-
- test/test_watchr.rb
|
28
|
-
- test/test_helper.rb
|
29
|
-
- TODO.txt
|
30
|
-
- bin
|
31
|
-
- bin/watchr
|
32
|
-
- lib
|
33
|
-
- lib/watchr
|
34
|
-
- lib/watchr/version.rb
|
35
|
-
- lib/watchr.rb
|
36
|
-
- README.rdoc
|
37
|
-
- LICENSE
|
38
|
-
- yard.watchr
|
39
|
-
- rdoc.watchr
|
40
|
-
- specs.watchr
|
41
|
-
- watchr.gemspec
|
42
|
-
has_rdoc: true
|
43
|
-
homepage: ""
|
44
|
-
licenses: []
|
45
|
-
|
46
|
-
post_install_message:
|
47
|
-
rdoc_options: []
|
48
|
-
|
49
|
-
require_paths:
|
50
|
-
- lib
|
51
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: "0"
|
56
|
-
version:
|
57
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: "0"
|
62
|
-
version:
|
63
|
-
requirements: []
|
64
|
-
|
65
|
-
rubyforge_project:
|
66
|
-
rubygems_version: 1.3.5
|
67
|
-
signing_key:
|
68
|
-
specification_version: 3
|
69
|
-
summary: Continious anything
|
70
|
-
test_files: []
|
71
1
|
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'watchr'
|
4
|
+
s.version = '0.5.2'
|
5
|
+
s.date = '2009-09-17'
|
6
|
+
s.summary = "Modern continious testing (flexible alternative to autotest)"
|
7
|
+
s.description = "Modern continious testing (flexible alternative to autotest)."
|
8
|
+
s.author = "mynyml"
|
9
|
+
s.email = 'mynyml@gmail.com'
|
10
|
+
s.homepage = 'http://mynyml.com/ruby/flexible-continuous-testing'
|
11
|
+
s.has_rdoc = true
|
12
|
+
s.rdoc_options = %w( --main README.rdoc )
|
13
|
+
s.extra_rdoc_files = %w( README.rdoc )
|
14
|
+
s.require_path = "lib"
|
15
|
+
s.bindir = "bin"
|
16
|
+
s.executables = "watchr"
|
17
|
+
s.files = %w[
|
18
|
+
README.rdoc
|
19
|
+
LICENSE
|
20
|
+
TODO.txt
|
21
|
+
Rakefile
|
22
|
+
bin/watchr
|
23
|
+
lib/watchr.rb
|
24
|
+
lib/watchr/version.rb
|
25
|
+
lib/watchr/script.rb
|
26
|
+
lib/watchr/controller.rb
|
27
|
+
lib/watchr/event_handlers/base.rb
|
28
|
+
lib/watchr/event_handlers/unix.rb
|
29
|
+
lib/watchr/event_handlers/portable.rb
|
30
|
+
test/test_helper.rb
|
31
|
+
test/test_watchr.rb
|
32
|
+
test/test_script.rb
|
33
|
+
test/test_controller.rb
|
34
|
+
test/event_handlers/test_base.rb
|
35
|
+
test/event_handlers/test_unix.rb
|
36
|
+
test/event_handlers/test_portable.rb
|
37
|
+
specs.watchr
|
38
|
+
docs.watchr
|
39
|
+
watchr.gemspec
|
40
|
+
]
|
41
|
+
s.test_files = %w[
|
42
|
+
test/test_helper.rb
|
43
|
+
test/test_watchr.rb
|
44
|
+
test/test_script.rb
|
45
|
+
test/test_controller.rb
|
46
|
+
test/event_handlers/test_base.rb
|
47
|
+
test/event_handlers/test_unix.rb
|
48
|
+
test/event_handlers/test_portable.rb
|
49
|
+
]
|
50
|
+
|
51
|
+
#require 'rbconfig'
|
52
|
+
#unless Config::CONFIG['host_os'] =~ /mswin|windows|cygwin/i
|
53
|
+
unless RUBY_PLATFORM =~ /mswin|windows|cygwin/i
|
54
|
+
s.add_dependency 'rev', '>= 0.3.0'
|
55
|
+
end
|
56
|
+
|
57
|
+
s.add_development_dependency 'mocha'
|
58
|
+
s.add_development_dependency 'jeremymcanally-matchy'
|
59
|
+
s.add_development_dependency 'jeremymcanally-pending'
|
60
|
+
s.add_development_dependency 'mynyml-every'
|
61
|
+
s.add_development_dependency 'mynyml-redgreen'
|
62
|
+
end
|
metadata
CHANGED
@@ -1,51 +1,115 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mynyml-watchr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- mynyml
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rev
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.3.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mocha
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jeremymcanally-matchy
|
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: jeremymcanally-pending
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mynyml-every
|
57
|
+
type: :development
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: mynyml-redgreen
|
67
|
+
type: :development
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
description: Modern continious testing (flexible alternative to autotest).
|
17
76
|
email: mynyml@gmail.com
|
18
77
|
executables:
|
19
78
|
- watchr
|
20
79
|
extensions: []
|
21
80
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
81
|
+
extra_rdoc_files:
|
82
|
+
- README.rdoc
|
24
83
|
files:
|
25
|
-
-
|
26
|
-
-
|
27
|
-
- test/test_watchr.rb
|
28
|
-
- test/test_helper.rb
|
84
|
+
- README.rdoc
|
85
|
+
- LICENSE
|
29
86
|
- TODO.txt
|
30
|
-
-
|
87
|
+
- Rakefile
|
31
88
|
- bin/watchr
|
32
|
-
- lib
|
33
|
-
- lib/watchr
|
34
|
-
- lib/watchr/version.rb
|
35
89
|
- lib/watchr.rb
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
90
|
+
- lib/watchr/version.rb
|
91
|
+
- lib/watchr/script.rb
|
92
|
+
- lib/watchr/controller.rb
|
93
|
+
- lib/watchr/event_handlers/base.rb
|
94
|
+
- lib/watchr/event_handlers/unix.rb
|
95
|
+
- lib/watchr/event_handlers/portable.rb
|
96
|
+
- test/test_helper.rb
|
97
|
+
- test/test_watchr.rb
|
98
|
+
- test/test_script.rb
|
99
|
+
- test/test_controller.rb
|
100
|
+
- test/event_handlers/test_base.rb
|
101
|
+
- test/event_handlers/test_unix.rb
|
102
|
+
- test/event_handlers/test_portable.rb
|
40
103
|
- specs.watchr
|
104
|
+
- docs.watchr
|
41
105
|
- watchr.gemspec
|
42
106
|
has_rdoc: true
|
43
|
-
homepage:
|
44
|
-
licenses:
|
45
|
-
|
107
|
+
homepage: http://mynyml.com/ruby/flexible-continuous-testing
|
108
|
+
licenses:
|
46
109
|
post_install_message:
|
47
|
-
rdoc_options:
|
48
|
-
|
110
|
+
rdoc_options:
|
111
|
+
- --main
|
112
|
+
- README.rdoc
|
49
113
|
require_paths:
|
50
114
|
- lib
|
51
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -65,7 +129,13 @@ requirements: []
|
|
65
129
|
rubyforge_project:
|
66
130
|
rubygems_version: 1.3.5
|
67
131
|
signing_key:
|
68
|
-
specification_version:
|
69
|
-
summary:
|
70
|
-
test_files:
|
71
|
-
|
132
|
+
specification_version: 2
|
133
|
+
summary: Modern continious testing (flexible alternative to autotest)
|
134
|
+
test_files:
|
135
|
+
- test/test_helper.rb
|
136
|
+
- test/test_watchr.rb
|
137
|
+
- test/test_script.rb
|
138
|
+
- test/test_controller.rb
|
139
|
+
- test/event_handlers/test_base.rb
|
140
|
+
- test/event_handlers/test_unix.rb
|
141
|
+
- test/event_handlers/test_portable.rb
|