watchr 0.5.9 → 0.6

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/specs.watchr CHANGED
@@ -1,38 +1,37 @@
1
1
  # Run me with:
2
- #
3
2
  # $ watchr specs.watchr
4
3
 
5
4
  # --------------------------------------------------
6
- # Helpers
5
+ # Rules
7
6
  # --------------------------------------------------
8
- def run(cmd)
9
- puts(cmd)
10
- system(cmd)
11
- end
12
-
13
- def run_all_tests
14
- # see Rakefile for the definition of the test:all task
15
- system( "rake -s test:all VERBOSE=true" )
16
- end
7
+ watch( '^test.*/test_.*\.rb' ) { |m| ruby m[0] }
8
+ watch( '^lib/(.*)\.rb' ) { |m| ruby "test/test_#{m[1]}.rb" }
9
+ watch( '^lib/watchr/(.*)\.rb' ) { |m| ruby "test/test_#{m[1]}.rb" }
10
+ watch( '^lib/watchr/event_handlers/(.*)\.rb' ) { |m| ruby "test/event_handlers/test_#{m[1]}.rb" }
11
+ watch( '^test/test_helper\.rb' ) { ruby tests }
17
12
 
18
13
  # --------------------------------------------------
19
- # Watchr Rules
14
+ # Signal Handling
20
15
  # --------------------------------------------------
21
- watch( '^test.*/test_.*\.rb' ) { |m| run( "ruby -rubygems -I.:lib %s" % m[0] ) }
22
- watch( '^lib/(.*)\.rb' ) { |m| run( "ruby -rubygems -I.:lib test/test_%s.rb" % m[1] ) }
23
- watch( '^lib/watchr/(.*)\.rb' ) { |m| run( "ruby -rubygems -I.:lib test/test_%s.rb" % m[1] ) }
24
- watch( '^lib/watchr/event_handlers/(.*)\.rb' ) { |m| run( "ruby -rubygems -I.:lib test/event_handlers/test_%s.rb" % m[1] ) }
25
- watch( '^test/test_helper\.rb' ) { run_all_tests }
16
+ Signal.trap('QUIT') { ruby tests } # Ctrl-\
17
+ Signal.trap('INT' ) { abort("\n") } # Ctrl-C
26
18
 
27
19
  # --------------------------------------------------
28
- # Signal Handling
20
+ # Helpers
29
21
  # --------------------------------------------------
30
- # Ctrl-\
31
- Signal.trap('QUIT') do
32
- puts " --- Running all tests ---\n\n"
33
- run_all_tests
22
+ def ruby(*paths)
23
+ run "ruby #{gem_opt} -I.:lib:test -e'%w( #{paths.flatten.join(' ')} ).each {|p| require p }'"
34
24
  end
35
25
 
36
- # Ctrl-C
37
- Signal.trap('INT') { abort("\n") }
26
+ def tests
27
+ Dir['test/**/test_*.rb'] - ['test/test_helper.rb']
28
+ end
38
29
 
30
+ def run( cmd )
31
+ puts cmd
32
+ system cmd
33
+ end
34
+
35
+ def gem_opt
36
+ defined?(Gem) ? "-rubygems" : ""
37
+ end
data/watchr.gemspec CHANGED
@@ -8,9 +8,6 @@ Gem::Specification.new do |s|
8
8
  s.email = "mynyml@gmail.com"
9
9
  s.homepage = "http://mynyml.com/ruby/flexible-continuous-testing"
10
10
  s.rubyforge_project = "watchr"
11
- s.has_rdoc = true
12
- s.rdoc_options = %w( --main README.rdoc )
13
- s.extra_rdoc_files = %w( README.rdoc )
14
11
  s.require_path = "lib"
15
12
  s.bindir = "bin"
16
13
  s.executables = "watchr"
@@ -19,5 +16,5 @@ Gem::Specification.new do |s|
19
16
 
20
17
  s.add_development_dependency 'minitest'
21
18
  s.add_development_dependency 'mocha'
22
- s.add_development_dependency 'every' #http://gemcutter.org/gems/every
19
+ s.add_development_dependency 'every'
23
20
  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.9
4
+ version: "0.6"
5
5
  platform: ruby
6
6
  authors:
7
7
  - mynyml
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-25 00:00:00 -03:00
12
+ date: 2010-02-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -48,16 +48,16 @@ executables:
48
48
  - watchr
49
49
  extensions: []
50
50
 
51
- extra_rdoc_files:
52
- - README.rdoc
51
+ extra_rdoc_files: []
52
+
53
53
  files:
54
54
  - .gitignore
55
55
  - History.txt
56
56
  - LICENSE
57
57
  - Manifest
58
- - README.rdoc
58
+ - README.md
59
59
  - Rakefile
60
- - TODO.txt
60
+ - TODO.md
61
61
  - bin/watchr
62
62
  - contributions.txt
63
63
  - docs.watchr
@@ -83,9 +83,8 @@ homepage: http://mynyml.com/ruby/flexible-continuous-testing
83
83
  licenses: []
84
84
 
85
85
  post_install_message:
86
- rdoc_options:
87
- - --main
88
- - README.rdoc
86
+ rdoc_options: []
87
+
89
88
  require_paths:
90
89
  - lib
