guard-rack 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Guard::Rack [![Build Status](http://travis-ci.org/johnbintz/guard-rack.png)](http://travis-ci.org/dblock/guard-rack)
1
+ Guard::Rack [![Build Status](http://travis-ci.org/dblock/guard-rack.png)](http://travis-ci.org/dblock/guard-rack)
2
2
  ===========
3
3
 
4
4
  Want to restart your Rack development with *rackup* whilst you work? Now you can!
@@ -31,4 +31,3 @@ MIT License, see [LICENSE](http://github.com/dblock/guard-rack/raw/master/LICENS
31
31
 
32
32
  (c) 2012 [Daniel Doubrovkine](http://github.com/dblock)
33
33
 
34
-
@@ -11,6 +11,11 @@ module Guard
11
11
  @options = options
12
12
  end
13
13
 
14
+ def kill pid
15
+ system %{kill -INT #{pid}}
16
+ $?.exitstatus
17
+ end
18
+
14
19
  def start
15
20
  kill_unmanaged_pid! if options[:force_run]
16
21
  run_rack_command!
@@ -18,16 +23,22 @@ module Guard
18
23
  end
19
24
 
20
25
  def stop
21
- if File.file?(pid_file)
22
- system %{kill -KILL #{File.read(pid_file).strip}}
23
- wait_for_no_pid if $?.exitstatus == 0
24
- FileUtils.rm pid_file
26
+ # Rely on kill_unmanaged_pid if there's no pid file
27
+ return true unless File.file?(pid_file)
28
+
29
+ if kill(pid) == 0
30
+ wait_for_no_pid
31
+ remove_pid_file
32
+ else
33
+ UI.info "Rackup exited with non-zero exit status whilst trying to stop."
34
+ return false
25
35
  end
36
+
37
+ true
26
38
  end
27
39
 
28
40
  def restart
29
- stop
30
- start
41
+ stop and start
31
42
  end
32
43
 
33
44
  def build_rack_command
@@ -51,6 +62,10 @@ module Guard
51
62
  File.file?(pid_file) ? File.read(pid_file).to_i : nil
52
63
  end
53
64
 
65
+ def remove_pid_file
66
+ FileUtils.rm pid_file if File.exist? pid_file
67
+ end
68
+
54
69
  def sleep_time
55
70
  options[:timeout].to_f / MAX_WAIT_COUNT.to_f
56
71
  end
@@ -71,16 +86,16 @@ module Guard
71
86
 
72
87
  def kill_unmanaged_pid!
73
88
  if pid = unmanaged_pid
74
- system %{kill -KILL #{pid}}
75
- FileUtils.rm pid_file
89
+ kill pid
76
90
  wait_for_no_pid
91
+ remove_pid_file
77
92
  end
78
93
  end
79
94
 
80
95
  def unmanaged_pid
81
96
  %x{lsof -n -i TCP:#{options[:port]}}.each_line { |line|
82
97
  if line["*:#{options[:port]} "]
83
- return line.split("\s")[1]
98
+ return line.split("\s")[1].to_i
84
99
  end
85
100
  }
86
101
  nil
@@ -106,5 +121,4 @@ module Guard
106
121
  end
107
122
 
108
123
  end
109
- end
110
-
124
+ end
@@ -1,6 +1,6 @@
1
1
  module Guard
2
2
  module RackVersion
3
- VERSION = '1.0'
3
+ VERSION = '1.1'
4
4
  end
5
5
  end
6
6
 
data/lib/guard/rack.rb CHANGED
@@ -45,7 +45,7 @@ module Guard
45
45
  runner.stop
46
46
  end
47
47
 
48
- def run_on_change(paths)
48
+ def run_on_changes(paths)
49
49
  reload
50
50
  end
51
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-23 00:00:00.000000000Z
12
+ date: 2012-06-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard-rack
16
- requirement: &81364010 !ruby/object:Gem::Requirement
16
+ requirement: &72033700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *81364010
24
+ version_requirements: *72033700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard
27
- requirement: &81363220 !ruby/object:Gem::Requirement
27
+ requirement: &72032770 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: '1.1'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *81363220
35
+ version_requirements: *72032770
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rb-inotify
38
- requirement: &81362390 !ruby/object:Gem::Requirement
38
+ requirement: &72015030 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.5.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *81362390
46
+ version_requirements: *72015030
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: libnotify
49
- requirement: &81361750 !ruby/object:Gem::Requirement
49
+ requirement: &72014380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,76 @@ dependencies:
54
54
  version: 0.1.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *81361750
57
+ version_requirements: *72014380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &81361280 !ruby/object:Gem::Requirement
60
+ requirement: &72013970 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *72013970
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &72013540 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *72013540
80
+ - !ruby/object:Gem::Dependency
81
+ name: bundler
82
+ requirement: &72013130 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '1.0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *72013130
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: &72012710 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: '2.6'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *72012710
102
+ - !ruby/object:Gem::Dependency
103
+ name: jeweler
104
+ requirement: &72012050 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.6'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *72012050
113
+ - !ruby/object:Gem::Dependency
114
+ name: guard-rspec
115
+ requirement: &72011490 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *72011490
124
+ - !ruby/object:Gem::Dependency
125
+ name: fakefs
126
+ requirement: &72009760 !ruby/object:Gem::Requirement
61
127
  none: false
62
128
  requirements:
63
129
  - - ! '>='
@@ -65,10 +131,10 @@ dependencies:
65
131
  version: '0'
66
132
  type: :development
67
133
  prerelease: false
68
- version_requirements: *81361280
134
+ version_requirements: *72009760
69
135
  - !ruby/object:Gem::Dependency
70
136
  name: rake
71
- requirement: &81360690 !ruby/object:Gem::Requirement
137
+ requirement: &72009230 !ruby/object:Gem::Requirement
72
138
  none: false
73
139
  requirements:
74
140
  - - ! '>='
@@ -76,10 +142,10 @@ dependencies:
76
142
  version: '0'
77
143
  type: :development
78
144
  prerelease: false
79
- version_requirements: *81360690
145
+ version_requirements: *72009230
80
146
  - !ruby/object:Gem::Dependency
81
147
  name: bundler
82
- requirement: &81360080 !ruby/object:Gem::Requirement
148
+ requirement: &72008500 !ruby/object:Gem::Requirement
83
149
  none: false
84
150
  requirements:
85
151
  - - ~>
@@ -87,10 +153,10 @@ dependencies:
87
153
  version: '1.0'
88
154
  type: :development
89
155
  prerelease: false
90
- version_requirements: *81360080
156
+ version_requirements: *72008500
91
157
  - !ruby/object:Gem::Dependency
92
158
  name: rspec
93
- requirement: &81359470 !ruby/object:Gem::Requirement
159
+ requirement: &72007960 !ruby/object:Gem::Requirement
94
160
  none: false
95
161
  requirements:
96
162
  - - ~>
@@ -98,10 +164,10 @@ dependencies:
98
164
  version: '2.6'
99
165
  type: :development
100
166
  prerelease: false
101
- version_requirements: *81359470
167
+ version_requirements: *72007960
102
168
  - !ruby/object:Gem::Dependency
103
169
  name: jeweler
104
- requirement: &81336310 !ruby/object:Gem::Requirement
170
+ requirement: &72007220 !ruby/object:Gem::Requirement
105
171
  none: false
106
172
  requirements:
107
173
  - - ~>
@@ -109,10 +175,10 @@ dependencies:
109
175
  version: '1.6'
110
176
  type: :development
111
177
  prerelease: false
112
- version_requirements: *81336310
178
+ version_requirements: *72007220
113
179
  - !ruby/object:Gem::Dependency
114
180
  name: guard-rspec
115
- requirement: &81335760 !ruby/object:Gem::Requirement
181
+ requirement: &71996490 !ruby/object:Gem::Requirement
116
182
  none: false
117
183
  requirements:
118
184
  - - ! '>='
@@ -120,10 +186,10 @@ dependencies:
120
186
  version: '0'
121
187
  type: :development
122
188
  prerelease: false
123
- version_requirements: *81335760
189
+ version_requirements: *71996490
124
190
  - !ruby/object:Gem::Dependency
125
191
  name: fakefs
126
- requirement: &81335090 !ruby/object:Gem::Requirement
192
+ requirement: &71996010 !ruby/object:Gem::Requirement
127
193
  none: false
128
194
  requirements:
129
195
  - - ! '>='
@@ -131,10 +197,10 @@ dependencies:
131
197
  version: '0'
132
198
  type: :development
133
199
  prerelease: false
134
- version_requirements: *81335090
200
+ version_requirements: *71996010
135
201
  - !ruby/object:Gem::Dependency
136
202
  name: rake
137
- requirement: &81334550 !ruby/object:Gem::Requirement
203
+ requirement: &71995180 !ruby/object:Gem::Requirement
138
204
  none: false
139
205
  requirements:
140
206
  - - ! '>='
@@ -142,10 +208,10 @@ dependencies:
142
208
  version: '0'
143
209
  type: :development
144
210
  prerelease: false
145
- version_requirements: *81334550
211
+ version_requirements: *71995180
146
212
  - !ruby/object:Gem::Dependency
147
213
  name: bundler
148
- requirement: &81333950 !ruby/object:Gem::Requirement
214
+ requirement: &71994090 !ruby/object:Gem::Requirement
149
215
  none: false
150
216
  requirements:
151
217
  - - ~>
@@ -153,10 +219,10 @@ dependencies:
153
219
  version: '1.0'
154
220
  type: :development
155
221
  prerelease: false
156
- version_requirements: *81333950
222
+ version_requirements: *71994090
157
223
  - !ruby/object:Gem::Dependency
158
224
  name: rspec
159
- requirement: &81333420 !ruby/object:Gem::Requirement
225
+ requirement: &71993440 !ruby/object:Gem::Requirement
160
226
  none: false
161
227
  requirements:
162
228
  - - ~>
@@ -164,10 +230,10 @@ dependencies:
164
230
  version: '2.6'
165
231
  type: :development
166
232
  prerelease: false
167
- version_requirements: *81333420
233
+ version_requirements: *71993440
168
234
  - !ruby/object:Gem::Dependency
169
235
  name: jeweler
170
- requirement: &81332860 !ruby/object:Gem::Requirement
236
+ requirement: &71992660 !ruby/object:Gem::Requirement
171
237
  none: false
172
238
  requirements:
173
239
  - - ~>
@@ -175,10 +241,10 @@ dependencies:
175
241
  version: '1.6'
176
242
  type: :development
177
243
  prerelease: false
178
- version_requirements: *81332860
244
+ version_requirements: *71992660
179
245
  - !ruby/object:Gem::Dependency
180
246
  name: guard-rspec
181
- requirement: &81332400 !ruby/object:Gem::Requirement
247
+ requirement: &71992090 !ruby/object:Gem::Requirement
182
248
  none: false
183
249
  requirements:
184
250
  - - ! '>='
@@ -186,10 +252,10 @@ dependencies:
186
252
  version: '0'
187
253
  type: :development
188
254
  prerelease: false
189
- version_requirements: *81332400
255
+ version_requirements: *71992090
190
256
  - !ruby/object:Gem::Dependency
191
257
  name: fakefs
192
- requirement: &81331910 !ruby/object:Gem::Requirement
258
+ requirement: &71991570 !ruby/object:Gem::Requirement
193
259
  none: false
194
260
  requirements:
195
261
  - - ! '>='
@@ -197,10 +263,10 @@ dependencies:
197
263
  version: '0'
198
264
  type: :development
199
265
  prerelease: false
200
- version_requirements: *81331910
266
+ version_requirements: *71991570
201
267
  - !ruby/object:Gem::Dependency
202
268
  name: rake
203
- requirement: &81331400 !ruby/object:Gem::Requirement
269
+ requirement: &71991090 !ruby/object:Gem::Requirement
204
270
  none: false
205
271
  requirements:
206
272
  - - ! '>='
@@ -208,10 +274,10 @@ dependencies:
208
274
  version: '0'
209
275
  type: :development
210
276
  prerelease: false
211
- version_requirements: *81331400
277
+ version_requirements: *71991090
212
278
  - !ruby/object:Gem::Dependency
213
279
  name: bundler
214
- requirement: &81330920 !ruby/object:Gem::Requirement
280
+ requirement: &71990010 !ruby/object:Gem::Requirement
215
281
  none: false
216
282
  requirements:
217
283
  - - ~>
@@ -219,10 +285,10 @@ dependencies:
219
285
  version: '1.0'
220
286
  type: :development
221
287
  prerelease: false
222
- version_requirements: *81330920
288
+ version_requirements: *71990010
223
289
  - !ruby/object:Gem::Dependency
224
290
  name: rspec
225
- requirement: &81330330 !ruby/object:Gem::Requirement
291
+ requirement: &71989250 !ruby/object:Gem::Requirement
226
292
  none: false
227
293
  requirements:
228
294
  - - ~>
@@ -230,10 +296,10 @@ dependencies:
230
296
  version: '2.6'
231
297
  type: :development
232
298
  prerelease: false
233
- version_requirements: *81330330
299
+ version_requirements: *71989250
234
300
  - !ruby/object:Gem::Dependency
235
301
  name: jeweler
236
- requirement: &81329900 !ruby/object:Gem::Requirement
302
+ requirement: &71976890 !ruby/object:Gem::Requirement
237
303
  none: false
238
304
  requirements:
239
305
  - - ~>
@@ -241,10 +307,10 @@ dependencies:
241
307
  version: '1.6'
242
308
  type: :development
243
309
  prerelease: false
244
- version_requirements: *81329900
310
+ version_requirements: *71976890
245
311
  - !ruby/object:Gem::Dependency
246
312
  name: guard-rspec
247
- requirement: &81329360 !ruby/object:Gem::Requirement
313
+ requirement: &71976220 !ruby/object:Gem::Requirement
248
314
  none: false
249
315
  requirements:
250
316
  - - ! '>='
@@ -252,10 +318,10 @@ dependencies:
252
318
  version: '0'
253
319
  type: :development
254
320
  prerelease: false
255
- version_requirements: *81329360
321
+ version_requirements: *71976220
256
322
  - !ruby/object:Gem::Dependency
257
323
  name: fakefs
258
- requirement: &81328770 !ruby/object:Gem::Requirement
324
+ requirement: &71975630 !ruby/object:Gem::Requirement
259
325
  none: false
260
326
  requirements:
261
327
  - - ! '>='
@@ -263,7 +329,7 @@ dependencies:
263
329
  version: '0'
264
330
  type: :development
265
331
  prerelease: false
266
- version_requirements: *81328770
332
+ version_requirements: *71975630
267
333
  description:
268
334
  email: dblock@dblock.org
269
335
  executables: []
@@ -294,7 +360,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
294
360
  version: '0'
295
361
  segments:
296
362
  - 0
297
- hash: -587883089
363
+ hash: 198270653
298
364
  required_rubygems_version: !ruby/object:Gem::Requirement
299
365
  none: false
300
366
  requirements: