rerun 0.8.2 → 0.9.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 358f792dfe92e79b4e621d039a96b4a607dace72
4
- data.tar.gz: 94c80e4ff9e1ffdcc6f3fc4d42aa695b486965be
3
+ metadata.gz: dfeb631293e3c084bb49fe63e960edd9ec01a7bc
4
+ data.tar.gz: dfacf8cd2c638cc518b3021d3267f09b0f9df91a
5
5
  SHA512:
6
- metadata.gz: ef6893b335910d5d69f578ae4d3bc9251bfb8894d13557953d0c14e248c6aa0c4eb1affd210682c2e585a329cdf9be56d53e6d95a65733ee58c1fff0367c22e6
7
- data.tar.gz: b95e0675a76f4d8b5d87f58f52ea5cdf1e9a37e7947cf296a7688881ad5afdb3eb251f4fd8a0dc2de10f0054373834ea1c1ad70ab716e98c1fb6d8483c1c88a8
6
+ metadata.gz: 15d53a73449cc4755ca91ebf2c59c5f21b64d9ac97c43c3af3f47c9404e0fea33ba02f6e2b3ab9fe021043fbc60bb9fa0b4f81d2af1363a8bc151136462c53df
7
+ data.tar.gz: 74e2275e507e39b77ca9f01358178639f2f65154b4255518e550371f5c78fb95a84d90b34e11236bc0db9ea3ba579d21fc38c68edb1368803ac44beb4c4a2574
data/README.md CHANGED
@@ -113,11 +113,11 @@ Procfile processes locally and restart them all when necessary.
113
113
 
114
114
  # Options:
115
115
 
116
- `--dir` directory (or directories) to watch (default = "."). Separate multiple paths with ','.
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
119
  By default it watches files ending in: `rb,js,css,scss,sass,erb,html,haml,ru`.
120
- It also ignores directories named `.rbx .bundle .git .svn log tmp vendor` and files named `.DS_Store`.
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.
121
121
 
122
122
  `--signal` (or -s) use specified signal (instead of the default SIGTERM) to terminate the previous process.
123
123
  This may be useful for forcing the respective process to terminate as quickly as possible.
@@ -131,6 +131,8 @@ This may be useful for forcing the respective process to terminate as quickly as
131
131
 
132
132
  `--no-growl` don't use growl
133
133
 
134
+ `--name` set the app name (for display)
135
+
134
136
  Also --version and --help, naturally.
135
137
 
136
138
  # Growl Notifications
@@ -149,6 +151,7 @@ While the app is (re)running, you can make things happen by pressing keys:
149
151
  * **r** -- restart (as if a file had changed)
150
152
  * **c** -- clear the screen
151
153
  * **x** or **q** -- exit (just like control-C)
154
+ * **p** -- pause/unpause filesystem watching
152
155
 
153
156
  If you're backgrounding or using Pry or a debugger, you might not want these
154
157
  keys to be trapped, so use the `--background` option.
@@ -169,20 +172,23 @@ restart.
169
172
 
170
173
  * Cooldown (so if a dozen files appear in a burst, say from 'git pull', it only restarts once)
171
174
  * If the last element of the command is a `.ru` file and there's no other command then use `rackup`
172
- * Exclude files beginning with a dot, unless the pattern explicitly says to include them
173
- * --exclude pattern
175
+ * --ignore pattern (currently we're using Listen's default list plus dotfiles)
174
176
  * ".rerun" file to specify options per project or in $HOME.
175
- * Test on Linux.
176
- * On OS X, use a C library using growl's developer API <http://growl.info/developer/>
177
- * Use growl's AppleScript or SDK instead of relying on growlnotify
178
- * "Failed" icon
179
- * Figure out an algorithm so "-x" is not needed (if possible)
177
+ * Figure out an algorithm so "-x" is not needed (if possible) -- maybe by accepting a "--port" option or reading `config.ru`
180
178
  * Specify (or deduce) port to listen for to determine success of a web server launch
181
179
  * Make sure to pass through quoted options correctly to target process [bug]
182
180
  * Make it work on Windows, like Guard now does. See
183
181
  * https://github.com/guard/guard/issues/59
184
182
  * https://github.com/guard/guard/issues/27
185
183
  * Optionally do "bundle install" before and "bundle exec" during launch
184
+ * On OS X:
185
+ * use a C library using growl's developer API <http://growl.info/developer/>
186
+ * Use growl's AppleScript or SDK instead of relying on growlnotify
187
+ * Use OS X notifications
188
+ * "Failed" icon for notifications
189
+ * On Linux:
190
+ * Test on Linux.
191
+ * Use libnotify or notify-send http://www.linuxjournal.com/content/tech-tip-get-notifications-your-scripts-notify-send
186
192
 
187
193
  # Other projects that do similar things
188
194
 
@@ -276,6 +282,13 @@ Based upon and/or inspired by:
276
282
 
277
283
  # Version History
278
284
 
285
+ * v0.9.0
286
+ * --dir (or -d) can be specified more than once, for multiple directories (thanks again Barry!)
287
+ * --name option
288
+ * press 'p' to pause/unpause filesystem watching (Barry is the man!)
289
+ * works with Listen 2 (note: needs 2.3 or higher)
290
+ * ignore all dotfiles, and add actual list of ignored dirs and files
291
+
279
292
  * v0.8.2
280
293
  * bugfix, forcing Rerun to use Listen v1.0.3 while we work out the troubles we're having with Listen 1.3 and 2.1
281
294
 
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'pathname'
2
3
 
3
4
  libdir = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}"
4
5
 
@@ -7,12 +8,13 @@ $spec = Gem::Specification.load(File.join(libdir, "..", "rerun.gemspec"))
7
8
  module Rerun
8
9
  class Options
9
10
  DEFAULT_PATTERN = "**/*.{rb,js,css,scss,sass,erb,html,haml,ru}"
11
+ DEFAULT_DIRS = ["."]
10
12
 
11
13
  DEFAULTS = {
12
- :dir => ["."],
13
14
  :pattern => DEFAULT_PATTERN,
14
15
  :signal => "TERM",
15
16
  :growl => true,
17
+ :name => Pathname.getwd.basename.to_s.capitalize
16
18
  }
17
19
 
18
20
  def self.parse args = ARGV
@@ -27,8 +29,9 @@ module Rerun
27
29
  opts.separator ""
28
30
  opts.separator "Options:"
29
31
 
30
- opts.on("-d dir", "--dir dir", "directory to watch, default = \"#{DEFAULTS[:dir]}\". Separate multiple paths with ','.") do |dir|
31
- options[:dir] = dir.split(",")
32
+ opts.on("-d dir", "--dir dir", "directory to watch, default = \"#{DEFAULT_DIRS}\". Specify multiple paths with ',' or separate '-d dir' option pairs.") do |dir|
33
+ elements = dir.split(",")
34
+ options[:dir] = (options[:dir] || []) + elements
32
35
  end
33
36
 
34
37
  opts.on("-p pattern", "--pattern pattern", "file glob, default = \"#{DEFAULTS[:pattern]}\"") do |pattern|
@@ -51,6 +54,10 @@ module Rerun
51
54
  options[:background] = true
52
55
  end
53
56
 
57
+ opts.on("-n name", "--name name", "name of app used in logs and notifications, default = \"#{DEFAULTS[:name]}\"") do |name|
58
+ options[:name] = name
59
+ end
60
+
54
61
  opts.on("--no-growl", "don't use growl") do
55
62
  options[:growl] = false
56
63
  end
@@ -64,6 +71,10 @@ module Rerun
64
71
  puts $spec.version
65
72
  return
66
73
  end
74
+
75
+ 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(',')}]."
77
+
67
78
  end
68
79
 
69
80
  if args.empty?