91
90
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.rdoc DELETED
@@ -1,104 +0,0 @@
1
- === Summary
2
-
3
- Agile development tool that monitors a directory tree, and triggers a user
4
- defined action whenever an observed file is modified. Its most typical use is
5
- continuous testing, and as such it is a more flexible alternative to autotest.
6
-
7
-
8
- === Features
9
-
10
- watchr is:
11
-
12
- * Simple to use
13
- * Highly flexible
14
- * Evented ( Listens for filesystem events with native c libs )
15
- * Portable ( Linux, *BSD, OSX, Solaris, Windows )
16
- * Fast ( Immediately reacts to file changes )
17
-
18
- Most importantly it allows running tests in an environment that is *agnostic* to:
19
-
20
- * Web frameworks ( rails, merb, sinatra, camping, invisible, ... )
21
- * Test frameworks ( test/unit, minitest, rspec, test/spec, expectations, ... )
22
- * Ruby interpreters ( ruby1.8, ruby1.9, MRI, JRuby, Rubinius, ... )
23
- * Package frameworks ( rubygems, rip, ... )
24
-
25
-
26
- === Usage
27
-
28
- On the command line,
29
-
30
- $ watchr path/to/script.file
31
-
32
- will monitor files in the current directory tree, and react to events on those
33
- files in accordance with the script.
34
-
35
-
36
- === Scripts
37
-
38
- The script contains a set of simple rules that map observed files to an action.
39
- Its DSL is a single method: watch(pattern, &action)
40
-
41
- watch( 'a regexp pattern matching paths to observe' ) {|match_data_object| command_to_run }
42
-
43
- So for example,
44
-
45
- watch( 'test/test_.*\.rb' ) {|md| system("ruby #{md[0]}") }
46
-
47
- will match any test file and run it whenever it is saved.
48
-
49
- A continuous testing script for a basic project could be
50
-
51
- watch( 'test/test_.*\.rb' ) {|md| system("ruby #{md[0]}") }
52
- watch( 'lib/(.*)\.rb' ) {|md| system("ruby test/test_#{md[1]}.rb") }
53
-
54
- which, in addition to running any saved test file as above, will also run a
55
- lib file's associated test. This mimics the equivalent autotest behaviour.
56
-
57
- It's easy to see why watchr is so flexible, since the whole command is custom.
58
- The above actions could just as easily call "jruby", "ruby --rubygems", "ruby
59
- -Ilib", "specrb", "rbx", ... or any combination of these. For the sake of
60
- comparison, autotest runs with:
61
-
62
- /usr/bin/ruby1.8 -I.:lib:test -rubygems -e "%w[test/unit test/test_helper.rb test/test_watchr.rb].each { |f| require f }"
63
-
64
- locking the environment into ruby1.8, rubygems and test/unit for all tests.
65
-
66
- And remember the scripts are pure ruby, so feel free to add methods,
67
- Signal#trap calls, etc. Updates to script files are picked up on the fly (no
68
- need to restart watchr) so experimenting is painless.
69
-
70
- The wiki[http://wiki.github.com/mynyml/watchr] has more details and examples.
71
- You might also want to take a look at watchr's own scripts,
72
- specs.watchr[http://github.com/mynyml/watchr/blob/master/specs.watchr],
73
- docs.watchr[http://github.com/mynyml/watchr/blob/master/docs.watchr] and
74
- gem.watchr[http://github.com/mynyml/watchr/blob/master/gem.watchr], to get you
75
- started.
76
-
77
-
78
- === Install
79
-
80
- gem install watchr --source http://gemcutter.org
81
-
82
- If you're on *nix and have the rev[http://github.com/tarcieri/rev/] gem
83
- installed, Watchr will detect it and use it automatically. This will make
84
- Watchr evented.
85
-
86
- gem install rev
87
-
88
-
89
- === See Also
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.
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
95
-
96
-
97
- === Links
98
-
99
- source:: http://github.com/mynyml/watchr
100
- docs:: http://docs.github.com/mynyml/watchr
101
- wiki:: http://wiki.github.com/mynyml/watchr
102
- bugs:: http://github.com/mynyml/watchr/issues
103
- group:: http://groups.google.com/group/watchr
104
-
data/TODO.txt DELETED
@@ -1,40 +0,0 @@
1
-
2
- * 1.9 compatibility
3
-
4
- * sometimes an action is fired without a file being saved
5
- * buffer flushing issue?
6
- * libev issue?
7
- * probably fixed with event type handling update, which ignores atime
8
- updates by defaults
9
-
10
- * when a file is saved twice quickly, subsequent events are ignored.
11
- * seems like rev/libev drops the file watch
12
-
13
- * test on other platforms
14
- x mswin
15
- x cygwin
16
- * bsd
17
- * osx
18
- * solaris
19
-
20
- * write a few prepackaged scripts
21
- * post on gists
22
- * post links on wiki
23
- * post main links in readme
24
-
25
- * eval script within own context?
26
- * use case: using <tt>path</tt> within script accesses Script#path
27
-
28
- * respond to different file events?
29
- * modified
30
- * created
31
- * deleted
32
- * etc.
33
- * watch(pattern, EVENT, &action)
34
- * use case: a script updates a manifest file when a file is deleted
35
-
36
- * memory profiling / benchmarks
37
-
38
- * version.watchr
39
- * sync versions (gemspec & Watchr::VERSION)
40
-