rerun 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfeb631293e3c084bb49fe63e960edd9ec01a7bc
4
- data.tar.gz: dfacf8cd2c638cc518b3021d3267f09b0f9df91a
3
+ metadata.gz: b5186659055558e298a987ddc358c03fb2ca23dc
4
+ data.tar.gz: 93afa739db65f198c20d09520efcfa6e08800e06
5
5
  SHA512:
6
- metadata.gz: 15d53a73449cc4755ca91ebf2c59c5f21b64d9ac97c43c3af3f47c9404e0fea33ba02f6e2b3ab9fe021043fbc60bb9fa0b4f81d2af1363a8bc151136462c53df
7
- data.tar.gz: 74e2275e507e39b77ca9f01358178639f2f65154b4255518e550371f5c78fb95a84d90b34e11236bc0db9ea3ba579d21fc38c68edb1368803ac44beb4c4a2574
6
+ metadata.gz: 60e098c424e134c5456c0ed871f62224bb2fe33f93aed659e554a55729b56f2cdd06a4c910a5f6a498c8d1a131d67e82861a0acfdcca874cb0799031eacd289a
7
+ data.tar.gz: 5f0fbd5006a6bae73e8ac6104ec6d4c7648ee79baf9c3ba01b14e6ed544386922b6472e3d3fec9e852dea6f4857449673b3b7a93ac7ce4798ef697748b8ac5fa
data/README.md CHANGED
@@ -14,7 +14,7 @@ Rerun's advantage is its simple design. Since it uses `exec` and the standard
14
14
  Unix `SIGINT` and `SIGKILL` signals, you're sure the restarted app is really
15
15
  acting just like it was when you ran it from the command line the first time.
16
16
 
17
- By default only `*.{rb,js,css,scss,sass,erb,html,haml,ru}` files are watched.
17
+ By default only `*.{rb,js,css,coffee,scss,sass,erb,html,haml,ru,slim,md}` files are watched.
18
18
  Use the `--pattern` option if you want to change this.
19
19
 
20
20
  As of version 0.7.0, we use the Listen gem, which tries to use your OS's
@@ -116,8 +116,14 @@ Procfile processes locally and restart them all when necessary.
116
116
  `--dir` directory (or directories) to watch (default = "."). Separate multiple paths with ',' and/or use multiple `-d` options.
117
117
 
118
118
  `--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.
119
- By default it watches files ending in: `rb,js,css,scss,sass,erb,html,haml,ru`.
120
- On top of this, it also ignores dotfiles, `.tmp` files, and some other files and directories (like `.git .hg .rbx .svn bundle log tmp`) -- run `rerun --help` for the full list.
119
+ By default it watches files ending in: `rb,js,css,coffee,scss,sass,erb,html,haml,ru,slim,md`.
120
+ On top of this, it also ignores dotfiles, `.tmp` files, and some other files and directories (like `.git` and `log`).
121
+ Run `rerun --help` to see the actual list.
122
+
123
+ `--ignore pattern` file glob to ignore (can be set many times). To ignore a directory, you must append '/*' e.g.
124
+ `--ignore 'coverage/*'`.
125
+
126
+ *On top of --pattern and --ignore, we ignore any changes to files and dirs starting with a dot.*
121
127
 
122
128
  `--signal` (or -s) use specified signal (instead of the default SIGTERM) to terminate the previous process.
123
129
  This may be useful for forcing the respective process to terminate as quickly as possible.
@@ -133,7 +139,7 @@ This may be useful for forcing the respective process to terminate as quickly as
133
139
 
134
140
  `--name` set the app name (for display)
135
141
 
136
- Also --version and --help, naturally.
142
+ Also `--version` and `--help`, naturally.
137
143
 
138
144
  # Growl Notifications
139
145
 
@@ -170,17 +176,21 @@ restart.
170
176
 
171
177
  # To Do:
172
178
 
173
- * Cooldown (so if a dozen files appear in a burst, say from 'git pull', it only restarts once)
174
- * If the last element of the command is a `.ru` file and there's no other command then use `rackup`
175
- * --ignore pattern (currently we're using Listen's default list plus dotfiles)
179
+ ## Must have for v1.0
176
180
  * ".rerun" file to specify options per project or in $HOME.
181
+ * Make sure to pass through quoted options correctly to target process [bug]
182
+ * Optionally do "bundle install" before and "bundle exec" during launch
183
+
184
+ ## Nice to have
185
+ * Smarter --signal option (specifying signal to try and a timeout to wait, repeated)
186
+ * If the last element of the command is a `.ru` file and there's no other command then use `rackup`
177
187
  * Figure out an algorithm so "-x" is not needed (if possible) -- maybe by accepting a "--port" option or reading `config.ru`
178
188
  * Specify (or deduce) port to listen for to determine success of a web server launch
179
- * Make sure to pass through quoted options correctly to target process [bug]
189
+
190
+ ## Wacky Ideas
180
191
  * Make it work on Windows, like Guard now does. See
181
192
  * https://github.com/guard/guard/issues/59
182
193
  * https://github.com/guard/guard/issues/27
183
- * Optionally do "bundle install" before and "bundle exec" during launch
184
194
  * On OS X:
185
195
  * use a C library using growl's developer API <http://growl.info/developer/>
186
196
  * Use growl's AppleScript or SDK instead of relying on growlnotify
@@ -282,11 +292,16 @@ Based upon and/or inspired by:
282
292
 
283
293
  # Version History
284
294
 
285
- * v0.9.0
295
+ * v0.10.0 4 May 2014
296
+ * add '.coffee,.slim,.md' to default pattern (thanks @xylinq)
297
+ * --ignore option
298
+
299
+ * v0.9.0 6 March 2014
286
300
  * --dir (or -d) can be specified more than once, for multiple directories (thanks again Barry!)
287
301
  * --name option
288
302
  * press 'p' to pause/unpause filesystem watching (Barry is the man!)
289
303
  * works with Listen 2 (note: needs 2.3 or higher)
304
+ * cooldown works, thanks to patches to underlying Listen gem
290
305
  * ignore all dotfiles, and add actual list of ignored dirs and files
291
306
 
292
307
  * v0.8.2
@@ -10,7 +10,5 @@ require "rerun/glob"
10
10
 
11
11
  module Rerun
12
12
 
13
- DEFAULT_PATTERN = "**/*.{rb,js,css,scss,sass,erb,html,haml,ru}"
14
-
15
13
  end
16
14
 
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
  require 'pathname'
3
+ require 'rerun/watcher'
3
4
 
4
5
  libdir = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}"
5
6
 
@@ -7,14 +8,15 @@ $spec = Gem::Specification.load(File.join(libdir, "..", "rerun.gemspec"))
7
8
 
8
9
  module Rerun
9
10
  class Options
10
- DEFAULT_PATTERN = "**/*.{rb,js,css,scss,sass,erb,html,haml,ru}"
11
+ DEFAULT_PATTERN = "**/*.{rb,js,coffee,css,scss,sass,erb,html,haml,ru,yml,slim,md}"
11
12
  DEFAULT_DIRS = ["."]
12
13
 
13
14
  DEFAULTS = {
14
15
  :pattern => DEFAULT_PATTERN,
15
16
  :signal => "TERM",
16
17
  :growl => true,
17
- :name => Pathname.getwd.basename.to_s.capitalize
18
+ :name => Pathname.getwd.basename.to_s.capitalize,
19
+ :ignore => []
18
20
  }
19
21
 
20
22
  def self.parse args = ARGV
@@ -34,11 +36,16 @@ module Rerun
34
36
  options[:dir] = (options[:dir] || []) + elements
35
37
  end
36
38
 
37
- opts.on("-p pattern", "--pattern pattern", "file glob, default = \"#{DEFAULTS[:pattern]}\"") do |pattern|
39
+ # todo: rename to "--watch"
40
+ opts.on("-p pattern", "--pattern pattern", "file glob to watch, default = \"#{DEFAULTS[:pattern]}\"") do |pattern|
38
41
  options[:pattern] = pattern
39
42
  end
40
43
 
41
- opts.on("-s", "--signal signal", "terminate process using this signal, default = \"#{DEFAULTS[:signal]}\"") do |signal|
44
+ opts.on("-i pattern", "--ignore pattern", "file glob to ignore (can be set many times). To ignore a directory, you must append '/*' e.g. --ignore 'coverage/*'") do |pattern|
45
+ options[:ignore] += [pattern]
46
+ end
47
+
48
+ opts.on("-s signal", "--signal signal", "terminate process using this signal, default = \"#{DEFAULTS[:signal]}\"") do |signal|
42
49
  options[:signal] = signal
43
50
  end
44
51
 
@@ -73,7 +80,7 @@ module Rerun
73
80
  end
74
81
 
75
82
  opts.on_tail ""
76
- opts.on_tail "On top of --pattern, we ignore any changes to files and dirs starting with a dot, ending with [#{Listen::Silencer::DEFAULT_IGNORED_EXTENSIONS.join(',')}], or named [#{Listen::Silencer::DEFAULT_IGNORED_DIRECTORIES.join(',')}]."
83
+ opts.on_tail "On top of --pattern and --ignore, we ignore any changes to files and dirs starting with a dot."
77
84
 
78
85
  end
79
86
 
@@ -97,6 +97,10 @@ module Rerun
97
97
  @options[:pattern]
98
98
  end
99
99
 
100
+ def ignore
101
+ @options[:ignore] || []
102
+ end
103
+
100
104
  def clear?
101
105
  @options[:clear]
102
106
  end
@@ -175,7 +179,7 @@ module Rerun
175
179
 
176
180
  unless @watcher
177
181
 
178
- watcher = Watcher.new(:directory => dirs, :pattern => pattern) do |changes|
182
+ watcher = Watcher.new(:directory => dirs, :pattern => pattern, :ignore => ignore) do |changes|
179
183
 
180
184
  message = [:modified, :added, :removed].map do |change|
181
185
  count = changes[change].size
@@ -188,7 +192,9 @@ module Rerun
188
192
  end
189
193
  watcher.start
190
194
  @watcher = watcher
191
- say "Watching #{dir.join(', ')} for #{pattern} using #{watcher.adapter.class.name.split('::').last} adapter"
195
+ say "Watching #{dir.join(', ')} for #{pattern}" +
196
+ (ignore.empty? ? "" : " (ignoring #{ignore.join(',')})") +
197
+ " using #{watcher.adapter.class.name.split('::').last} adapter"
192
198
  end
193
199
  end
194
200
 
@@ -220,13 +226,13 @@ module Rerun
220
226
  if @pid && (@pid != 0)
221
227
  notify "stopping", "All good things must come to an end." unless @restarting
222
228
  begin
223
- timeout(4) do # todo: escalation timeout setting
229
+ timeout(5) do # todo: escalation timeout setting
224
230
  # start with a polite SIGTERM
225
231
  signal(default_signal) && Process.wait(@pid)
226
232
  end
227
233
  rescue Timeout::Error
228
234
  begin
229
- timeout(2) do
235
+ timeout(5) do
230
236
  # escalate to SIGINT aka control-C since some foolish process may be ignoring SIGTERM
231
237
  signal("INT") && Process.wait(@pid)
232
238
  end
@@ -14,6 +14,10 @@ module Rerun
14
14
  class Watcher
15
15
  InvalidDirectoryError = Class.new(RuntimeError)
16
16
 
17
+ #def self.default_ignore
18
+ # Listen::Silencer.new(Listen::Listener.new).send :_default_ignore_patterns
19
+ #end
20
+
17
21
  attr_reader :directory, :pattern, :priority
18
22
 
19
23
  # Create a file system watcher. Start it by calling #start.
@@ -35,6 +39,7 @@ module Rerun
35
39
  @directories = options[:directory]
36
40
  @directories = sanitize_dirs(@directories)
37
41
  @priority = options[:priority]
42
+ @ignore = [options[:ignore]].flatten.compact
38
43
  @thread = nil
39
44
  end
40
45
 
@@ -55,9 +60,7 @@ module Rerun
55
60
  end
56
61
 
57
62
  @thread = Thread.new do
58
- regexp = Rerun::Glob.new(@pattern).to_regexp
59
- dotfiles = /^\.[^.]/ # at beginning of string, a real dot followed by any other character
60
- @listener = Listen.to(*@directories, only: regexp, ignore: dotfiles, wait_for_delay: 1) do |modified, added, removed|
63
+ @listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1) do |modified, added, removed|
61
64
  if((modified.size + added.size + removed.size) > 0)
62
65
  @client_callback.call(:modified => modified, :added => added, :removed => removed)
63
66
  end
@@ -72,6 +75,16 @@ module Rerun
72
75
  at_exit { stop } # try really hard to clean up after ourselves
73
76
  end
74
77
 
78
+ def watching
79
+ Rerun::Glob.new(@pattern).to_regexp
80
+ end
81
+
82
+ def ignoring
83
+ # todo: --no-ignore-dotfiles
84
+ dotfiles = /^\.[^.]/ # at beginning of string, a real dot followed by any other character
85
+ [dotfiles] + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
86
+ end
87
+
75
88
  def adapter
76
89
  @listener.registry[:adapter] || (timeout(4) do
77
90
  sleep 1 until adapter = @listener.registry[:adapter]
@@ -3,7 +3,7 @@ $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.9.0'
6
+ s.version = '0.10.0'
7
7
 
8
8
  s.description = "Restarts your app when a file changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
9
9
  s.summary = "Launches an app, and restarts it whenever the filesystem changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
@@ -25,7 +25,7 @@ $spec = Gem::Specification.new do |s|
25
25
 
26
26
  s.extra_rdoc_files = %w[README.md]
27
27
 
28
- s.add_dependency 'listen', '~> 2.7'
28
+ s.add_runtime_dependency 'listen', '~> 2.7', '>= 2.7.3'
29
29
 
30
30
  s.homepage = "http://github.com/alexch/rerun/"
31
31
  s.require_paths = %w[lib]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.7'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.7.3
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.7'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.7.3
27
33
  description: Restarts your app when a file changes. A no-frills, command-line alternative
28
34
  to Guard, Shotgun, Autotest, etc.
29
35
  email: alex@stinky.com