rerun 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -22
- data/Rakefile +82 -82
- data/bin/rerun +12 -12
- data/lib/goo.rb +3 -0
- data/lib/rerun.rb +15 -15
- data/lib/rerun/notification.rb +82 -64
- data/lib/rerun/options.rb +142 -119
- data/lib/rerun/runner.rb +375 -334
- data/lib/rerun/system.rb +22 -22
- data/lib/rerun/watcher.rb +130 -119
- data/rerun.gemspec +34 -34
- metadata +4 -3
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/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,119 +1,130 @@
|
|
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
|
-
}.merge(options)
|
37
|
-
|
38
|
-
@pattern = options[:pattern]
|
39
|
-
@directories = options[:directory]
|
40
|
-
@directories = sanitize_dirs(@directories)
|
41
|
-
@priority = options[:priority]
|
42
|
-
@
|
43
|
-
@
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
dirs
|
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
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
+
}.merge(options)
|
37
|
+
|
38
|
+
@pattern = options[:pattern]
|
39
|
+
@directories = options[:directory]
|
40
|
+
@directories = sanitize_dirs(@directories)
|
41
|
+
@priority = options[:priority]
|
42
|
+
@force_polling = options[:force_polling]
|
43
|
+
@ignore = [options[:ignore]].flatten.compact
|
44
|
+
@thread = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def sanitize_dirs(dirs)
|
48
|
+
dirs = [*dirs]
|
49
|
+
dirs.map do |d|
|
50
|
+
d.chomp!("/")
|
51
|
+
unless FileTest.exists?(d) && FileTest.readable?(d) && FileTest.directory?(d)
|
52
|
+
raise InvalidDirectoryError, "Directory '#{d}' either doesnt exist or isn't readable"
|
53
|
+
end
|
54
|
+
File.expand_path(d)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def start
|
59
|
+
if @thread then
|
60
|
+
raise RuntimeError, "already started"
|
61
|
+
end
|
62
|
+
|
63
|
+
@thread = Thread.new do
|
64
|
+
@listener = Listen.to(*@directories, only: watching, ignore: ignoring, wait_for_delay: 1, force_polling: @force_polling) do |modified, added, removed|
|
65
|
+
if((modified.size + added.size + removed.size) > 0)
|
66
|
+
@client_callback.call(:modified => modified, :added => added, :removed => removed)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
@listener.start
|
70
|
+
end
|
71
|
+
|
72
|
+
@thread.priority = @priority
|
73
|
+
|
74
|
+
sleep 0.1 until @listener
|
75
|
+
|
76
|
+
at_exit { stop } # try really hard to clean up after ourselves
|
77
|
+
end
|
78
|
+
|
79
|
+
def watching
|
80
|
+
Rerun::Glob.new(@pattern).to_regexp
|
81
|
+
end
|
82
|
+
|
83
|
+
def ignoring
|
84
|
+
# todo: --no-ignore-dotfiles
|
85
|
+
dotfiles = /^\.[^.]/ # at beginning of string, a real dot followed by any other character
|
86
|
+
[dotfiles] + @ignore.map { |x| Rerun::Glob.new(x).to_regexp }
|
87
|
+
end
|
88
|
+
|
89
|
+
# kill the file watcher thread
|
90
|
+
def stop
|
91
|
+
@thread.wakeup rescue ThreadError
|
92
|
+
begin
|
93
|
+
@listener.stop
|
94
|
+
rescue Exception => e
|
95
|
+
puts "#{e.class}: #{e.message} stopping listener"
|
96
|
+
end
|
97
|
+
@thread.kill rescue ThreadError
|
98
|
+
end
|
99
|
+
|
100
|
+
# wait for the file watcher to finish
|
101
|
+
def join
|
102
|
+
@thread.join if @thread
|
103
|
+
rescue Interrupt => e
|
104
|
+
# don't care
|
105
|
+
end
|
106
|
+
|
107
|
+
def pause
|
108
|
+
@listener.pause if @listener
|
109
|
+
end
|
110
|
+
|
111
|
+
def unpause
|
112
|
+
@listener.start if @listener
|
113
|
+
end
|
114
|
+
|
115
|
+
def running?
|
116
|
+
@listener && @listener.processing?
|
117
|
+
end
|
118
|
+
|
119
|
+
def adapter
|
120
|
+
@listener &&
|
121
|
+
(backend = @listener.instance_variable_get(:@backend)) &&
|
122
|
+
backend.instance_variable_get(:@adapter)
|
123
|
+
end
|
124
|
+
|
125
|
+
def adapter_name
|
126
|
+
adapter && adapter.class.name.split('::').last
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
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.
|
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.12.0'
|
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.
|
4
|
+
version: 0.12.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:
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- bin/rerun
|
40
40
|
- icons/rails_grn_sml.png
|
41
41
|
- icons/rails_red_sml.png
|
42
|
+
- lib/goo.rb
|
42
43
|
- lib/rerun.rb
|
43
44
|
- lib/rerun/glob.rb
|
44
45
|
- lib/rerun/notification.rb
|
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
68
|
version: '0'
|
68
69
|
requirements: []
|
69
70
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
71
|
+
rubygems_version: 2.5.2
|
71
72
|
signing_key:
|
72
73
|
specification_version: 2
|
73
74
|
summary: Launches an app, and restarts it whenever the filesystem changes. A no-frills,
|