fivepointssolutions-serve 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +52 -0
- data/License.txt +20 -0
- data/Quickstart.textile +148 -0
- data/README.txt +105 -0
- data/VERSION.yml +4 -0
- data/bin/serve +12 -0
- data/lib/serve.rb +10 -0
- data/lib/serve/application.rb +150 -0
- data/lib/serve/file_resolver.rb +46 -0
- data/lib/serve/handlers/dynamic_handler.rb +210 -0
- data/lib/serve/handlers/email_handler.rb +23 -0
- data/lib/serve/handlers/file_type_handler.rb +37 -0
- data/lib/serve/handlers/markdown_handler.rb +10 -0
- data/lib/serve/handlers/redirect_handler.rb +13 -0
- data/lib/serve/handlers/sass_handler.rb +19 -0
- data/lib/serve/handlers/textile_handler.rb +10 -0
- data/lib/serve/rails.rb +3 -0
- data/lib/serve/rails/configuration.rb +69 -0
- data/lib/serve/rails/controllers/serve_controller.rb +43 -0
- data/lib/serve/rails/mount.rb +29 -0
- data/lib/serve/rails/routing.rb +25 -0
- data/lib/serve/response_cache.rb +172 -0
- data/lib/serve/version.rb +13 -0
- data/lib/serve/webrick/extensions.rb +98 -0
- data/lib/serve/webrick/server.rb +17 -0
- data/lib/serve/webrick/servlet.rb +19 -0
- data/spec/response_cache_spec.rb +248 -0
- data/spec/serve_application_spec.rb +75 -0
- data/spec/serve_spec.rb +13 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +12 -0
- metadata +89 -0
data/History.txt
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
== 0.9.11 (??)
|
2
|
+
* Made to work as a Rails GemPlugin [aiwilliams]
|
3
|
+
* Caches responses using the Radiant ResponseCache when used as a Rails plugin [aiwilliams]
|
4
|
+
* Managing gem using jeweler [aiwilliams]
|
5
|
+
|
6
|
+
== 0.9.10 (October 25, 2008)
|
7
|
+
* Updated to work with Haml 2.0.3. [jlong]
|
8
|
+
|
9
|
+
== 0.9.9 (September 19, 2008)
|
10
|
+
* Fixed ERB partial support. [jlong]
|
11
|
+
* Added support for content_for blocks in ERB. [jlong]
|
12
|
+
|
13
|
+
== 0.9.8 (July 18, 2008)
|
14
|
+
|
15
|
+
* Added experimental support for ERB layouts. [Lawjoskar]
|
16
|
+
|
17
|
+
== 0.9.7 (July 17, 2008)
|
18
|
+
|
19
|
+
* Added experimental support for view helpers. [aiwilliams]
|
20
|
+
* Added limited support for ERB. Layouts are not yet supported. [jlong]
|
21
|
+
|
22
|
+
== 0.9.6 (February 20, 2008)
|
23
|
+
|
24
|
+
* Changed default port to 4000 so that serve plays nicely with Rails apps.
|
25
|
+
* Rearranged source.
|
26
|
+
|
27
|
+
== 0.9.5 (February 19, 2008)
|
28
|
+
|
29
|
+
* Added support for rendering other files with the following syntax:
|
30
|
+
|
31
|
+
render :template => "template_name"
|
32
|
+
|
33
|
+
== 0.9.4 (January 31, 2008)
|
34
|
+
|
35
|
+
* Small fix for calculating the partial name in render_partial.
|
36
|
+
|
37
|
+
== 0.9.3 (January 23, 2008)
|
38
|
+
|
39
|
+
* Added support for layouts and partials for HAML documents.
|
40
|
+
|
41
|
+
== 0.9.2 (January 17, 2008)
|
42
|
+
|
43
|
+
* Added support for redirects.
|
44
|
+
|
45
|
+
== 0.9.1 (October 19, 2007)
|
46
|
+
|
47
|
+
* Added basic support for email mockups.
|
48
|
+
* Updated description and help text.
|
49
|
+
|
50
|
+
== 0.9.0 (September 25, 2007)
|
51
|
+
|
52
|
+
* Initial release
|
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 John W. Long
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Quickstart.textile
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
h1. Getting Started with Serve
|
2
|
+
|
3
|
+
|
4
|
+
Serve is a rapid prototyping framework for Rails applications. It is designed to compliment Rails development and enforce a strict separation of concerns between designer and developer. Using Serve with Rails allows the designer to happily work in his own space creating an HTML prototype of the application, while the developer works on the Rails application and copies over HTML from the prototype as needed. This allows the designer to focus on presentation and flow while the developer can focus on the implementation.
|
5
|
+
|
6
|
+
Let's have a look at how it all works.
|
7
|
+
|
8
|
+
|
9
|
+
h3. Installation
|
10
|
+
|
11
|
+
To get started we need to download and install the Ruby gem for Serve:
|
12
|
+
|
13
|
+
<pre>
|
14
|
+
% sudo gem install serve
|
15
|
+
</pre>
|
16
|
+
|
17
|
+
After we've done that it's probably a good idea to install a couple of additional gems so that Serve will play nicely with HAML, Markdown, and Textile:
|
18
|
+
|
19
|
+
<pre>
|
20
|
+
% sudo gem install haml Bluecloth Redcloth
|
21
|
+
</pre>
|
22
|
+
|
23
|
+
|
24
|
+
h3. Project Directory Structure
|
25
|
+
|
26
|
+
Once we have everything installed the next thing to do is setup the project directory. I like to setup my projects with the following directory structure:
|
27
|
+
|
28
|
+
<pre>
|
29
|
+
artwork # Logos and other identity design files go here
|
30
|
+
mockups # Fireworks or Photoshop web app mockups go here
|
31
|
+
prototype # The HTML prototype for the web app goes here
|
32
|
+
application # The actual Rails application is here
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
Let's go ahead and create the directory for the prototype:
|
36
|
+
|
37
|
+
% mkdir prototype
|
38
|
+
|
39
|
+
Rails apps generally store images, javascripts, and stylesheets in the top level directories by the same name. Let's go ahead and mirror those directories for our prototype:
|
40
|
+
|
41
|
+
<pre>
|
42
|
+
% cd prototype
|
43
|
+
% mkdir images
|
44
|
+
% mkdir javascripts
|
45
|
+
% mkdir stylesheets
|
46
|
+
</pre>
|
47
|
+
|
48
|
+
|
49
|
+
h3. Creating Our First Screen
|
50
|
+
|
51
|
+
Now that we have the prototype directory set up, let's create our first page so that you can get a feel for how Serve works. This will be a simple HTML login page for our application.
|
52
|
+
|
53
|
+
Insert the following HTML into an file named "login.html.erb":
|
54
|
+
|
55
|
+
<pre><code>
|
56
|
+
<form action="/dashboard/" method="put">
|
57
|
+
<p>
|
58
|
+
<label for="username">Username</label>
|
59
|
+
<input type="text" name="username" id="username" />
|
60
|
+
</p>
|
61
|
+
<p>
|
62
|
+
<label for="password">Password</label>
|
63
|
+
<input type="password" name="password" id="password" />
|
64
|
+
</p>
|
65
|
+
<p>
|
66
|
+
<input type="submit" value="Login" />
|
67
|
+
</p>
|
68
|
+
</form>
|
69
|
+
</code></pre>
|
70
|
+
|
71
|
+
|
72
|
+
h3. Starting Serve
|
73
|
+
|
74
|
+
To view our login page in a Web browser, we need to start up Serve in the directory where we are building the prototype:
|
75
|
+
|
76
|
+
<pre>
|
77
|
+
% cd prototype
|
78
|
+
% serve
|
79
|
+
[2008-02-23 15:19:05] INFO WEBrick 1.3.1
|
80
|
+
[2008-02-23 15:19:05] INFO ruby 1.8.6 (2007-09-24) [universal-darwin9.0]
|
81
|
+
[2008-02-23 15:19:05] INFO Serve::Server#start: pid=5087 port=4000
|
82
|
+
...
|
83
|
+
</pre>
|
84
|
+
|
85
|
+
Once you execute the `serve` command it will launch a mini Web server for the prototype and will output a noisy log of any activity. (To stop the command at any point simply switch back to the command line and press Ctrl+C.)
|
86
|
+
|
87
|
+
By default the `serve` command automatically serves files from the directory that it is started in over port 4000 on your local machine. To access the the prototype in your Web browser go to:
|
88
|
+
|
89
|
+
http://localhost:4000
|
90
|
+
|
91
|
+
You should see a simple directory listing. It will look similar to this:
|
92
|
+
|
93
|
+
<pre>
|
94
|
+
Name Last modified Size
|
95
|
+
----------------------------------------------------------
|
96
|
+
Parent Directory 2008/02/23 15:35 -
|
97
|
+
images/ 2008/02/23 15:35 -
|
98
|
+
javascripts/ 2008/02/23 15:35 -
|
99
|
+
login.html.erb 2008/02/23 15:36 346
|
100
|
+
stylesheets/ 2008/02/23 15:35 -
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
Now navigate to the following URL:
|
104
|
+
|
105
|
+
http://localhost:4000/login/
|
106
|
+
|
107
|
+
You should see the contents of the login page. Note that Serve allows you to refer to pages without their extension. This allows you to use URLs in your documents that correspond well to the URLs that Rails uses by default.
|
108
|
+
|
109
|
+
|
110
|
+
h3. Layouts
|
111
|
+
|
112
|
+
One thing to note about the source that I gave you for the login page. I intentionally left out the <html>, <head>, and <body> tags because they belong a layout---not the source file. Let's go ahead and create that layout now.
|
113
|
+
|
114
|
+
Insert the following HTML into a file named "_layout.html.erb" in the root directory of your prototype:
|
115
|
+
|
116
|
+
<pre><code>
|
117
|
+
<html>
|
118
|
+
<head>
|
119
|
+
<title><%= @title %></title>
|
120
|
+
</head>
|
121
|
+
<body>
|
122
|
+
<h1><%= @title %>/h1>
|
123
|
+
<%= yield %>
|
124
|
+
</body>
|
125
|
+
</html>
|
126
|
+
</code></pre>
|
127
|
+
|
128
|
+
This layout includes a small amount of ERB(Embedded Ruby) to indicate the title of the web page and to insert the content of the page at the appropriate point.
|
129
|
+
|
130
|
+
Embedded Ruby is delineated with the opening and closing sequence <% and %> respectively. Sequences that begin with an addition equals sign insert their output directly into the HTML. In this case we want to render the @title variable as the title in the head and as the first heading in the document body. The yield keyword is used to insert the content of the page at that point.
|
131
|
+
|
132
|
+
We need to make one small change to our login page before continuing. Insert the following line at the top of login.html.erb file:
|
133
|
+
|
134
|
+
<pre>
|
135
|
+
<% @title = "Login" %>
|
136
|
+
</pre>
|
137
|
+
|
138
|
+
This will set the @title variable for the login page. Now, switch back to your Web browser and navigate to:
|
139
|
+
|
140
|
+
<pre>
|
141
|
+
http://localhost:4000/login/
|
142
|
+
</pre>
|
143
|
+
|
144
|
+
The page should now have a title and heading that both read "Login".
|
145
|
+
|
146
|
+
h3. Content For
|
147
|
+
|
148
|
+
h3. Partials
|
data/README.txt
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
== Serve
|
2
|
+
|
3
|
+
Serve is a small Ruby script that makes it easy to start up a WEBrick server
|
4
|
+
in any directory. Serve is ideal for HTML prototyping and simple file sharing.
|
5
|
+
If the haml, redcloth, and bluecloth gems are installed serve can handle Haml,
|
6
|
+
Sass, Textile, and Markdown (in addition to HTML and ERB).
|
7
|
+
|
8
|
+
|
9
|
+
=== Usage
|
10
|
+
|
11
|
+
At a command prompt all you need to type to start serve is:
|
12
|
+
|
13
|
+
$ serve
|
14
|
+
|
15
|
+
This will launch a WEBrick server which you can access from any Web browser at
|
16
|
+
the following address:
|
17
|
+
|
18
|
+
http://localhost:4000
|
19
|
+
|
20
|
+
Once the server is going it will output a running log of its activity. To
|
21
|
+
stop the server at any time, type CTRL+C at the command prompt. By default the
|
22
|
+
serve command serves up files from the current directory. To change this
|
23
|
+
behavior, `cd` to the appropriate directory before starting serve.
|
24
|
+
|
25
|
+
|
26
|
+
=== Advanced Options
|
27
|
+
|
28
|
+
The serve command automatically binds to 0.0.0.0 (localhost) and uses port
|
29
|
+
4000 by default. To serve files over a different IP (that is bound to your
|
30
|
+
computer) or port specify those options on the command line:
|
31
|
+
|
32
|
+
$ serve 4000 # a custom port
|
33
|
+
|
34
|
+
$ serve 192.168.1.6 # a custom IP
|
35
|
+
|
36
|
+
$ serve 192.168.1.6:4000 # a custom IP and port
|
37
|
+
|
38
|
+
|
39
|
+
=== Rails Applications
|
40
|
+
|
41
|
+
For your convenience if the file "script/server" exists in the current
|
42
|
+
directory the serve command will start that instead of launching a WEBrick
|
43
|
+
server. You can specify the environment that you want to start the server
|
44
|
+
with as an option on the command line:
|
45
|
+
|
46
|
+
$ serve production # start script/server in production mode
|
47
|
+
|
48
|
+
|
49
|
+
=== File Types
|
50
|
+
|
51
|
+
Serve presently does special processing for files with following extensions:
|
52
|
+
|
53
|
+
textile :: Evaluates the document as Textile (requires the Redcloth gem)
|
54
|
+
markdown :: Evaluates the document as Markdown (requires the Bluecloth gem)
|
55
|
+
erb :: Experimental support for ERB
|
56
|
+
haml :: Evaluates the document as Haml (requires the Haml gem)
|
57
|
+
sass :: Evaluates the document as Sass (requires the Haml gem)
|
58
|
+
email :: Evaluates the document as if it is an e-mail message; the format is identical to a plain/text e-mail message's source
|
59
|
+
redirect :: Redirects to the URL contained in the document
|
60
|
+
|
61
|
+
|
62
|
+
== View Helpers
|
63
|
+
|
64
|
+
If you drop a file called view_helpers.rb in the root of a project, you can define custom helpers for your Haml and ERB views. Just declare the ViewHelpers module and begin declaring your helpers:
|
65
|
+
|
66
|
+
module ViewHelpers
|
67
|
+
def custom_method
|
68
|
+
"Request object: #{request.headers['user-agent']}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
=== Installation and Setup
|
74
|
+
|
75
|
+
It is recommended that you install serve via RubyGems:
|
76
|
+
|
77
|
+
$ sudo gem install serve
|
78
|
+
|
79
|
+
|
80
|
+
=== More Information
|
81
|
+
|
82
|
+
For more information, be sure to look through the documentation over at
|
83
|
+
RubyForge:
|
84
|
+
|
85
|
+
* http://serve.rubyforge.org
|
86
|
+
|
87
|
+
Or visit the project page here:
|
88
|
+
|
89
|
+
* http://rubyforge.org/projects/serve
|
90
|
+
|
91
|
+
All development now takes place on GitHub:
|
92
|
+
|
93
|
+
* http://github.com/jlong/serve
|
94
|
+
|
95
|
+
|
96
|
+
=== License
|
97
|
+
|
98
|
+
Serve is released under the MIT license and is copyright (c) 2006-2008
|
99
|
+
John W. Long. A copy of the MIT license can be found in the License.txt file.
|
100
|
+
|
101
|
+
|
102
|
+
Enjoy!
|
103
|
+
|
104
|
+
--
|
105
|
+
John Long :: http://wiseheartdesign.com
|
data/VERSION.yml
ADDED
data/bin/serve
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
lib = File.dirname(__FILE__) + '/../lib'
|
3
|
+
require 'rubygems'
|
4
|
+
if File.file?(lib + '/serve/version.rb')
|
5
|
+
$LOAD_PATH << lib
|
6
|
+
else
|
7
|
+
gem 'serve'
|
8
|
+
end
|
9
|
+
require 'activesupport'
|
10
|
+
require 'serve'
|
11
|
+
require 'serve/application'
|
12
|
+
Serve::Application.run
|
data/lib/serve.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'serve/version'
|
2
|
+
require 'serve/file_resolver'
|
3
|
+
require 'serve/handlers/file_type_handler'
|
4
|
+
require 'serve/handlers/textile_handler'
|
5
|
+
require 'serve/handlers/markdown_handler'
|
6
|
+
require 'serve/handlers/dynamic_handler'
|
7
|
+
require 'serve/handlers/sass_handler'
|
8
|
+
require 'serve/handlers/email_handler'
|
9
|
+
require 'serve/handlers/redirect_handler'
|
10
|
+
require 'serve/response_cache'
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'serve/webrick/extensions'
|
3
|
+
require 'serve/webrick/servlet'
|
4
|
+
require 'serve/webrick/server'
|
5
|
+
|
6
|
+
module Serve
|
7
|
+
class Application
|
8
|
+
class InvalidArgumentsError < StandardError; end
|
9
|
+
|
10
|
+
attr_accessor :options
|
11
|
+
|
12
|
+
def self.run(args = ARGV)
|
13
|
+
new.run(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
self.options = {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(args = ARGV)
|
21
|
+
@options = parse(args)
|
22
|
+
case
|
23
|
+
when options[:version]
|
24
|
+
puts version
|
25
|
+
when options[:help]
|
26
|
+
puts help
|
27
|
+
else
|
28
|
+
Dir.chdir(options[:root])
|
29
|
+
if rails_app?
|
30
|
+
run_rails_app
|
31
|
+
else
|
32
|
+
run_server
|
33
|
+
end
|
34
|
+
end
|
35
|
+
rescue InvalidArgumentsError
|
36
|
+
puts "invalid arguments"
|
37
|
+
puts
|
38
|
+
puts help
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse(args)
|
42
|
+
args = normalize_args(args)
|
43
|
+
options[:help] = extract_boolean(args, '-h', '--help')
|
44
|
+
options[:version] = extract_boolean(args, '-v', '--version')
|
45
|
+
options[:environment] = extract_environment(args)
|
46
|
+
options[:root] = extract_root(args)
|
47
|
+
options[:address] = extract_address(args)
|
48
|
+
options[:port] = extract_port(args)
|
49
|
+
raise InvalidArgumentsError if args.size > 0
|
50
|
+
options
|
51
|
+
end
|
52
|
+
|
53
|
+
def version
|
54
|
+
"Serve #{Serve.version}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def help
|
58
|
+
program = File.basename($0)
|
59
|
+
[
|
60
|
+
"Usage:",
|
61
|
+
" #{program} [port] [environment] [port]",
|
62
|
+
" #{program} [address:port] [environment] [port]",
|
63
|
+
" #{program} [options]",
|
64
|
+
" ",
|
65
|
+
"Description:",
|
66
|
+
" Starts a WEBrick server on the specified address and port with its document ",
|
67
|
+
" root set to the current working directory. (Optionally, you can specify the ",
|
68
|
+
" directory as the last parameter.) By default the command uses 0.0.0.0 for ",
|
69
|
+
" the address and 4000 for the port. This means that once the command has ",
|
70
|
+
" been started you can access the documents in the current directory with any ",
|
71
|
+
" Web browser at:",
|
72
|
+
" ",
|
73
|
+
" http://localhost:4000/",
|
74
|
+
" ",
|
75
|
+
" If the haml, redcloth, or bluecloth gems are installed the command can serve ",
|
76
|
+
" Haml, Sass, Textile, and Markdown for documents with haml, sass, textile, ",
|
77
|
+
" and markdown file extensions.",
|
78
|
+
" ",
|
79
|
+
" If the Rails command script/server exists in the current directory the ",
|
80
|
+
" script will start that instead with the specified environment or the ",
|
81
|
+
" development environment if none is specified. Rails apps are started by ",
|
82
|
+
" default on port 3000.",
|
83
|
+
" ",
|
84
|
+
"Options:",
|
85
|
+
" -h, --help Show this message and quit.",
|
86
|
+
" -v, --version Show the program version number and quit."
|
87
|
+
].join("\n")
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
def normalize_args(args)
|
92
|
+
args = args.join(' ')
|
93
|
+
args.gsub!(%r{http://}, '')
|
94
|
+
args.split(/[ :]/).compact
|
95
|
+
end
|
96
|
+
|
97
|
+
def extract_boolean(args, *opts)
|
98
|
+
opts.each do |opt|
|
99
|
+
return true if args.delete(opt)
|
100
|
+
end
|
101
|
+
false
|
102
|
+
end
|
103
|
+
|
104
|
+
def extract_environment(args)
|
105
|
+
args.delete('production') || args.delete('test') || args.delete('development') || 'development'
|
106
|
+
end
|
107
|
+
|
108
|
+
def extract_port(args)
|
109
|
+
args.delete(args.find {|a| /^\d\d\d+$/.match(a) }) || (rails_app? ? 3000 : 4000)
|
110
|
+
end
|
111
|
+
|
112
|
+
def extract_address(args)
|
113
|
+
args.delete(args.find {|a| /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(a) }) || '0.0.0.0'
|
114
|
+
end
|
115
|
+
|
116
|
+
def extract_root(args)
|
117
|
+
args.reverse.each do |dir|
|
118
|
+
if File.directory?(dir)
|
119
|
+
args.delete(dir)
|
120
|
+
return File.expand_path(dir)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
Dir.pwd
|
124
|
+
end
|
125
|
+
|
126
|
+
def rails_script_server
|
127
|
+
@rails_server_script ||= options[:root] + '/script/server'
|
128
|
+
end
|
129
|
+
|
130
|
+
def rails_app?
|
131
|
+
File.file?(rails_script_server) and File.executable?(rails_script_server)
|
132
|
+
end
|
133
|
+
|
134
|
+
def run_rails_app
|
135
|
+
system "#{rails_script_server} -p #{options[:port]} -b #{options[:address]} -e #{options[:environment]}"
|
136
|
+
end
|
137
|
+
|
138
|
+
def run_server
|
139
|
+
extensions = Serve::WEBrick::Server.register_handlers
|
140
|
+
server = Serve::WEBrick::Server.new(
|
141
|
+
:Port => options[:port],
|
142
|
+
:BindAddress => options[:address],
|
143
|
+
:DocumentRoot => options[:root],
|
144
|
+
:DirectoryIndex => %w(index.html index.rhtml index.txt index.text) + extensions.collect {|ext| "index.#{ext}"}
|
145
|
+
)
|
146
|
+
trap("INT") { server.shutdown }
|
147
|
+
server.start
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|