restart 1.0.2 → 2.0.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 +4 -4
- data/README.md +2 -13
- data/lib/restart.rb +29 -53
- data/lib/restart/version.rb +1 -1
- data/restart.gemspec +4 -4
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7e0e224e8faa47590340eba2a9e611876439426
|
4
|
+
data.tar.gz: eb7175aee0bd3e1c5807bbe1ee03f6d71339066b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0f12e067687fb15e13d0322394f82c8506f7aeb96e3fefccdbeaa75a681d87cc3b096b2b5df588312892eaaf1f9927ba7db5a0886c052b381cae4bd72c3371
|
7
|
+
data.tar.gz: 725e8867f1950d31dae2fef0b67ab7e7bacbf428692b3cd4385514ce29e9bcb65a6a4e7efe12eb80afa4e67d14382f0aaf134bcdbf9961b876bab3a73ad2e9a0
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Restart
|
2
2
|
|
3
|
-
|
3
|
+
On MS Windows, restart runs your shell command, then re-runs it any time filesystem change is detected.
|
4
4
|
|
5
5
|
EXAMPLE: `restart ruby test.rb`
|
6
6
|
|
@@ -10,20 +10,10 @@ This will run `ruby test.rb`, then re-run it after the test.rb file changes (or
|
|
10
10
|
|
11
11
|
`gem install restart`
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
The process of installing this gem involves building native extensions because of its dependency on the [listen](https://rubygems.org/gems/listen) gem. If you have not already installed [DevKit](http://rubyinstaller.org/add-ons/devkit/) from [RubyInstaller.org](http://rubyinstaller.org), you will need to get it installed and working on your system before installing any gems that depend on building native extensions. To get started, [download DevKit](http://rubyinstaller.org/downloads/), and follow [these step-by-step installation instructions](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit).
|
16
|
-
|
17
|
-
Once DevKit is installed and working, you are ready to install this gem:
|
18
|
-
|
19
|
-
`gem install restart`
|
20
|
-
|
21
|
-
It is _highly recommended_ that you also install the [wdm](https://rubygems.org/gems/wdm) gem, which enables [listen](https://rubygems.org/gems/listen) to receive filesystem event notifications from Windows instead of polling the filesystem for changes (you DO NOT want to use polling):
|
13
|
+
It is _highly recommended_ that you also install the [wdm](https://rubygems.org/gems/wdm) gem, which enables [listen](https://rubygems.org/gems/listen) to receive filesystem event notifications from Windows instead of polling the filesystem for changes:
|
22
14
|
|
23
15
|
`gem install wdm`
|
24
16
|
|
25
|
-
That's all - you should now be able to start using the `restart` command.
|
26
|
-
|
27
17
|
## Usage
|
28
18
|
|
29
19
|
```
|
@@ -47,7 +37,6 @@ OPTIONS:
|
|
47
37
|
|
48
38
|
-i, --ignore REGX[,REGX...] Ignore file paths matching regular expression.
|
49
39
|
Examples:
|
50
|
-
restart -i /foo/bar/
|
51
40
|
restart -i \.pid$,\.coffee$
|
52
41
|
restart -i \.pid$ -i \.coffee$
|
53
42
|
|
data/lib/restart.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'restart/version'
|
2
|
+
require 'optparse'
|
3
|
+
require 'listen'
|
2
4
|
|
3
|
-
Restart::BANNER = <<-BANNER
|
5
|
+
Restart::BANNER = <<-BANNER.freeze
|
4
6
|
USAGE: restart [options] <your shell command>
|
5
7
|
|
6
8
|
Runs your shell command, then re-runs it any time filesystem change is detected.
|
@@ -11,16 +13,14 @@ This will run "ruby test.rb", then re-run it after test.rb file changes (or any
|
|
11
13
|
other files change in current working directory or any subdirectories under it).
|
12
14
|
|
13
15
|
See http://github.com/vais/restart for more info.
|
14
|
-
Version: #{
|
16
|
+
Version: #{Restart::VERSION}
|
15
17
|
|
16
18
|
OPTIONS:
|
17
19
|
BANNER
|
18
20
|
|
19
|
-
require 'optparse'
|
20
21
|
options = {}
|
21
22
|
|
22
23
|
option_parser = OptionParser.new(Restart::BANNER, 28, ' ') do |opts|
|
23
|
-
|
24
24
|
options[:dir] = []
|
25
25
|
opts.on(
|
26
26
|
'-d', '--dir DIR[,DIR...]',
|
@@ -33,10 +33,11 @@ option_parser = OptionParser.new(Restart::BANNER, 28, ' ') do |opts|
|
|
33
33
|
' restart -d . -d ../test -d ../lib rake test',
|
34
34
|
' '
|
35
35
|
) do |dirs|
|
36
|
-
dirs.
|
36
|
+
dirs.map do |dir|
|
37
37
|
unless File.directory?(dir)
|
38
|
-
|
38
|
+
raise OptionParser::InvalidArgument, "#{dir} is not a valid directory"
|
39
39
|
end
|
40
|
+
File.expand_path(dir)
|
40
41
|
end
|
41
42
|
options[:dir] += dirs
|
42
43
|
end
|
@@ -66,7 +67,6 @@ option_parser = OptionParser.new(Restart::BANNER, 28, ' ') do |opts|
|
|
66
67
|
Array,
|
67
68
|
'Ignore file paths matching regular expression.',
|
68
69
|
'Examples:',
|
69
|
-
' restart -i /foo/bar/',
|
70
70
|
' restart -i \.pid$,\.coffee$',
|
71
71
|
' restart -i \.pid$ -i \.coffee$',
|
72
72
|
' '
|
@@ -98,67 +98,43 @@ option_parser = OptionParser.new(Restart::BANNER, 28, ' ') do |opts|
|
|
98
98
|
end
|
99
99
|
|
100
100
|
option_parser.order!
|
101
|
-
|
102
|
-
options[:
|
101
|
+
|
102
|
+
options[:dir] = options[:dir].empty? ? [Dir.pwd] : options[:dir].uniq
|
103
|
+
options[:command] = ARGV.map { |s| s =~ /\s/ ? %("#{s}") : s }.join(' ')
|
104
|
+
|
103
105
|
if options[:explain]
|
104
106
|
require 'pp'
|
105
107
|
options.delete(:explain)
|
106
108
|
pp options
|
107
109
|
exit
|
108
110
|
end
|
111
|
+
|
109
112
|
if options[:command].empty?
|
110
113
|
puts option_parser
|
111
114
|
exit
|
112
115
|
end
|
113
116
|
|
114
|
-
|
115
|
-
|
117
|
+
listener_options = {}
|
118
|
+
listener_options[:only] = options[:file] unless options[:file].empty?
|
119
|
+
listener_options[:ignore] = options[:ignore] unless options[:ignore].empty?
|
120
|
+
|
116
121
|
process = Process.detach(spawn(options[:command]))
|
117
122
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
end
|
128
|
-
clear = proc do
|
129
|
-
system 'cls'
|
130
|
-
end
|
131
|
-
rescue LoadError
|
132
|
-
killer = proc do
|
133
|
-
Process.kill(:INT, -Process.getpgrp)
|
134
|
-
sleep 0.1
|
135
|
-
if process.alive?
|
136
|
-
Process.kill(:KILL, process.pid)
|
137
|
-
end
|
138
|
-
end
|
139
|
-
clear = proc do
|
140
|
-
system 'clear'
|
141
|
-
end
|
123
|
+
listener = Listen.to(*options[:dir], listener_options) do
|
124
|
+
system("taskkill /t /f /pid #{process.pid} > nul 2>&1") if process.alive?
|
125
|
+
system('cls') if options[:clear]
|
126
|
+
print "\n\e[7m"
|
127
|
+
print Time.now.strftime('%H:%M:%S')
|
128
|
+
print ' '
|
129
|
+
print options[:command]
|
130
|
+
print "\e[0m\n\n"
|
131
|
+
process = Process.detach(spawn(options[:command]))
|
142
132
|
end
|
143
133
|
|
144
134
|
trap('INT') do
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
listener_options = {}
|
149
|
-
unless options[:file].empty?
|
150
|
-
listener_options[:only] = options[:file]
|
151
|
-
end
|
152
|
-
unless options[:ignore].empty?
|
153
|
-
listener_options[:ignore] = options[:ignore]
|
154
|
-
end
|
155
|
-
listener = Listen.to(*options[:dir], listener_options) do
|
156
|
-
restarting = true
|
157
|
-
killer.call
|
158
|
-
restarting = false
|
159
|
-
clear.call if options[:clear]
|
160
|
-
print "\n\e[7m#{ Time.now.strftime('%H:%M:%S') } #{ options[:command] }\e[0m\n\n"
|
161
|
-
process = Process.detach(spawn(options[:command]))
|
135
|
+
system("taskkill /t /f /pid #{process.pid} > nul 2>&1") if process.alive?
|
136
|
+
listener.stop
|
137
|
+
exit
|
162
138
|
end
|
163
139
|
|
164
140
|
listener.start
|
data/lib/restart/version.rb
CHANGED
data/restart.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Restart::VERSION
|
9
9
|
spec.authors = ["Vais Salikhov"]
|
10
10
|
spec.email = ["vsalikhov@gmail.com"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{On MS Windows, restart runs your shell command, then re-runs it any time filesystem change is detected.}
|
12
|
+
spec.description = %q{On MS Windows, restart runs your shell command, then re-runs it any time filesystem change is detected. For example, "restart ruby test.rb" will run "ruby test.rb", then re-run it after test.rb file changes (or any other files change in current working directory or any subdirectories under it).}
|
13
13
|
spec.homepage = "http://github.com/vais/restart"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "listen", "~> 3.0"
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler"
|
24
|
-
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake"
|
25
25
|
end
|
metadata
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vais Salikhov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-11 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
19
|
version: '3.0'
|
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
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
description:
|
56
|
-
detected. For example, "restart ruby test.rb" will run "ruby
|
57
|
-
it after test.rb file changes (or any other files change in
|
58
|
-
or any subdirectories under it).
|
54
|
+
version: '0'
|
55
|
+
description: On MS Windows, restart runs your shell command, then re-runs it any time
|
56
|
+
filesystem change is detected. For example, "restart ruby test.rb" will run "ruby
|
57
|
+
test.rb", then re-run it after test.rb file changes (or any other files change in
|
58
|
+
current working directory or any subdirectories under it).
|
59
59
|
email:
|
60
60
|
- vsalikhov@gmail.com
|
61
61
|
executables:
|
@@ -63,7 +63,7 @@ executables:
|
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
65
65
|
files:
|
66
|
-
- .gitignore
|
66
|
+
- ".gitignore"
|
67
67
|
- Gemfile
|
68
68
|
- LICENSE.txt
|
69
69
|
- README.md
|
@@ -82,19 +82,19 @@ require_paths:
|
|
82
82
|
- lib
|
83
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- -
|
90
|
+
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.6.13
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
|
-
summary:
|
98
|
+
summary: On MS Windows, restart runs your shell command, then re-runs it any time
|
99
|
+
filesystem change is detected.
|
99
100
|
test_files: []
|
100
|
-
has_rdoc:
|