@@ -72,6 +83,7 @@ module Rerun
72
83
  else
73
84
  opts.parse! args
74
85
  options[:cmd] = args.join(" ")
86
+ options[:dir] ||= DEFAULT_DIRS
75
87
  options
76
88
  end
77
89
  end
@@ -8,6 +8,8 @@ module Rerun
8
8
  runner = new(cmd, options)
9
9
  runner.start
10
10
  runner.join
11
+ # apparently runner doesn't keep running anymore (as of Listen 2) so we have to sleep forever :-(
12
+ sleep 10000 while true # :-(
11
13
  end
12
14
 
13
15
  include System
@@ -30,6 +32,8 @@ module Rerun
30
32
  when 'r'
31
33
  say "Restarting"
32
34
  restart
35
+ when 'p'
36
+ toggle_pause if watcher_running?
33
37
  when 'x', 'q'
34
38
  die
35
39
  break # the break will stop this thread, in case the 'die' doesn't
@@ -37,6 +41,7 @@ module Rerun
37
41
  puts "\n#{c.inspect} pressed inside rerun"
38
42
  puts [["c", "clear screen"],
39
43
  ["r", "restart"],
44
+ ["p", "toggle pause"],
40
45
  ["x or q", "stop and exit"]
41
46
  ].map{|key, description| " #{key} -- #{description}"}.join("\n")
42
47
  puts
@@ -60,6 +65,26 @@ module Rerun
60
65
  @restarting = false
61
66
  end
62
67
 
68
+ def watcher_running?
69
+ @watcher && @watcher.running?
70
+ end
71
+
72
+ def toggle_pause
73
+ unless @pausing
74
+ say "Pausing. Press 'p' again to resume."
75
+ @watcher.pause
76
+ @pausing = true
77
+ else
78
+ say "Resuming"
79
+ @watcher.unpause
80
+ @pausing = false
81
+ end
82
+ end
83
+
84
+ def unpause
85
+ @watcher.unpause
86
+ end
87
+
63
88
  def dir
64
89
  @options[:dir]
65
90
  end
@@ -80,6 +105,10 @@ module Rerun
80
105
  @options[:exit]
81
106
  end
82
107
 
108
+ def app_name
109
+ @options[:name]
110
+ end
111
+
83
112
  def start
84
113
  if windows?
85
114
  raise "Sorry, Rerun does not work on Windows."
@@ -24,11 +24,6 @@ module Rerun
24
24
  growlnotify
25
25
  end
26
26
 
27
- def app_name
28
- # todo: make sure this works in non-Mac and non-Unix environments
29
- File.expand_path(".").gsub(/^.*\//, '').capitalize
30
- end
31
-
32
27
  def icon
33
28
  here = File.expand_path(File.dirname(__FILE__))
34
29
  icondir = File.expand_path("#{here}/../../icons")
@@ -12,6 +12,8 @@ Thread.abort_on_exception = true
12
12
  #
13
13
  module Rerun
14
14
  class Watcher
15
+ InvalidDirectoryError = Class.new(RuntimeError)
16
+
15
17
  attr_reader :directory, :pattern, :priority
16
18
 
17
19
  # Create a file system watcher. Start it by calling #start.
@@ -41,7 +43,7 @@ module Rerun
41
43
  dirs.map do |d|
42
44
  d.chomp!("/")
43
45
  unless FileTest.exists?(d) && FileTest.readable?(d) && FileTest.directory?(d)
44
- raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isnt readable"
46
+ raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isn't readable"
45
47
  end
46
48
  File.expand_path(d)
47
49
  end
@@ -54,12 +56,13 @@ module Rerun
54
56
 
55
57
  @thread = Thread.new do
56
58
  regexp = Rerun::Glob.new(@pattern).to_regexp
57
- dirs = @directories
58
- params = dirs << { :filter => regexp, :relative_paths => false }
59
- @listener = Listen::Listener.new(*params) do |modified, added, removed|
60
- @client_callback.call(:modified => modified, :added => added, :removed => removed)
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|
61
+ if((modified.size + added.size + removed.size) > 0)
62
+ @client_callback.call(:modified => modified, :added => added, :removed => removed)
63
+ end
61
64
  end
62
- @listener.start!
65
+ @listener.start
63
66
  end
64
67
 
65
68
  @thread.priority = @priority
@@ -70,10 +73,10 @@ module Rerun
70
73
  end
71
74
 
72
75
  def adapter
73
- timeout(4) do
74
- sleep 1 until adapter = @listener.instance_variable_get(:@adapter)
76
+ @listener.registry[:adapter] || (timeout(4) do
77
+ sleep 1 until adapter = @listener.registry[:adapter]
75
78
  adapter
76
- end
79
+ end)
77
80
  end
78
81
 
79
82
  # kill the file watcher thread
@@ -93,5 +96,18 @@ module Rerun
93
96
  rescue Interrupt => e
94
97
  # don't care
95
98
  end
99
+
100
+ def pause
101
+ @listener.pause if @listener
102
+ end
103
+
104
+ def unpause
105
+ @listener.unpause if @listener
106
+ end
107
+
108
+ def running?
109
+ @listener && @listener.instance_variable_get(:@adapter)
110
+ end
111
+
96
112
  end
97
113
  end
@@ -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.8.2'
6
+ s.version = '0.9.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,8 +25,10 @@ $spec = Gem::Specification.new do |s|
25
25
 
26
26
  s.extra_rdoc_files = %w[README.md]
27
27
 
28
- s.add_dependency 'listen', '~> 1.0.3'
28
+ s.add_dependency 'listen', '~> 2.7'
29
29
 
30
30
  s.homepage = "http://github.com/alexch/rerun/"
31
31
  s.require_paths = %w[lib]
32
+
33
+ s.license = 'MIT'
32
34
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rerun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.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: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.3
19
+ version: '2.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.3
26
+ version: '2.7'
27
27
  description: Restarts your app when a file changes. A no-frills, command-line alternative
28
28
  to Guard, Shotgun, Autotest, etc.
29
29
  email: alex@stinky.com
@@ -33,21 +33,22 @@ extensions: []
33
33
  extra_rdoc_files:
34
34
  - README.md
35
35
  files:
36
- - README.md
37
36
  - LICENSE
37
+ - README.md
38
38
  - Rakefile
39
- - rerun.gemspec
40
39
  - bin/rerun
41
40
  - icons/rails_grn_sml.png
42
41
  - icons/rails_red_sml.png
42
+ - lib/rerun.rb
43
43
  - lib/rerun/glob.rb
44
44
  - lib/rerun/options.rb
45
45
  - lib/rerun/runner.rb
46
46
  - lib/rerun/system.rb
47
47
  - lib/rerun/watcher.rb
48
- - lib/rerun.rb
48
+ - rerun.gemspec
49
49
  homepage: http://github.com/alexch/rerun/
50
- licenses: []
50
+ licenses:
51
+ - MIT
51
52
  metadata: {}
52
53
  post_install_message:
53
54
  rdoc_options: []
@@ -55,17 +56,17 @@ require_paths:
55
56
  - lib
56
57
  required_ruby_version: !ruby/object:Gem::Requirement
57
58
  requirements:
58
- - - '>='
59
+ - - ">="
59
60
  - !ruby/object:Gem::Version
60
61
  version: '0'
61
62
  required_rubygems_version: !ruby/object:Gem::Requirement
62
63
  requirements:
63
- - - '>='
64
+ - - ">="
64
65
  - !ruby/object:Gem::Version
65
66
  version: '0'
66
67
  requirements: []
67
68
  rubyforge_project:
68
- rubygems_version: 2.0.5
69
+ rubygems_version: 2.2.2
69
70
  signing_key:
70
71
  specification_version: 2
71
72
  summary: Launches an app, and restarts it whenever the filesystem changes. A no-frills,