startbrick 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Startbrick
2
+
3
+ How much of your Rails dev time is utterly wasted waiting for this:
4
+
5
+ $ rails s
6
+ => Booting WEBrick
7
+ => Rails 3.1.1 application starting in development on http://0.0.0.0:3000
8
+ => Call with -d to detach
9
+ => Ctrl-C to shutdown server
10
+
11
+ to turn into this:
12
+
13
+ $ rails s
14
+ => Booting WEBrick
15
+ => Rails 3.1.1 application starting in development on http://0.0.0.0:3000
16
+ => Call with -d to detach
17
+ => Ctrl-C to shutdown server
18
+ [2011-11-01 13:22:01] INFO WEBrick 1.3.1
19
+ [2011-11-01 13:22:01] INFO ruby 1.9.2 (2011-07-09) [i686-linux]
20
+ [2011-11-01 13:22:01] INFO WEBrick::HTTPServer#start: pid=4012 port=3000
21
+
22
+ **Startbrick** is a thin wrapper gem around Rack::Handler::WEBrick that
23
+ automatically opens your Rails app in your default web browser when it's ready
24
+ to accept requests.
25
+
26
+ Install the gem with
27
+
28
+ gem install startbrick
29
+
30
+ Startbrick works with Rails 3.
31
+
32
+ To use Startbrick, just start your Rails app like this:
33
+
34
+ rails s Startbrick
35
+
36
+
37
+ ## Optional .startbrick script
38
+
39
+ By default, Startbrick runs this shell command when WEBrick is ready for
40
+ requests:
41
+
42
+ open "http://#{BindAddress}:#{Port}"
43
+
44
+ You can override this by putting your own shell script in a `.startbrick` file
45
+ in your Rails root directory.
46
+
47
+
48
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # encoding: UTF-8
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+ require 'bundler'
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ begin
8
+ require 'bundler/setup'
9
+ rescue LoadError
10
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
11
+ end
12
+
13
+
@@ -0,0 +1,3 @@
1
+ module Startbrick
2
+ VERSION = '0.0.1'
3
+ end
data/lib/startbrick.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'rack'
2
+ require 'rack/handler/webrick'
3
+
4
+ module Rack
5
+ module Handler
6
+ SCRIPT_FILE = '.startbrick'
7
+
8
+ class Startbrick < Rack::Handler::WEBrick
9
+ def self.run(app, options={})
10
+
11
+ options[:BindAddress] = options.delete(:Host) if options[:Host]
12
+
13
+ options[:StartCallback] = if ::File.size?(SCRIPT_FILE)
14
+ script = ::File.read(SCRIPT_FILE)
15
+ puts "Loading #{SCRIPT_FILE} script:\n\n#{script.gsub(/^/, ' ')}"
16
+ Proc.new {
17
+ puts "Executing #{SCRIPT_FILE}"
18
+ fork { `bash #{SCRIPT_FILE}` }
19
+ }
20
+ else
21
+ Proc.new {
22
+ url = "http://#{options[:BindAddress]}:#{options[:Port]}"
23
+ cmd = "open #{url}"
24
+ puts "Running '#{cmd}'"
25
+ fork { `#{cmd}` }
26
+ }
27
+
28
+ end
29
+ @server = ::WEBrick::HTTPServer.new(options)
30
+ @server.mount "/", Rack::Handler::WEBrick, app
31
+ yield @server if block_given?
32
+ @server.start
33
+ end
34
+
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,14 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+ require 'startbrick/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "startbrick"
6
+ s.description = "WEBrick wrapper"
7
+ s.files = `git ls-files`.split("\n")
8
+ s.version = Startbrick::VERSION
9
+ s.summary = s.description
10
+ s.authors = ["Daniel Choi"]
11
+ s.email = ["dhchoi@gmail.com"]
12
+ s.homepage = "https://github.com/danchoi/startbrick"
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: startbrick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Choi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-01 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: WEBrick wrapper
15
+ email:
16
+ - dhchoi@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - Rakefile
23
+ - lib/startbrick.rb
24
+ - lib/startbrick/version.rb
25
+ - startbrick.gemspec
26
+ homepage: https://github.com/danchoi/startbrick
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 1.8.11
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: WEBrick wrapper
50
+ test_files: []