shotgun 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +2 -2
  2. data/bin/shotgun +28 -8
  3. data/lib/shotgun.rb +2 -0
  4. data/shotgun.gemspec +4 -3
  5. metadata +15 -2
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ task :default => [:test]
5
5
  task :spec => :test
6
6
 
7
7
  Rake::TestTask.new(:test) do |t|
8
- t.test_files = FileList['test/*_test.rb']
8
+ t.test_files = FileList['test/spec_*.rb']
9
9
  t.ruby_opts = ['-rubygems'] if defined? Gem
10
10
  end
11
11
 
@@ -48,7 +48,7 @@ file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
48
48
  end
49
49
 
50
50
  desc 'Publish gem and tarball to rubyforge'
51
- task 'publish:gem' => [package('.gem'), package('.tar.gz')] do |t|
51
+ task 'release' => [package('.gem'), package('.tar.gz')] do |t|
52
52
  sh <<-end
53
53
  rubyforge add_release wink #{$spec.name} #{$spec.version} #{package('.gem')} &&
54
54
  rubyforge add_file wink #{$spec.name} #{$spec.version} #{package('.tar.gz')}
@@ -5,12 +5,10 @@ $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
5
5
 
6
6
  require 'optparse'
7
7
 
8
- automatic = false
9
8
  server = nil
10
9
  env = ENV['RACK_ENV'] || 'development'
11
- daemonize = false
12
- pid = nil
13
- options = {:Port => 9393, :Host => "0.0.0.0", :AccessLog => []}
10
+ browse = false
11
+ options = {:Port => 9393, :Host => 'localhost', :AccessLog => []}
14
12
 
15
13
  opts = OptionParser.new("", 24, ' ') { |opts|
16
14
  opts.banner = "Usage: shotgun [ruby options] [rack options] [rackup config]"
@@ -60,14 +58,18 @@ opts = OptionParser.new("", 24, ' ') { |opts|
60
58
  }
61
59
 
62
60
  opts.separator ""
63
- opts.separator "Common options:"
61
+ opts.separator "Shotgun options:"
64
62
 
65
- opts.on_tail("-h", "--help", "Show this message") do
63
+ opts.on("-O", "--browse", "open browser immediately after starting") { |browse|
64
+ browse = true
65
+ }
66
+
67
+ opts.on_tail("-h", "--help", "show this message") do
66
68
  puts opts
67
69
  exit
68
70
  end
69
71
 
70
- opts.on_tail("--version", "Show version") do
72
+ opts.on_tail("--version", "show version") do
71
73
  require 'rack'
72
74
  puts "Rack #{Rack.version}"
73
75
  exit
@@ -84,6 +86,12 @@ if config =~ /\.ru$/ && File.read(config)[/^#\\(.*)/]
84
86
  end
85
87
 
86
88
  require 'rack'
89
+ require 'rack/utils'
90
+ require 'rack/request'
91
+ require 'rack/response'
92
+ require 'rack/lint'
93
+ require 'rack/commonlogger'
94
+ require 'rack/showexceptions'
87
95
 
88
96
  unless server = Rack::Handler.get(server)
89
97
  begin
@@ -95,12 +103,19 @@ end
95
103
 
96
104
  app_wrapper =
97
105
  lambda do |inner_app|
98
- if env == 'development'
106
+ case env
107
+ when 'development'
99
108
  Rack::Builder.new {
109
+ use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
100
110
  use Rack::ShowExceptions
101
111
  use Rack::Lint
102
112
  run inner_app
103
113
  }.to_app
114
+ when 'deployment', 'production'
115
+ Rack::Builder.new {
116
+ use Rack::CommonLogger, STDERR unless server.name =~ /CGI/
117
+ run inner_app
118
+ }.to_app
104
119
  else
105
120
  inner_app
106
121
  end
@@ -113,4 +128,9 @@ app = Shotgun.new(config, app_wrapper)
113
128
 
114
129
  server.run app, options do |inst|
115
130
  puts "== Shotgun starting #{server.to_s} on #{options[:Host]}:#{options[:Port]}"
131
+
132
+ if browse
133
+ require 'launchy'
134
+ Launchy.open("http://#{options[:Host]}:#{options[:Port]}/")
135
+ end
116
136
  end
@@ -64,6 +64,8 @@ class Shotgun
64
64
  require rackup_file
65
65
  if defined? Sinatra::Application
66
66
  Sinatra::Application.set :reload, false
67
+ Sinatra::Application.set :logging, false
68
+ Sinatra::Application.set :raise_errors, true
67
69
  Sinatra::Application
68
70
  else
69
71
  Object.const_get(File.basename(rackup_file, '.rb').capitalize)
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
4
 
5
5
  s.name = 'shotgun'
6
- s.version = '0.1'
7
- s.date = '2009-02-20'
6
+ s.version = '0.2'
7
+ s.date = '2009-03-22'
8
8
 
9
9
  s.description = "Because reloading sucks."
10
10
  s.summary = s.description
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/}
25
25
 
26
26
  s.extra_rdoc_files = %w[README]
27
- s.add_dependency 'rack', '>= 0.9.1', '< 1.0'
27
+ s.add_dependency 'rack', '>= 0.9.1', '< 1.0'
28
+ s.add_dependency 'launchy', '>= 0.3.3', '< 1.0'
28
29
 
29
30
  s.homepage = "http://github.com/rtomayko/shotgun/"
30
31
  s.require_paths = %w[lib]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shotgun
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: "0.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-20 00:00:00 -08:00
12
+ date: 2009-03-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -25,6 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: "1.0"
27
27
  version:
28
+ - !ruby/object:Gem::Dependency
29
+ name: launchy
30
+ type: :runtime
31
+ version_requirement:
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.3.3
37
+ - - <
38
+ - !ruby/object:Gem::Version
39
+ version: "1.0"
40
+ version:
28
41
  description: Because reloading sucks.
29
42
  email: r@tomayko.com
30
43
  executables: