rerun 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +27 -14
- data/Rakefile +82 -83
- data/bin/rerun +18 -18
- data/lib/goo.rb +3 -3
- data/lib/rerun.rb +15 -15
- data/lib/rerun/notification.rb +82 -82
- data/lib/rerun/options.rb +146 -145
- data/lib/rerun/runner.rb +374 -376
- data/lib/rerun/system.rb +22 -22
- data/lib/rerun/watcher.rb +134 -131
- data/rerun.gemspec +34 -34
- metadata +6 -7
data/lib/rerun/system.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
module Rerun
|
2
|
-
module System
|
3
|
-
|
4
|
-
def mac?
|
5
|
-
RUBY_PLATFORM =~ /darwin/i
|
6
|
-
end
|
7
|
-
|
8
|
-
def windows?
|
9
|
-
RUBY_PLATFORM =~ /(mswin|mingw32)/i
|
10
|
-
end
|
11
|
-
|
12
|
-
def linux?
|
13
|
-
RUBY_PLATFORM =~ /linux/i
|
14
|
-
end
|
15
|
-
|
16
|
-
def rails?
|
17
|
-
rails_sig_file = File.expand_path(".")+"/config/boot.rb"
|
18
|
-
File.exists? rails_sig_file
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module Rerun
|
2
|
+
module System
|
3
|
+
|
4
|
+
def mac?
|
5
|
+
RUBY_PLATFORM =~ /darwin/i
|
6
|
+
end
|
7
|
+
|
8
|
+
def windows?
|
9
|
+
RUBY_PLATFORM =~ /(mswin|mingw32)/i
|
10
|
+
end
|
11
|
+
|
12
|
+
def linux?
|
13
|
+
RUBY_PLATFORM =~ /linux/i
|
14
|
+
end
|
15
|
+
|
16
|
+
def rails?
|
17
|
+
rails_sig_file = File.expand_path(".")+"/config/boot.rb"
|
18
|
+
File.exists? rails_sig_file
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/rerun/watcher.rb
CHANGED
@@ -1,131 +1,134 @@
|
|
1
|
-
require 'listen'
|
2
|
-
|
3
|
-
Thread.abort_on_exception = true
|
4
|
-
|
5
|
-
# This class will watch a directory and alert you of
|
6
|
-
# new files, modified files, deleted files.
|
7
|
-
#
|
8
|
-
# Now uses the Listen gem, but spawns its own thread on top.
|
9
|
-
# We should probably be accessing the Listen thread directly.
|
10
|
-
#
|
11
|
-
# Author: Alex Chaffee
|
12
|
-
#
|
13
|
-
module Rerun
|
14
|
-
class Watcher
|
15
|
-
InvalidDirectoryError = Class.new(RuntimeError)
|
16
|
-
|
17
|
-
#def self.default_ignore
|
18
|
-
# Listen::Silencer.new(Listen::Listener.new).send :_default_ignore_patterns
|
19
|
-
#end
|
20
|
-
|
21
|
-
attr_reader :directory, :pattern, :priority
|
22
|
-
|
23
|
-
# Create a file system watcher. Start it by calling #start.
|
24
|
-
#
|
25
|
-
# @param options[:directory] the directory to watch (default ".")
|
26
|
-
# @param options[:pattern] the glob pattern to search under the watched directory (default "**/*")
|
27
|
-
# @param options[:priority] the priority of the watcher thread (default 0)
|
28
|
-
#
|
29
|
-
def initialize(options = {}, &client_callback)
|
30
|
-
@client_callback = client_callback
|
31
|
-
|
32
|
-
options = {
|
33
|
-
:directory => ".",
|
34
|
-
:pattern => "**/*",
|
35
|
-
:priority => 0,
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@
|
40
|
-
@directories =
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
[
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
def
|
113
|
-
@listener.
|
114
|
-
end
|
115
|
-
|
116
|
-
def
|
117
|
-
@listener
|
118
|
-
end
|
119
|
-
|
120
|
-
def
|
121
|
-
@listener &&
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
|
1
|
+
require 'listen'
|
2
|
+
|
3
|
+
Thread.abort_on_exception = true
|
4
|
+
|
5
|
+
# This class will watch a directory and alert you of
|
6
|
+
# new files, modified files, deleted files.
|
7
|
+
#
|
8
|
+
# Now uses the Listen gem, but spawns its own thread on top.
|
9
|
+
# We should probably be accessing the Listen thread directly.
|
10
|
+
#
|
11
|
+
# Author: Alex Chaffee
|
12
|
+
#
|
13
|
+
module Rerun
|
14
|
+
class Watcher
|
15
|
+
InvalidDirectoryError = Class.new(RuntimeError)
|
16
|
+
|
17
|
+
#def self.default_ignore
|
18
|
+
# Listen::Silencer.new(Listen::Listener.new).send :_default_ignore_patterns
|
19
|
+
#end
|
20
|
+
|
21
|
+
attr_reader :directory, :pattern, :priority, :ignore_dotfiles
|
22
|
+
|
23
|
+
# Create a file system watcher. Start it by calling #start.
|
24
|
+
#
|
25
|
+
# @param options[:directory] the directory to watch (default ".")
|
26
|
+
# @param options[:pattern] the glob pattern to search under the watched directory (default "**/*")
|
27
|
+
# @param options[:priority] the priority of the watcher thread (default 0)
|
28
|
+
#
|
29
|
+
def initialize(options = {}, &client_callback)
|
30
|
+
@client_callback = client_callback
|
31
|
+
|
32
|
+
options = {
|
33
|
+
:directory => ".",
|
34
|
+
:pattern => "**/*",
|
35
|
+
:priority => 0,
|
36
|
+
:ignore_dotfiles => true,
|
37
|
+
}.merge(options)
|
38
|
+
|
39
|
+
@pattern = options[:pattern]
|
40
|
+
@directories = options[:directory]
|
41
|
+
@directories = sanitize_dirs(@directories)
|
42
|
+
@priority = options[:priority]
|
43
|
+
@force_polling = options[:force_polling]
|
44
|
+
@ignore = [options[:ignore]].flatten.compact
|
45
|
+
@ignore_dotfiles = options[:ignore_dotfiles]
|
46
|
+
@thread = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def sanitize_dirs(dirs)
|
50
|
+
dirs = [*dirs]
|
51
|
+
dirs.map do |d|
|
52
|
+
d.chomp!("/")
|
53
|
+
unless FileTest.exists?(d) && FileTest.readable?(d) && FileTest.directory?(d)
|
54
|
+
raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isn't readable"
|
55
|
+
end
|
56
|
+
File.expand_path(d)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def start
|
61
|
+
if @thread then
|
62
|
+
raise RuntimeError, "already started"
|
63
|
+
end
|
64
|
+
|
65
|
+
@thread = Thread.new do
|
66
|
+
@listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1, force_polling: @force_polling) do |modified, added, removed|
|
67
|
+
count = modified.size + added.size + removed.size
|
68
|
+
if count > 0
|
69
|
+
@client_callback.call(:modified => modified, :added => added, :removed => removed)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
@listener.start
|
73
|
+
end
|
74
|
+
|
75
|
+
@thread.priority = @priority
|
76
|
+
|
77
|
+
sleep 0.1 until @listener
|
78
|
+
|
79
|
+
at_exit { stop } # try really hard to clean up after ourselves
|
80
|
+
end
|
81
|
+
|
82
|
+
def watching
|
83
|
+
Rerun::Glob.new(@pattern).to_regexp
|
84
|
+
end
|
85
|
+
|
86
|
+
def ignoring
|
87
|
+
patterns = []
|
88
|
+
if ignore_dotfiles
|
89
|
+
patterns << /^\.[^.]/ # at beginning of string, a real dot followed by any other character
|
90
|
+
end
|
91
|
+
patterns + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
|
92
|
+
end
|
93
|
+
|
94
|
+
# kill the file watcher thread
|
95
|
+
def stop
|
96
|
+
@thread.wakeup rescue ThreadError
|
97
|
+
begin
|
98
|
+
@listener.stop
|
99
|
+
rescue Exception => e
|
100
|
+
puts "#{e.class}: #{e.message} stopping listener"
|
101
|
+
end
|
102
|
+
@thread.kill rescue ThreadError
|
103
|
+
end
|
104
|
+
|
105
|
+
# wait for the file watcher to finish
|
106
|
+
def join
|
107
|
+
@thread.join if @thread
|
108
|
+
rescue Interrupt
|
109
|
+
# don't care
|
110
|
+
end
|
111
|
+
|
112
|
+
def pause
|
113
|
+
@listener.pause if @listener
|
114
|
+
end
|
115
|
+
|
116
|
+
def unpause
|
117
|
+
@listener.start if @listener
|
118
|
+
end
|
119
|
+
|
120
|
+
def running?
|
121
|
+
@listener && @listener.processing?
|
122
|
+
end
|
123
|
+
|
124
|
+
def adapter
|
125
|
+
@listener &&
|
126
|
+
(backend = @listener.instance_variable_get(:@backend)) &&
|
127
|
+
backend.instance_variable_get(:@adapter)
|
128
|
+
end
|
129
|
+
|
130
|
+
def adapter_name
|
131
|
+
adapter && adapter.class.name.split('::').last
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/rerun.gemspec
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
$spec = Gem::Specification.new do |s|
|
2
|
-
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
|
-
|
5
|
-
s.name = 'rerun'
|
6
|
-
s.version = '0.13.
|
7
|
-
|
8
|
-
s.description = "Restarts your app when a file changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
|
9
|
-
s.summary = "Launches an app, and restarts it whenever the filesystem changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
|
10
|
-
|
11
|
-
s.authors = ["Alex Chaffee"]
|
12
|
-
s.email = "alex@stinky.com"
|
13
|
-
|
14
|
-
s.files = %w[
|
15
|
-
README.md
|
16
|
-
LICENSE
|
17
|
-
Rakefile
|
18
|
-
rerun.gemspec
|
19
|
-
bin/rerun
|
20
|
-
icons/rails_grn_sml.png
|
21
|
-
icons/rails_red_sml.png] +
|
22
|
-
Dir['lib/**/*.rb']
|
23
|
-
s.executables = ['rerun']
|
24
|
-
s.test_files = s.files.select {|path| path =~ /^spec\/.*_spec.rb/}
|
25
|
-
|
26
|
-
s.extra_rdoc_files = %w[README.md]
|
27
|
-
|
28
|
-
s.add_runtime_dependency 'listen', '~> 3.0'
|
29
|
-
|
30
|
-
s.homepage = "http://github.com/alexch/rerun/"
|
31
|
-
s.require_paths = %w[lib]
|
32
|
-
|
33
|
-
s.license = 'MIT'
|
34
|
-
end
|
1
|
+
$spec = Gem::Specification.new do |s|
|
2
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
|
+
|
5
|
+
s.name = 'rerun'
|
6
|
+
s.version = '0.13.1'
|
7
|
+
|
8
|
+
s.description = "Restarts your app when a file changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
|
9
|
+
s.summary = "Launches an app, and restarts it whenever the filesystem changes. A no-frills, command-line alternative to Guard, Shotgun, Autotest, etc."
|
10
|
+
|
11
|
+
s.authors = ["Alex Chaffee"]
|
12
|
+
s.email = "alex@stinky.com"
|
13
|
+
|
14
|
+
s.files = %w[
|
15
|
+
README.md
|
16
|
+
LICENSE
|
17
|
+
Rakefile
|
18
|
+
rerun.gemspec
|
19
|
+
bin/rerun
|
20
|
+
icons/rails_grn_sml.png
|
21
|
+
icons/rails_red_sml.png] +
|
22
|
+
Dir['lib/**/*.rb']
|
23
|
+
s.executables = ['rerun']
|
24
|
+
s.test_files = s.files.select {|path| path =~ /^spec\/.*_spec.rb/}
|
25
|
+
|
26
|
+
s.extra_rdoc_files = %w[README.md]
|
27
|
+
|
28
|
+
s.add_runtime_dependency 'listen', '~> 3.0'
|
29
|
+
|
30
|
+
s.homepage = "http://github.com/alexch/rerun/"
|
31
|
+
s.require_paths = %w[lib]
|
32
|
+
|
33
|
+
s.license = 'MIT'
|
34
|
+
end
|
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.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Chaffee
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -52,7 +52,7 @@ homepage: http://github.com/alexch/rerun/
|
|
52
52
|
licenses:
|
53
53
|
- MIT
|
54
54
|
metadata: {}
|
55
|
-
post_install_message:
|
55
|
+
post_install_message:
|
56
56
|
rdoc_options: []
|
57
57
|
require_paths:
|
58
58
|
- lib
|
@@ -67,9 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
|
71
|
-
|
72
|
-
signing_key:
|
70
|
+
rubygems_version: 3.1.2
|
71
|
+
signing_key:
|
73
72
|
specification_version: 2
|
74
73
|
summary: Launches an app, and restarts it whenever the filesystem changes. A no-frills,
|
75
74
|
command-line alternative to Guard, Shotgun, Autotest, etc.
|