restart 1.0.2 → 2.0.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: ca66f6c566aead10c36322c7ec101889aea52ac7
4
- data.tar.gz: d822ab6899a4c6054973c4689a7a42e00e8f6aaa
3
+ metadata.gz: d7e0e224e8faa47590340eba2a9e611876439426
4
+ data.tar.gz: eb7175aee0bd3e1c5807bbe1ee03f6d71339066b
5
5
  SHA512:
6
- metadata.gz: 580360f9196c85abb452a2e48c88c85d0331dd13f72b45ff7ee999df81bae77d0eb07337329d2935494862d74920b071ae2c38463d8be03097cc3de6ec7bdf52
7
- data.tar.gz: de1cbe504b5daae9d25e39d72cfba1a77dbaf65f38f42828789580ba893390a15114c54494aef88bb32782be16122dac2fef8234c9a223df8173f258c7a7d0f4
6
+ metadata.gz: 2c0f12e067687fb15e13d0322394f82c8506f7aeb96e3fefccdbeaa75a681d87cc3b096b2b5df588312892eaaf1f9927ba7db5a0886c052b381cae4bd72c3371
7
+ data.tar.gz: 725e8867f1950d31dae2fef0b67ab7e7bacbf428692b3cd4385514ce29e9bcb65a6a4e7efe12eb80afa4e67d14382f0aaf134bcdbf9961b876bab3a73ad2e9a0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Restart
2
2
 
3
- Runs your shell command, then re-runs it any time filesystem change is detected.
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
- ## Windows Installation
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
 
@@ -1,6 +1,8 @@
1
- require "restart/version"
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: #{ Restart::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.each do |dir|
36
+ dirs.map do |dir|
37
37
  unless File.directory?(dir)
38
- fail OptionParser::InvalidArgument, "#{ dir } is not a valid directory"
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
- options[:dir] << '.' if options[:dir].empty?
102
- options[:command] = ARGV.map{|s| s =~ /\s/ ? %Q{"#{ s }"} : s}.join(' ')
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
- require 'listen'
115
- restarting = false
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
- begin
119
- require 'win32api'
120
- ctrl_c = Win32API.new('Kernel32', 'GenerateConsoleCtrlEvent', 'II', 'I')
121
- killer = proc do
122
- ctrl_c.call(0, 0)
123
- sleep 0.1
124
- if process.alive?
125
- Process.kill(:KILL, process.pid)
126
- end
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
- exit unless restarting || process.alive?
146
- end
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
@@ -1,3 +1,3 @@
1
1
  module Restart
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -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{Runs your shell command, then re-runs it any time filesystem change is detected.}
12
- spec.description = %q{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).}
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", "~> 1.6"
24
- spec.add_development_dependency "rake", "~> 10.0"
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: 1.0.2
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: 2015-09-02 00:00:00.000000000 Z
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: '1.6'
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: '1.6'
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: '10.0'
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: '10.0'
55
- description: Runs your shell command, then re-runs it any time filesystem change is
56
- detected. For example, "restart ruby test.rb" will run "ruby test.rb", then re-run
57
- it after test.rb file changes (or any other files change in current working directory
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.0.3
95
+ rubygems_version: 2.6.13
96
96
  signing_key:
97
97
  specification_version: 4
98
- summary: Runs your shell command, then re-runs it any time filesystem change is detected.
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: