machinegun 0.1.0 → 0.2.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: 6b524811b2c23d4a050e5473d1b53ae1777dd2a6
4
- data.tar.gz: d616bd518cc62ab1ba3055bebca11ee5833b9fef
3
+ metadata.gz: 7137f868e393550a7ea7673c5b6ac8d794e9d878
4
+ data.tar.gz: f4a42b7b3a2f75f12ec4749b024015e2ab1e016c
5
5
  SHA512:
6
- metadata.gz: 169fcc2a682b66388a492a614b3b0b58e96e0c7ce203e601faefe2a61d3da0e57d38e03c7e319fa2aca4b7d15b9f5a0ed223fa17ab67c28f6ace8e41c8aec646
7
- data.tar.gz: 03b2e046e1e056728d91f2f7628d8dba0e1f6488de8655b6327aaaf52a6de803931cdc6add7810e87b4fea2704f6fdd9a87deea1f78ee86056d8fd06a074b190
6
+ metadata.gz: 1f903d783b3b56c81546ff11f5610c440c046ea9a19ef7cc89fc3764ce611b37cbea40f219e4e64a7fa56df18b5603e5233da8069e375d8995ce9da8428a01c2
7
+ data.tar.gz: 1e8c941cb8a7f8d51ffde2927571759d95f19f678025dd3d1de68cd681401ffaa1609904c446a7463b398b285d14ffc6b82ad52e51c62b0ad59b026afbdb5f2c
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # machinegun
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/machinegun.svg)](https://badge.fury.io/rb/machinegun)
4
+ [![Coverage Status](https://coveralls.io/repos/amclain/machinegun/badge.svg?branch=master&service=github)](https://coveralls.io/github/amclain/machinegun?branch=master)
5
+ [![API Documentation](https://img.shields.io/badge/docs-api-blue.svg)](http://www.rubydoc.info/gems/machinegun)
6
+ [![MIT License](https://img.shields.io/badge/license-MIT-yellowgreen.svg)](https://github.com/amclain/machinegun/blob/master/license.txt)
4
7
 
5
8
  An automatic reloading Rack development web server for Ruby.
6
9
 
@@ -21,3 +24,10 @@ For example, the following command will launch the web server on port 9393 and b
21
24
  ```text
22
25
  $ machinegun -p 9393 -o 0.0.0.0
23
26
  ```
27
+
28
+ ## Development
29
+
30
+ To skip the integration tests during development, run the test suite with:
31
+ ```text
32
+ $ SKIP_INTEGRATION_TESTS=true bundle exec rake
33
+ ```
data/bin/machinegun CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative '../lib/machinegun'
4
4
 
5
- MachineGun.run
5
+ MachineGun.run interval: ENV["MACHINEGUN_INTERVAL"]
data/doc/MachineGun.html CHANGED
@@ -99,7 +99,18 @@
99
99
  </dl>
100
100
  <div class="clear"></div>
101
101
 
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>An automatic reloading Rack development web server for Ruby.</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
102
112
 
113
+ </div>
103
114
 
104
115
 
105
116
 
@@ -117,7 +128,114 @@
117
128
  <li class="public ">
118
129
  <span class="summary_signature">
119
130
 
120
- <a href="#run-class_method" title="run (class method)">+ (Object) <strong>run</strong> </a>
131
+ <a href="#run-class_method" title="run (class method)">+ (Object) <strong>run</strong>(*args) </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>Helper method to instantiate a new object and run the server.</p>
147
+ </div></span>
148
+
149
+ </li>
150
+
151
+
152
+ </ul>
153
+
154
+ <h2>
155
+ Instance Method Summary
156
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
157
+ </h2>
158
+
159
+ <ul class="summary">
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (MachineGun) <strong>initialize</strong> </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+ <span class="note title constructor">constructor</span>
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+ <span class="summary_desc"><div class='inline'>
181
+ <p>A new instance of MachineGun.</p>
182
+ </div></span>
183
+
184
+ </li>
185
+
186
+
187
+ <li class="public ">
188
+ <span class="summary_signature">
189
+
190
+ <a href="#run-instance_method" title="#run (instance method)">- (Object) <strong>run</strong>(opts = {}) </a>
191
+
192
+
193
+
194
+ </span>
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ <span class="summary_desc"><div class='inline'>
205
+ <p>Run the automatically-reloading web server.</p>
206
+ </div></span>
207
+
208
+ </li>
209
+
210
+
211
+ <li class="public ">
212
+ <span class="summary_signature">
213
+
214
+ <a href="#running%3F-instance_method" title="#running? (instance method)">- (Boolean) <strong>running?</strong> </a>
215
+
216
+
217
+
218
+ </span>
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+ <span class="summary_desc"><div class='inline'>
229
+ <p>True if the server is running.</p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ <li class="public ">
236
+ <span class="summary_signature">
237
+
238
+ <a href="#stop-instance_method" title="#stop (instance method)">- (Object) <strong>stop</strong> </a>
121
239
 
122
240
 
123
241
 
@@ -131,7 +249,9 @@
131
249
 
132
250
 
133
251
 
134
- <span class="summary_desc"><div class='inline'></div></span>
252
+ <span class="summary_desc"><div class='inline'>
253
+ <p>Stop watching for file changes and shutdown the web server.</p>
254
+ </div></span>
135
255
 
136
256
  </li>
137
257
 
@@ -139,6 +259,51 @@
139
259
  </ul>
140
260
 
141
261
 
262
+ <div id="constructor_details" class="method_details_list">
263
+ <h2>Constructor Details</h2>
264
+
265
+ <div class="method_details first">
266
+ <h3 class="signature first" id="initialize-instance_method">
267
+
268
+ - (<tt><span class='object_link'><a href="" title="MachineGun (class)">MachineGun</a></span></tt>) <strong>initialize</strong>
269
+
270
+
271
+
272
+
273
+
274
+ </h3><div class="docstring">
275
+ <div class="discussion">
276
+
277
+ <p>Returns a new instance of MachineGun</p>
278
+
279
+
280
+ </div>
281
+ </div>
282
+ <div class="tags">
283
+
284
+
285
+ </div><table class="source_code">
286
+ <tr>
287
+ <td>
288
+ <pre class="lines">
289
+
290
+
291
+ 13
292
+ 14
293
+ 15</pre>
294
+ </td>
295
+ <td>
296
+ <pre class="code"><span class="info file"># File 'lib/machinegun.rb', line 13</span>
297
+
298
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span>
299
+ <span class='ivar'>@running</span> <span class='op'>=</span> <span class='kw'>false</span>
300
+ <span class='kw'>end</span></pre>
301
+ </td>
302
+ </tr>
303
+ </table>
304
+ </div>
305
+
306
+ </div>
142
307
 
143
308
 
144
309
  <div id="class_method_details" class="method_details_list">
@@ -148,45 +313,271 @@
148
313
  <div class="method_details first">
149
314
  <h3 class="signature first" id="run-class_method">
150
315
 
151
- + (<tt>Object</tt>) <strong>run</strong>
316
+ + (<tt>Object</tt>) <strong>run</strong>(*args)
152
317
 
153
318
 
154
319
 
155
320
 
156
321
 
157
- </h3><table class="source_code">
322
+ </h3><div class="docstring">
323
+ <div class="discussion">
324
+
325
+ <p>Helper method to instantiate a new object and run the server.</p>
326
+
327
+
328
+ </div>
329
+ </div>
330
+ <div class="tags">
331
+
332
+
333
+ <p class="tag_title">See Also:</p>
334
+ <ul class="see">
335
+
336
+ <li><span class='object_link'><a href="#run-instance_method" title="MachineGun#run (method)">#run</a></span></li>
337
+
338
+ </ul>
339
+
340
+ </div><table class="source_code">
158
341
  <tr>
159
342
  <td>
160
343
  <pre class="lines">
161
344
 
162
345
 
163
- 6
164
- 7
165
- 8
166
346
  9
167
347
  10
168
- 11
169
- 12
170
- 13
171
- 14
172
- 15</pre>
348
+ 11</pre>
173
349
  </td>
174
350
  <td>
175
- <pre class="code"><span class="info file"># File 'lib/machinegun.rb', line 6</span>
351
+ <pre class="code"><span class="info file"># File 'lib/machinegun.rb', line 9</span>
352
+
353
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
354
+ <span class='id identifier rubyid_new'>new</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
355
+ <span class='kw'>end</span></pre>
356
+ </td>
357
+ </tr>
358
+ </table>
359
+ </div>
360
+
361
+ </div>
362
+
363
+ <div id="instance_method_details" class="method_details_list">
364
+ <h2>Instance Method Details</h2>
365
+
366
+
367
+ <div class="method_details first">
368
+ <h3 class="signature first" id="run-instance_method">
369
+
370
+ - (<tt>Object</tt>) <strong>run</strong>(opts = {})
371
+
372
+
373
+
374
+
375
+
376
+ </h3><div class="docstring">
377
+ <div class="discussion">
378
+
379
+ <p>Run the automatically-reloading web server. This method blocks.</p>
380
+
381
+
382
+ </div>
383
+ </div>
384
+ <div class="tags">
385
+ <p class="tag_title">Parameters:</p>
386
+ <ul class="param">
387
+
388
+ <li>
389
+
390
+ <span class='name'>opts</span>
391
+
392
+
393
+ <span class='type'>(<tt>Hash</tt>)</span>
394
+
395
+
396
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
397
+
398
+
399
+ &mdash;
400
+ <div class='inline'>
401
+ <p>a customizable set of options</p>
402
+ </div>
403
+
404
+ </li>
405
+
406
+ </ul>
176
407
 
177
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span>
178
- <span class='id identifier rubyid_pid'>pid</span> <span class='op'>=</span> <span class='id identifier rubyid_start_server'>start_server</span>
179
408
 
180
- <span class='const'>FileWatcher</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>./**/*.rb</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_watch'>watch</span> <span class='kw'>do</span>
181
- <span class='const'>Process</span><span class='period'>.</span><span class='id identifier rubyid_kill'>kill</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>INT</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_pid'>pid</span>
182
- <span class='const'>Process</span><span class='period'>.</span><span class='id identifier rubyid_wait'>wait</span> <span class='id identifier rubyid_pid'>pid</span>
183
409
 
184
- <span class='id identifier rubyid_pid'>pid</span> <span class='op'>=</span> <span class='id identifier rubyid_start_server'>start_server</span>
410
+
411
+ <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
412
+ <ul class="option">
413
+
414
+ <li>
415
+ <span class="name">:interval</span>
416
+ <span class="type">(<tt>Numeric</tt>)</span>
417
+ <span class="default">
418
+
419
+ &mdash; default:
420
+ <tt>0.5</tt>
421
+
422
+ </span>
423
+
424
+ &mdash; <div class='inline'>
425
+ <p>Interval in seconds to scan the filesystem for changes.</p>
426
+ </div>
427
+
428
+ </li>
429
+
430
+ </ul>
431
+
432
+
433
+
434
+ </div><table class="source_code">
435
+ <tr>
436
+ <td>
437
+ <pre class="lines">
438
+
439
+
440
+ 21
441
+ 22
442
+ 23
443
+ 24
444
+ 25
445
+ 26
446
+ 27
447
+ 28
448
+ 29
449
+ 30
450
+ 31
451
+ 32
452
+ 33</pre>
453
+ </td>
454
+ <td>
455
+ <pre class="code"><span class="info file"># File 'lib/machinegun.rb', line 21</span>
456
+
457
+ <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
458
+ <span class='ivar'>@running</span> <span class='op'>=</span> <span class='kw'>true</span>
459
+ <span class='id identifier rubyid_interval'>interval</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:interval</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='float'>0.5</span>
460
+
461
+ <span class='ivar'>@pid</span> <span class='op'>=</span> <span class='id identifier rubyid_start_server'>start_server</span>
462
+
463
+ <span class='ivar'>@watcher</span> <span class='op'>=</span> <span class='const'>FileWatcher</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>./**/*.rb</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
464
+
465
+ <span class='ivar'>@watcher</span><span class='period'>.</span><span class='id identifier rubyid_watch'>watch</span> <span class='id identifier rubyid_interval'>interval</span> <span class='kw'>do</span>
466
+ <span class='id identifier rubyid_stop_server'>stop_server</span>
467
+ <span class='ivar'>@pid</span> <span class='op'>=</span> <span class='id identifier rubyid_start_server'>start_server</span>
185
468
  <span class='kw'>end</span>
186
469
  <span class='kw'>end</span></pre>
187
470
  </td>
188
471
  </tr>
189
472
  </table>
473
+ </div>
474
+
475
+ <div class="method_details ">
476
+ <h3 class="signature " id="running?-instance_method">
477
+
478
+ - (<tt>Boolean</tt>) <strong>running?</strong>
479
+
480
+
481
+
482
+
483
+
484
+ </h3><div class="docstring">
485
+ <div class="discussion">
486
+
487
+ <p>Returns true if the server is running.</p>
488
+
489
+
490
+ </div>
491
+ </div>
492
+ <div class="tags">
493
+
494
+ <p class="tag_title">Returns:</p>
495
+ <ul class="return">
496
+
497
+ <li>
498
+
499
+
500
+ <span class='type'>(<tt>Boolean</tt>)</span>
501
+
502
+
503
+
504
+ &mdash;
505
+ <div class='inline'>
506
+ <p>true if the server is running.</p>
507
+ </div>
508
+
509
+ </li>
510
+
511
+ </ul>
512
+
513
+ </div><table class="source_code">
514
+ <tr>
515
+ <td>
516
+ <pre class="lines">
517
+
518
+
519
+ 45
520
+ 46
521
+ 47</pre>
522
+ </td>
523
+ <td>
524
+ <pre class="code"><span class="info file"># File 'lib/machinegun.rb', line 45</span>
525
+
526
+ <span class='kw'>def</span> <span class='id identifier rubyid_running?'>running?</span>
527
+ <span class='ivar'>@running</span>
528
+ <span class='kw'>end</span></pre>
529
+ </td>
530
+ </tr>
531
+ </table>
532
+ </div>
533
+
534
+ <div class="method_details ">
535
+ <h3 class="signature " id="stop-instance_method">
536
+
537
+ - (<tt>Object</tt>) <strong>stop</strong>
538
+
539
+
540
+
541
+
542
+
543
+ </h3><div class="docstring">
544
+ <div class="discussion">
545
+
546
+ <p>Stop watching for file changes and shutdown the web server.</p>
547
+
548
+
549
+ </div>
550
+ </div>
551
+ <div class="tags">
552
+
553
+
554
+ </div><table class="source_code">
555
+ <tr>
556
+ <td>
557
+ <pre class="lines">
558
+
559
+
560
+ 36
561
+ 37
562
+ 38
563
+ 39
564
+ 40
565
+ 41
566
+ 42</pre>
567
+ </td>
568
+ <td>
569
+ <pre class="code"><span class="info file"># File 'lib/machinegun.rb', line 36</span>
570
+
571
+ <span class='kw'>def</span> <span class='id identifier rubyid_stop'>stop</span>
572
+ <span class='kw'>return</span> <span class='kw'>unless</span> <span class='ivar'>@running</span>
573
+
574
+ <span class='ivar'>@watcher</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
575
+ <span class='id identifier rubyid_stop_server'>stop_server</span>
576
+ <span class='ivar'>@running</span> <span class='op'>=</span> <span class='kw'>false</span>
577
+ <span class='kw'>end</span></pre>
578
+ </td>
579
+ </tr>
580
+ </table>
190
581
  </div>
191
582
 
192
583
  </div>
@@ -194,9 +585,9 @@
194
585
  </div>
195
586
 
196
587
  <div id="footer">
197
- Generated on Fri Oct 23 11:08:57 2015 by
588
+ Generated on Sat Oct 24 18:31:28 2015 by
198
589
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
199
- 0.8.7.6 (ruby-2.1.1).
590
+ 0.8.7.6 (ruby-2.1.6).
200
591
  </div>
201
592
 
202
593
  </body>
data/doc/_index.html CHANGED
@@ -104,9 +104,9 @@
104
104
  </div>
105
105
 
106
106
  <div id="footer">
107
- Generated on Fri Oct 23 11:08:57 2015 by
107
+ Generated on Sat Oct 24 18:31:28 2015 by
108
108
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
109
- 0.8.7.6 (ruby-2.1.1).
109
+ 0.8.7.6 (ruby-2.1.6).
110
110
  </div>
111
111
 
112
112
  </body>
data/doc/file.README.html CHANGED
@@ -61,33 +61,59 @@
61
61
 
62
62
  <iframe id="search_frame"></iframe>
63
63
 
64
- <div id="content"><div id='filecontents'><h1>machinegun</h1>
65
-
66
- <p><a href="https://badge.fury.io/rb/machinegun"><img src="https://badge.fury.io/rb/machinegun.svg" alt="Gem Version"></a></p>
64
+ <div id="content"><div id='filecontents'>
65
+ <h1 id="label-machinegun">machinegun</h1>
66
+
67
+ <p><a href="https://badge.fury.io/rb/machinegun"><img
68
+ src="https://badge.fury.io/rb/machinegun.svg"></a> <a
69
+ href="https://coveralls.io/github/amclain/machinegun?branch=master"><img
70
+ src="https://coveralls.io/repos/amclain/machinegun/badge.svg?branch=master&service=github"></a>
71
+ <a href="http://www.rubydoc.info/gems/machinegun"><img
72
+ src="https://img.shields.io/badge/docs-api-blue.svg"></a> <a
73
+ href="https://github.com/amclain/machinegun/blob/master/license.txt"><img
74
+ src="https://img.shields.io/badge/license-MIT-yellowgreen.svg"></a></p>
67
75
 
68
76
  <p>An automatic reloading Rack development web server for Ruby.</p>
69
77
 
70
- <p>This gem was inspired by <a href="https://github.com/rtomayko/shotgun">shotgun</a>, which reloads the application on every request to ensure that the latest code is running. However, reloading on request can cause performance problems for applications that consume a lot of memory and/or generate a lot of requests. machinegun solves this problem by reloading the application when there are changes to the filesystem, instead of reloading on each request. This allows for the best of both worlds: A web server that reloads when changes to the code are made, and also performs quickly when serving requests.</p>
78
+ <p>This gem was inspired by <a
79
+ href="https://github.com/rtomayko/shotgun">shotgun</a>, which reloads the
80
+ application on every request to ensure that the latest code is running.
81
+ However, reloading on request can cause performance problems for
82
+ applications that consume a lot of memory and/or generate a lot of
83
+ requests. machinegun solves this problem by reloading the application when
84
+ there are changes to the filesystem, instead of reloading on each request.
85
+ This allows for the best of both worlds: A web server that reloads when
86
+ changes to the code are made, and also performs quickly when serving
87
+ requests.</p>
88
+
89
+ <h2 id="label-Installation">Installation</h2>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ gem install machinegun</code></pre>
71
92
 
72
- <h2>Installation</h2>
93
+ <h2 id="label-Use">Use</h2>
73
94
 
74
- <pre class="code text"><code class="text">$ gem install machinegun
75
- </code></pre>
95
+ <p>The <code>machinegun</code> command replaces <code>rackup</code>.
96
+ rackup&#39;s command line options should be compatible with the machinegun
97
+ executable. Since machinegun is a wrapper around Rack, your project also
98
+ needs a <a
99
+ href="https://github.com/rack/rack/wiki/(tutorial)-rackup-howto#config-file-syntax">Rack
100
+ configuration file</a>, typically <code>config.ru</code>.</p>
76
101
 
77
- <h2>Use</h2>
102
+ <p>For example, the following command will launch the web server on port 9393
103
+ and bind it to all network adapters:</p>
78
104
 
79
- <p>The <code>machinegun</code> command replaces <code>rackup</code>. rackup&#39;s command line options should be compatible with the machinegun executable. Since machinegun is a wrapper around Rack, your project also needs a <a href="https://github.com/rack/rack/wiki/(tutorial)-rackup-howto#config-file-syntax">Rack configuration file</a>, typically <code>config.ru</code>.</p>
105
+ <pre class="code ruby"><code class="ruby">$ machinegun -p 9393 -o 0.0.0.0</code></pre>
80
106
 
81
- <p>For example, the following command will launch the web server on port 9393 and bind it to all network adapters:</p>
107
+ <h2 id="label-Development">Development</h2>
82
108
 
83
- <pre class="code text"><code class="text">$ machinegun -p 9393 -o 0.0.0.0
84
- </code></pre>
109
+ <p>To skip the integration tests during development, run the test suite with:
110
+ <code>text $ SKIP_INTEGRATION_TESTS=true bundle exec rake </code></p>
85
111
  </div></div>
86
112
 
87
113
  <div id="footer">
88
- Generated on Fri Oct 23 11:08:57 2015 by
114
+ Generated on Sat Oct 24 18:31:28 2015 by
89
115
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
90
- 0.8.7.6 (ruby-2.1.1).
116
+ 0.8.7.6 (ruby-2.1.6).
91
117
  </div>
92
118
 
93
119
  </body>
@@ -64,9 +64,9 @@
64
64
  <div id="content"><div id='filecontents'>The MIT License (MIT)<br/><br/>Copyright (c) 2015 Alex McLain<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in<br/>all copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br/>THE SOFTWARE.</div></div>
65
65
 
66
66
  <div id="footer">
67
- Generated on Fri Oct 23 11:08:57 2015 by
67
+ Generated on Sat Oct 24 18:31:28 2015 by
68
68
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
69
- 0.8.7.6 (ruby-2.1.1).
69
+ 0.8.7.6 (ruby-2.1.6).
70
70
  </div>
71
71
 
72
72
  </body>
data/doc/index.html CHANGED
@@ -61,33 +61,59 @@
61
61
 
62
62
  <iframe id="search_frame"></iframe>
63
63
 
64
- <div id="content"><div id='filecontents'><h1>machinegun</h1>
65
-
66
- <p><a href="https://badge.fury.io/rb/machinegun"><img src="https://badge.fury.io/rb/machinegun.svg" alt="Gem Version"></a></p>
64
+ <div id="content"><div id='filecontents'>
65
+ <h1 id="label-machinegun">machinegun</h1>
66
+
67
+ <p><a href="https://badge.fury.io/rb/machinegun"><img
68
+ src="https://badge.fury.io/rb/machinegun.svg"></a> <a
69
+ href="https://coveralls.io/github/amclain/machinegun?branch=master"><img
70
+ src="https://coveralls.io/repos/amclain/machinegun/badge.svg?branch=master&service=github"></a>
71
+ <a href="http://www.rubydoc.info/gems/machinegun"><img
72
+ src="https://img.shields.io/badge/docs-api-blue.svg"></a> <a
73
+ href="https://github.com/amclain/machinegun/blob/master/license.txt"><img
74
+ src="https://img.shields.io/badge/license-MIT-yellowgreen.svg"></a></p>
67
75
 
68
76
  <p>An automatic reloading Rack development web server for Ruby.</p>
69
77
 
70
- <p>This gem was inspired by <a href="https://github.com/rtomayko/shotgun">shotgun</a>, which reloads the application on every request to ensure that the latest code is running. However, reloading on request can cause performance problems for applications that consume a lot of memory and/or generate a lot of requests. machinegun solves this problem by reloading the application when there are changes to the filesystem, instead of reloading on each request. This allows for the best of both worlds: A web server that reloads when changes to the code are made, and also performs quickly when serving requests.</p>
78
+ <p>This gem was inspired by <a
79
+ href="https://github.com/rtomayko/shotgun">shotgun</a>, which reloads the
80
+ application on every request to ensure that the latest code is running.
81
+ However, reloading on request can cause performance problems for
82
+ applications that consume a lot of memory and/or generate a lot of
83
+ requests. machinegun solves this problem by reloading the application when
84
+ there are changes to the filesystem, instead of reloading on each request.
85
+ This allows for the best of both worlds: A web server that reloads when
86
+ changes to the code are made, and also performs quickly when serving
87
+ requests.</p>
88
+
89
+ <h2 id="label-Installation">Installation</h2>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ gem install machinegun</code></pre>
71
92
 
72
- <h2>Installation</h2>
93
+ <h2 id="label-Use">Use</h2>
73
94
 
74
- <pre class="code text"><code class="text">$ gem install machinegun
75
- </code></pre>
95
+ <p>The <code>machinegun</code> command replaces <code>rackup</code>.
96
+ rackup&#39;s command line options should be compatible with the machinegun
97
+ executable. Since machinegun is a wrapper around Rack, your project also
98
+ needs a <a
99
+ href="https://github.com/rack/rack/wiki/(tutorial)-rackup-howto#config-file-syntax">Rack
100
+ configuration file</a>, typically <code>config.ru</code>.</p>
76
101
 
77
- <h2>Use</h2>
102
+ <p>For example, the following command will launch the web server on port 9393
103
+ and bind it to all network adapters:</p>
78
104
 
79
- <p>The <code>machinegun</code> command replaces <code>rackup</code>. rackup&#39;s command line options should be compatible with the machinegun executable. Since machinegun is a wrapper around Rack, your project also needs a <a href="https://github.com/rack/rack/wiki/(tutorial)-rackup-howto#config-file-syntax">Rack configuration file</a>, typically <code>config.ru</code>.</p>
105
+ <pre class="code ruby"><code class="ruby">$ machinegun -p 9393 -o 0.0.0.0</code></pre>
80
106
 
81
- <p>For example, the following command will launch the web server on port 9393 and bind it to all network adapters:</p>
107
+ <h2 id="label-Development">Development</h2>
82
108
 
83
- <pre class="code text"><code class="text">$ machinegun -p 9393 -o 0.0.0.0
84
- </code></pre>
109
+ <p>To skip the integration tests during development, run the test suite with:
110
+ <code>text $ SKIP_INTEGRATION_TESTS=true bundle exec rake </code></p>
85
111
  </div></div>
86
112
 
87
113
  <div id="footer">
88
- Generated on Fri Oct 23 11:08:57 2015 by
114
+ Generated on Sat Oct 24 18:31:28 2015 by
89
115
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
90
- 0.8.7.6 (ruby-2.1.1).
116
+ 0.8.7.6 (ruby-2.1.6).
91
117
  </div>
92
118
 
93
119
  </body>
data/doc/method_list.html CHANGED
@@ -52,11 +52,35 @@
52
52
 
53
53
 
54
54
  <li class="r1 ">
55
+ <span class='object_link'><a href="MachineGun.html#initialize-instance_method" title="MachineGun#initialize (method)">#initialize</a></span>
56
+ <small>MachineGun</small>
57
+ </li>
58
+
59
+
60
+ <li class="r2 ">
55
61
  <span class='object_link'><a href="MachineGun.html#run-class_method" title="MachineGun.run (method)">run</a></span>
56
62
  <small>MachineGun</small>
57
63
  </li>
58
64
 
59
65
 
66
+ <li class="r1 ">
67
+ <span class='object_link'><a href="MachineGun.html#run-instance_method" title="MachineGun#run (method)">#run</a></span>
68
+ <small>MachineGun</small>
69
+ </li>
70
+
71
+
72
+ <li class="r2 ">
73
+ <span class='object_link'><a href="MachineGun.html#running%3F-instance_method" title="MachineGun#running? (method)">#running?</a></span>
74
+ <small>MachineGun</small>
75
+ </li>
76
+
77
+
78
+ <li class="r1 ">
79
+ <span class='object_link'><a href="MachineGun.html#stop-instance_method" title="MachineGun#stop (method)">#stop</a></span>
80
+ <small>MachineGun</small>
81
+ </li>
82
+
83
+
60
84
  </ul>
61
85
  </div>
62
86
  </body>
@@ -103,9 +103,9 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Fri Oct 23 11:08:57 2015 by
106
+ Generated on Sat Oct 24 18:31:28 2015 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.7.6 (ruby-2.1.1).
108
+ 0.8.7.6 (ruby-2.1.6).
109
109
  </div>
110
110
 
111
111
  </body>
data/lib/machinegun.rb CHANGED
@@ -1,28 +1,66 @@
1
1
  require 'rack'
2
2
  require 'filewatcher'
3
3
 
4
+ # An automatic reloading Rack development web server for Ruby.
4
5
  class MachineGun
5
6
 
6
- def self.run
7
- pid = start_server
7
+ # Helper method to instantiate a new object and run the server.
8
+ # @see #run
9
+ def self.run *args
10
+ new.run *args
11
+ end
12
+
13
+ def initialize
14
+ @running = false
15
+ end
16
+
17
+ # Run the automatically-reloading web server.
18
+ # This method blocks.
19
+ # @option opts [Numeric] :interval (0.5) Interval in seconds to scan the
20
+ # filesystem for changes.
21
+ def run opts = {}
22
+ @running = true
23
+ interval = opts[:interval] || 0.5
24
+
25
+ @pid = start_server
26
+
27
+ @watcher = FileWatcher.new("./**/*.rb")
8
28
 
9
- FileWatcher.new("./**/*.rb").watch do
10
- Process.kill "INT", pid
11
- Process.wait pid
12
-
13
- pid = start_server
29
+ @watcher.watch interval do
30
+ stop_server
31
+ @pid = start_server
14
32
  end
15
33
  end
16
34
 
35
+ # Stop watching for file changes and shutdown the web server.
36
+ def stop
37
+ return unless @running
38
+
39
+ @watcher.stop
40
+ stop_server
41
+ @running = false
42
+ end
43
+
44
+ # @return true if the server is running.
45
+ def running?
46
+ @running
47
+ end
48
+
17
49
  private
18
50
 
19
- def self.start_server
20
- pid = fork do
51
+ # Start the web server in a forked process.
52
+ # @return process id
53
+ def start_server
54
+ fork do
21
55
  $0 = "rack"
22
56
  Rack::Server.start
23
57
  end
24
-
25
- pid
58
+ end
59
+
60
+ # Gracefully stop the web server's forked process.
61
+ def stop_server
62
+ Process.kill "INT", @pid
63
+ Process.wait @pid
26
64
  end
27
65
 
28
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: machinegun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex McLain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-23 00:00:00.000000000 Z
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -106,28 +106,28 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 3.1.0
109
+ version: 3.3.0
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 3.1.0
116
+ version: 3.3.0
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: rspec-its
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 1.0.1
123
+ version: 1.2.0
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 1.0.1
130
+ version: 1.2.0
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: fivemat
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +142,20 @@ dependencies:
142
142
  - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: cuba
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '3.4'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: '3.4'
145
159
  description: An automatic reloading Rack development web server for Ruby.
146
160
  email:
147
161
  - alex@alexmclain.com
@@ -190,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
204
  version: '0'
191
205
  requirements: []
192
206
  rubyforge_project:
193
- rubygems_version: 2.4.1
207
+ rubygems_version: 2.2.3
194
208
  signing_key:
195
209
  specification_version: 4
196
210
  summary: An automatic reloading Rack development web server for Ruby.