shotgun 0.9 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bfb95c3ce272fda90c987c9761c981ba16ab692d
4
+ data.tar.gz: 47182b008d5fcaf9779411bbab72f35053f1a873
5
+ SHA512:
6
+ metadata.gz: b509cc0e7c7c956c7da7de176ba589d5937e86d195711cc11516a68351742454b8f1adcfb9c37f4be540462725fd81d45c94fe988d976d93dc13f184fdd00827
7
+ data.tar.gz: 0fa3d9eb2148671e290272f73b51716ec50e7de56c7648a0676bea2f6e44b279557f048971f185e07aac0cf15a1b6031b406ec6133ad18997a065e48e990996e
@@ -0,0 +1,3 @@
1
+ /pkg
2
+ /test/verbose.log
3
+ shotgun.1.html
@@ -0,0 +1,12 @@
1
+ 0.9.1 - 2015-03-01
2
+ ==================
3
+
4
+ * Fixed a long-standing issue that caused Shotgun not to show any access logs
5
+ in the terminal (#57).
6
+
7
+ * Made `--url` option actually work (Adam Mckaig, #49).
8
+
9
+ Previous versions
10
+ =================
11
+
12
+ (See commit list.)
File without changes
@@ -1,4 +1,4 @@
1
- Shotgun
1
+ # Shotgun
2
2
 
3
3
  This is an automatic reloading version of the rackup command that's shipped with
4
4
  Rack. It can be used as an alternative to the complex reloading logic provided
@@ -16,31 +16,60 @@ Usage
16
16
 
17
17
  Installation:
18
18
 
19
- gem install shotgun
19
+ ```shell
20
+ gem install shotgun
21
+ ```
20
22
 
21
23
  Starting a server with a rackup file:
22
24
 
23
- shotgun config.ru
24
-
25
+ ```shell
26
+ shotgun config.ru
27
+ ```
25
28
  Using Thin and starting on port 6000 instead of 9393 (default):
26
29
 
27
- shotgun --server=thin --port=6000 config.ru
28
-
30
+ ```shell
31
+ shotgun --server=thin --port=6000 config.ru
32
+ ```
29
33
  Running Sinatra apps:
30
34
 
31
- shotgun hello.rb
35
+
36
+ ```shell
37
+ shotgun hello.rb
38
+ ```
32
39
 
33
40
  See 'shotgun --help' for more advanced usage.
34
41
 
42
+ Compatibility
43
+ ---
44
+
45
+ Because of the underlying technique used, Shotgun is only compatible with
46
+ systems that support `fork(2)` (probably just MRI on POSIX systems).
47
+
48
+ Caveats
49
+ ---
50
+
51
+ * For performance reasons, Shotgun automatically includes middleware to serve
52
+ static files (similar to `Rack::Static`). If you rely on Rack serving static
53
+ assets, then do include `Rack::Static` yourself.
54
+
55
+ * If you use Sinatra, you may need to [set the session secret manually][sinatra-caveat].
56
+
57
+ * Similar to a Rackup file (`config.ru`), you can't use `require_relative` in
58
+ your preload files (`shotgun.rb`).
59
+
35
60
  Links
36
61
  -----
37
62
 
38
- Shotgun: http://github.com/rtomayko/shotgun
39
- Rack: http://rack.rubyforge.org/
40
- Sinatra: http://www.sinatrarb.com/
63
+ [Shotgun](http://github.com/rtomayko/shotgun)
64
+
65
+ [Rack](http://rack.rubyforge.org/)
66
+
67
+ [Sinatra](http://www.sinatrarb.com/)
41
68
 
42
69
  The reloading system in Ian Bicking's webware framework served as inspiration
43
70
  for the approach taken in Shotgun. Ian lays down the pros and cons of this
44
71
  approach in the following article:
45
72
 
46
73
  http://ianbicking.org/docs/Webware_reload.html
74
+
75
+ [sinatra-caveat]: https://groups.google.com/forum/#!topic/sinatrarb/pUFSoyQXyQs
@@ -0,0 +1,8 @@
1
+ 1. update shotgun.gemspec version and date
2
+ 2. update revision history in shotgun.1
3
+ 3. rake man
4
+ 4. git add -u
5
+ 4. tag <version>
6
+ 5. rake package
7
+ 6. git push origin master <version>
8
+ 7. gem push pkg/shotgun-<version>.gem
@@ -3,10 +3,13 @@
3
3
  require 'optparse'
4
4
 
5
5
  env = ENV['RACK_ENV'] || 'development'
6
+ host = ENV['HOST'] || '127.0.0.1'
7
+ port = ENV['PORT'] || 9393
8
+ mount_path = "/"
6
9
  browse = false
7
10
  server = nil
8
11
  public_dir = 'public' if File.directory?('public')
9
- options = {:Port => 9393, :Host => '127.0.0.1', :AccessLog => [], :Path => '/'}
12
+ options = {:Port => port, :Host => host, :AccessLog => []}
10
13
 
11
14
  opts = OptionParser.new("", 24, ' ') { |opts|
12
15
  opts.banner = "Usage: shotgun [ruby options] [rack options] [rackup config]"
@@ -58,12 +61,12 @@ opts = OptionParser.new("", 24, ' ') { |opts|
58
61
  opts.separator ""
59
62
  opts.separator "Shotgun options:"
60
63
 
61
- opts.on("-O", "--browse", "open browser immediately after starting") { |browse|
64
+ opts.on("-O", "--browse", "open browser immediately after starting") {
62
65
  browse = true
63
66
  }
64
67
 
65
- opts.on("-u", "--url URL", "specify url path (default: /)") { |url|
66
- options[:Path] = url
68
+ opts.on("-u", "--url URL", "specify url path (default: #{mount_path})") { |url|
69
+ mount_path = url
67
70
  }
68
71
 
69
72
  opts.on("-P", "--public PATH", "serve static files under PATH") { |path|
@@ -116,22 +119,25 @@ server = Rack::Handler.get(server) || Rack::Handler.default
116
119
 
117
120
  app =
118
121
  Rack::Builder.new do
119
- # these middleware run in the master process.
120
- use Shotgun::Static, public_dir if public_dir
121
- use Shotgun::SkipFavicon
122
-
123
- # loader forks the child and runs the embedded config followed by the
124
- # application config.
125
- run Shotgun::Loader.new(config) {
126
- case env
127
- when 'development'
128
- use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
129
- use Rack::ShowExceptions
130
- use Rack::Lint
131
- when 'deployment', 'production'
132
- use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
133
- end
134
- }
122
+ map(mount_path) do
123
+
124
+ # these middleware run in the master process.
125
+ use Shotgun::Static, public_dir if public_dir
126
+ use Shotgun::SkipFavicon
127
+
128
+ # loader forks the child and runs the embedded config followed by the
129
+ # application config.
130
+ run Shotgun::Loader.new(config) {
131
+ case env
132
+ when 'development'
133
+ use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
134
+ use Rack::ShowExceptions
135
+ use Rack::Lint
136
+ when 'deployment', 'production'
137
+ use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
138
+ end
139
+ }
140
+ end
135
141
  end
136
142
 
137
143
  Shotgun.enable_copy_on_write
@@ -151,7 +157,7 @@ end
151
157
  # load shotgun.rb in current working directory if it exists
152
158
  Shotgun.preload
153
159
 
154
- base_url = "http://#{options[:Host]}:#{options[:Port]}#{options[:Path]}"
160
+ base_url = "http://#{options[:Host]}:#{options[:Port]}#{mount_path}"
155
161
  puts "== Shotgun/#{server.to_s.sub(/Rack::Handler::/, '')} on #{base_url}"
156
162
  server.run app, options do |inst|
157
163
  if browse
@@ -86,6 +86,7 @@ module Shotgun
86
86
  status, headers, body = assemble_app.call(@env)
87
87
  Marshal.dump([:ok, status, headers.to_hash], @writer)
88
88
  spec_body(body).each { |chunk| @writer.write(chunk) }
89
+ body.close if body.respond_to?(:close)
89
90
  rescue Object => boom
90
91
  Marshal.dump([
91
92
  :error,
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "SHOTGUN" "1" "February 2011" "Shotgun 0.9" ""
4
+ .TH "SHOTGUN" "1" "March 2015" "Shotgun 0.9.1" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBshotgun\fR \- reloading rack development server
@@ -35,11 +35,11 @@ The Rack server handler implementation used to serve requests\. Supported values
35
35
  .
36
36
  .TP
37
37
  \fB\-o\fR, \fB\-\-host\fR=\fIaddr\fR
38
- The hostname or address of the interface the HTTP server should bind to\. Default: \fB127\.0\.0\.1\fR\.
38
+ The hostname or address of the interface the HTTP server should bind to\. Overrides the \fBHOST\fR environment variable\. Default: \fB127\.0\.0\.1\fR\.
39
39
  .
40
40
  .TP
41
41
  \fB\-p\fR, \fB\-\-port\fR=\fIport\fR
42
- The port the HTTP server should bind to\. Default: \fB9393\fR\.
42
+ The port the HTTP server should bind to\. Overrides the \fBPORT\fR environment variable\. Default: \fB9393\fR\.
43
43
  .
44
44
  .TP
45
45
  \fB\-O\fR, \fB\-\-browse\fR
@@ -79,6 +79,17 @@ Show usage message and exit\.
79
79
  \fB\-\-version\fR
80
80
  Show the Rack version and exit\.
81
81
  .
82
+ .SH "ENVIRONMENT"
83
+ The following environment variables affect the configuration of \fBshotgun\fR:
84
+ .
85
+ .TP
86
+ \fBHOST\fR
87
+ The hostname or address of the interface the HTTP server should bind to\. See the \fB\-h\fR option\.
88
+ .
89
+ .TP
90
+ \fBPORT\fR
91
+ The port the HTTP server should bind to\. See the \fB\-p\fR option\.
92
+ .
82
93
  .SH "PRELOADING"
83
94
  It\'s possible to load support libraries and portions of the application in the shotgun master process to reduce the amount of work that needs to be done for each request in worker processes\. There\'s two ways of accomplishing this: either by specifying one or more \fB\-\-require\fR (\fB\-r\fR) arguments or through the use of a \fBshotgun\.rb\fR file\.
84
95
  .
@@ -145,6 +156,16 @@ Fork and report issues at github\.com:
145
156
  .
146
157
  .SH "VERSION HISTORY"
147
158
  .
159
+ .SS "Version 0\.9\.1 (2015 March 1)"
160
+ .
161
+ .IP "\(bu" 4
162
+ Fix a long\-standing issue that caused Shotgun not to show any access logs in the terminal (#57)\.
163
+ .
164
+ .IP "\(bu" 4
165
+ Make \fB\-\-url\fR option actually work\.
166
+ .
167
+ .IP "" 0
168
+ .
148
169
  .SS "Version 0\.9 (2011 February 24)"
149
170
  .
150
171
  .IP "\(bu" 4
@@ -46,10 +46,11 @@ control server behavior:
46
46
 
47
47
  * `-o`, `--host`=<addr>:
48
48
  The hostname or address of the interface the HTTP server should bind to.
49
- Default: `127.0.0.1`.
49
+ Overrides the `HOST` environment variable. Default: `127.0.0.1`.
50
50
 
51
51
  * `-p`, `--port`=<port>:
52
- The port the HTTP server should bind to. Default: `9393`.
52
+ The port the HTTP server should bind to. Overrides the `PORT` environment
53
+ variable. Default: `9393`.
53
54
 
54
55
  * `-O`, `--browse`:
55
56
  Open browser at http://<host>:<port>/ immediately after the server
@@ -86,6 +87,17 @@ Miscellaneous:
86
87
  * `--version`:
87
88
  Show the Rack version and exit.
88
89
 
90
+ ## ENVIRONMENT
91
+
92
+ The following environment variables affect the configuration of `shotgun`:
93
+
94
+ * `HOST`:
95
+ The hostname or address of the interface the HTTP server should bind to. See
96
+ the `-h` option.
97
+
98
+ * `PORT`:
99
+ The port the HTTP server should bind to. See the `-p` option.
100
+
89
101
  ## PRELOADING
90
102
 
91
103
  It's possible to load support libraries and portions of the application in the
@@ -148,6 +160,13 @@ Fork and report issues at github.com:
148
160
 
149
161
  ## VERSION HISTORY
150
162
 
163
+ ### Version 0.9.1 (2015 March 1)
164
+
165
+ * Fix a long-standing issue that caused Shotgun not to show any access logs
166
+ in the terminal (#57).
167
+
168
+ * Make `--url` option actually work.
169
+
151
170
  ### Version 0.9 (2011 February 24)
152
171
 
153
172
  * <http://github.com/rtomayko/shotgun/compare/0.8...0.9>
@@ -1,41 +1,20 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'shotgun'
3
- s.version = '0.9'
4
- s.date = '2011-02-24'
3
+ s.version = '0.9.1'
5
4
 
6
- s.description = "reloading rack development server"
5
+ s.description = "Reloading Rack development server"
7
6
  s.summary = s.description
8
7
 
8
+ s.license = "MIT"
9
+
9
10
  s.authors = ["Ryan Tomayko"]
10
11
  s.email = "rtomayko@gmail.com"
11
12
 
12
- s.files = %w[
13
- COPYING
14
- README
15
- Rakefile
16
- bin/shotgun
17
- lib/shotgun.rb
18
- lib/shotgun/favicon.rb
19
- lib/shotgun/loader.rb
20
- lib/shotgun/static.rb
21
- man/index.txt
22
- man/shotgun.1
23
- man/shotgun.1.ronn
24
- shotgun.gemspec
25
- test/big.ru
26
- test/boom.ru
27
- test/slow.ru
28
- test/test-sinatra.ru
29
- test/test.ru
30
- test/test_shotgun_loader.rb
31
- test/test_shotgun_static.rb
32
- ]
33
- s.executables = ['shotgun']
34
- s.test_files = s.files.select { |f| f =~ /test_shotgun.*rb/ }
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
35
16
 
36
- s.extra_rdoc_files = %w[README]
37
17
  s.add_dependency 'rack', '>= 1.0'
38
18
 
39
- s.homepage = "http://github.com/rtomayko/shotgun"
40
- s.require_paths = %w[lib]
19
+ s.homepage = "https://github.com/rtomayko/shotgun"
41
20
  end
@@ -32,4 +32,19 @@ class ShotgunLoaderTest < Test::Unit::TestCase
32
32
  assert res.body =~ %r|<pre>(?:.{1023}\n){1024}</pre>|,
33
33
  "body of size #{res.body.size} does not match expected output"
34
34
  end
35
+
36
+ def test_logging
37
+ file = rackup_file('verbose.ru')
38
+
39
+ $logger = File.open('test/verbose.log', 'w')
40
+ $logger.sync = true
41
+
42
+ shotgun = Shotgun::Loader.new(file)
43
+ request = Rack::MockRequest.new(shotgun)
44
+ request.get('/', 'REMOTE_ADDR' => 'foo.local')
45
+
46
+ $logger.close
47
+
48
+ assert_match /^foo.local/, File.read('test/verbose.log')
49
+ end
35
50
  end
@@ -0,0 +1,7 @@
1
+ require 'rack'
2
+
3
+ app = lambda { |env|
4
+ [200, {'Content-Type'=>'text/plain'}, ['BANG!']] }
5
+
6
+ use Rack::CommonLogger, $logger
7
+ run app
metadata CHANGED
@@ -1,48 +1,41 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: shotgun
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 9
9
- version: "0.9"
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Ryan Tomayko
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2011-02-24 00:00:00 -08:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2015-03-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: rack
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 15
29
- segments:
30
- - 1
31
- - 0
32
- version: "1.0"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
33
20
  type: :runtime
34
- version_requirements: *id001
35
- description: reloading rack development server
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: Reloading Rack development server
36
28
  email: rtomayko@gmail.com
37
- executables:
29
+ executables:
38
30
  - shotgun
39
31
  extensions: []
40
-
41
- extra_rdoc_files:
42
- - README
43
- files:
44
- - COPYING
45
- - README
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - CHANGELOG.md
36
+ - LICENSE
37
+ - README.md
38
+ - RELEASING
46
39
  - Rakefile
47
40
  - bin/shotgun
48
41
  - lib/shotgun.rb
@@ -60,40 +53,37 @@ files:
60
53
  - test/test.ru
61
54
  - test/test_shotgun_loader.rb
62
55
  - test/test_shotgun_static.rb
63
- has_rdoc: true
64
- homepage: http://github.com/rtomayko/shotgun
65
- licenses: []
66
-
56
+ - test/verbose.ru
57
+ homepage: https://github.com/rtomayko/shotgun
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
67
61
  post_install_message:
68
62
  rdoc_options: []
69
-
70
- require_paths:
63
+ require_paths:
71
64
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
75
67
  - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
84
72
  - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
90
75
  requirements: []
91
-
92
76
  rubyforge_project:
93
- rubygems_version: 1.3.7
77
+ rubygems_version: 2.4.5
94
78
  signing_key:
95
- specification_version: 3
96
- summary: reloading rack development server
97
- test_files:
79
+ specification_version: 4
80
+ summary: Reloading Rack development server
81
+ test_files:
82
+ - test/big.ru
83
+ - test/boom.ru
84
+ - test/slow.ru
85
+ - test/test-sinatra.ru
86
+ - test/test.ru
98
87
  - test/test_shotgun_loader.rb
99
88
  - test/test_shotgun_static.rb
89
+ - test/verbose.ru