rerun 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,13 +5,13 @@
5
5
  Launches your app, then watches the filesystem. If a relevant file
6
6
  changes, then it restarts your app.
7
7
 
8
- By default only *.{rb,js,css,erb,ru} files are watched. Use the
8
+ By default only *.{rb,js,css,scss,sass,erb,html,haml,ru} files are watched. Use the
9
9
  `--pattern` option if you want to change this.
10
10
 
11
11
  If you're on Mac OS X, and using the built-in ruby,
12
12
  it uses the built-in facilities for monitoring
13
- the filesystem, so CPU use is very light. And if you have "growlnotify"
14
- available on the PATH, it sends notifications to growl in addition to
13
+ the filesystem, so CPU use is very light. And if you have `growlnotify`
14
+ available on the `PATH`, it sends notifications to growl in addition to
15
15
  the console. Here's how to install
16
16
  [growlnotify](http://growl.info/extras.php#growlnotify):
17
17
 
@@ -61,15 +61,19 @@ Rackup can also be used to launch a Rack server, so let's try that:
61
61
  --pattern glob to match inside directory. This uses the Ruby Dir glob style -- see <http://www.ruby-doc.org/core/classes/Dir.html#M002322> for details.
62
62
  By default it watches these files: `rb,js,css,scss,sass,erb,html,haml,ru`.
63
63
 
64
+ --clear (or -c) clear the screen before each run
65
+
66
+ --exit (or -x) expect the program to exit. With this option, rerun checks the return value; without it, rerun checks that the process is running.
67
+
64
68
  Also --version and --help.
65
69
 
66
70
  # To Do:
67
71
 
72
+ * Cooldown (so if a dozen files appear in a burst, say from 'git pull', it only restarts once)
68
73
  * If the last element of the command is a `.ru` file and there's no other command then use `rackup`
69
74
  * Allow arbitrary sets of directories and file types, possibly with "include" and "exclude" sets
70
75
  * ".rerun" file to specify options per project or in $HOME.
71
76
  * Test on Linux.
72
- * Test on Mac without Growlnotify.
73
77
  * Merge with Kicker (using it as a library and writing a Rerun recipe) or Watchr
74
78
  * On OS X, use a C library using growl's developer API <http://growl.info/developer/>
75
79
 
data/bin/rerun CHANGED
@@ -30,6 +30,14 @@ opts = OptionParser.new("", 24, ' ') { |opts|
30
30
  options[:pattern] = pattern
31
31
  end
32
32
 
33
+ opts.on("-c", "--clear", "clear screen before each run") do
34
+ options[:clear] = true
35
+ end
36
+
37
+ opts.on("-x", "--exit", "expect the program to exit. With this option, rerun checks the return value; without it, rerun checks that the process is running.") do |dir|
38
+ options[:exit] = true
39
+ end
40
+
33
41
  opts.on_tail("-h", "--help", "--usage", "show this message") do
34
42
  puts opts
35
43
  exit
data/lib/rerun/runner.rb CHANGED
@@ -22,6 +22,14 @@ module Rerun
22
22
  def pattern
23
23
  @options[:pattern] || DEFAULT_PATTERN
24
24
  end
25
+
26
+ def clear?
27
+ @options[:clear]
28
+ end
29
+
30
+ def exit?
31
+ @options[:exit]
32
+ end
25
33
 
26
34
  def start
27
35
  if windows?
@@ -33,16 +41,20 @@ module Rerun
33
41
  "To infinity... and beyond!",
34
42
  "Charge!",
35
43
  ]
36
- notify "Launched", taglines[rand(taglines.size)]
44
+ notify "launched", taglines[rand(taglines.size)]
37
45
  @already_running = true
38
46
  else
39
47
  taglines = [
40
48
  "Here we go again!",
49
+ "Keep on trucking.",
41
50
  "Once more unto the breach, dear friends, once more!",
51
+ "The road goes ever on and on, down from the door where it began.",
42
52
  ]
43
- notify "Restarted", taglines[rand(taglines.size)]
53
+ notify "restarted", taglines[rand(taglines.size)]
44
54
  end
45
55
 
56
+ print "\033[H\033[2J" if clear? # see http://ascii-table.com/ansi-escape-sequences-vt-100.php
57
+
46
58
  @pid = Kernel.fork do
47
59
  begin
48
60
  # Signal.trap("INT") { exit }
@@ -52,13 +64,13 @@ module Rerun
52
64
  exit
53
65
  end
54
66
  end
55
- Process.detach(@pid) # so if the child exits, it dies
67
+ status_thread = Process.detach(@pid) # so if the child exits, it dies
56
68
 
57
69
  Signal.trap("INT") do # INT = control-C
58
70
  stop # first stop the child
59
71
  exit
60
72
  end
61
-
73
+
62
74
  begin
63
75
  sleep 2
64
76
  rescue Interrupt => e
@@ -67,9 +79,18 @@ module Rerun
67
79
  exit
68
80
  end
69
81
 
70
- unless running?
71
- notify "Launch Failed", "See console for error output"
72
- @already_running = false
82
+ if exit?
83
+ status = status_thread.value
84
+ if status.success?
85
+ notify "succeeded", ""
86
+ else
87
+ notify "failed", "Exit status #{status.exitstatus}"
88
+ end
89
+ else
90
+ if !running?
91
+ notify "Launch Failed", "See console for error output"
92
+ @already_running = false
93
+ end
73
94
  end
74
95
 
75
96
  unless @watcher
data/rerun.gemspec CHANGED
@@ -3,8 +3,8 @@ $spec = Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'rerun'
6
- s.version = '0.5.5'
7
- s.date = '2011-05-14'
6
+ s.version = '0.6.0'
7
+ s.date = '2011-05-15'
8
8
 
9
9
  s.description = "Restarts your app when a file changes"
10
10
  s.summary = "Launches an app, and restarts it whenever the filesystem changes."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-14 00:00:00.000000000Z
12
+ date: 2011-05-15 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Restarts your app when a file changes
15
15
  email: alex@stinky.com