serve 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,5 @@
1
+ * Added support for redirects
2
+
1
3
  == 0.9.1 (October 19, 2007)
2
4
 
3
5
  * Added basic support for email mockups.
data/README.txt CHANGED
@@ -1,4 +1,6 @@
1
- == What is Serve?
1
+ == Serve
2
+
3
+ === What is Serve?
2
4
 
3
5
  Serve is a small Ruby script that makes it easy to start up a WEBrick server
4
6
  in any directory. Serve is ideal for HTML prototyping and simple file sharing.
@@ -6,7 +8,7 @@ If the haml, redcloth, and bluecloth gems are installed serve can handle Haml,
6
8
  Sass, Textile, and Markdown (in addition to HTML).
7
9
 
8
10
 
9
- == Usage
11
+ === Usage
10
12
 
11
13
  At a command prompt all you need to type to start serve is:
12
14
 
@@ -23,7 +25,7 @@ serve command serves up files from the current directory. To change this
23
25
  behavior, `cd` to the appropriate directory before starting serve.
24
26
 
25
27
 
26
- == Advanced Options
28
+ === Advanced Options
27
29
 
28
30
  The serve command automatically binds to 0.0.0.0 (localhost) and uses port
29
31
  3000 by default. To serve files over a different IP (that is bound to your
@@ -36,7 +38,7 @@ computer) or port specify those options on the command line:
36
38
  $ serve 192.168.1.6:4000 # a custom IP and port
37
39
 
38
40
 
39
- == Rails Applications
41
+ === Rails Applications
40
42
 
41
43
  For your convenience if the file "script/server" exists in the current
42
44
  directory the serve command will start that instead of launching a WEBrick
@@ -46,14 +48,27 @@ with as an option on the command line:
46
48
  $ serve production # start script/server in production mode
47
49
 
48
50
 
49
- == Installation and Setup
51
+ === File Types
52
+
53
+ Serve presently does special processing for files with following extensions:
54
+
55
+ textile :: Evaluates the document as Textile (requires the Redcloth gem)
56
+ markdown :: Evaluates the document as Markdown (requires the Bluecloth gem)
57
+ haml :: Evaluates the document as Haml (requires the Haml gem)
58
+ sass :: Evaluates the document as Sass (requires the Haml gem)
59
+ email :: Evaluates the document as if it is an e-mail message; the format
60
+ is identicle to a plain/text e-mail message's source
61
+ redirect :: Redirects to the URL contained in the document
62
+
63
+
64
+ === Installation and Setup
50
65
 
51
66
  It is recommended that you install serve via RubyGems:
52
67
 
53
68
  $ sudo gem install serve
54
69
 
55
70
 
56
- == License
71
+ === License
57
72
 
58
73
  Serve is released under the MIT license and is copyright (c) John W. Long.
59
74
  A copy of the MIT license can be found in the License.txt file.
data/bin/serve CHANGED
@@ -62,8 +62,8 @@ else
62
62
  :Port => port,
63
63
  :BindAddress => address,
64
64
  :DocumentRoot => Dir.pwd,
65
- :DirectoryIndex => %w(index.html index.txt index.text index.haml index.textile index.markdown),
66
- :AppendExtensions => %w(html txt text haml textile markdown)
65
+ :DirectoryIndex => %w(index.html index.txt index.text index.haml index.textile index.markdown index.email index.redirect),
66
+ :AppendExtensions => %w(html txt text haml textile markdown email redirect)
67
67
  )
68
68
  trap("INT") { server.shutdown }
69
69
  server.start
data/lib/serve/version.rb CHANGED
@@ -2,7 +2,7 @@ module Serve #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 9
5
- TINY = 1
5
+ TINY = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/serve.rb CHANGED
@@ -12,12 +12,16 @@ module Serve #:nodoc:
12
12
  super
13
13
  @script_filename = name
14
14
  end
15
-
15
+
16
+ def process(req, res)
17
+ data = open(@script_filename){|io| io.read }
18
+ res['content-type'] = content_type
19
+ res.body = parse(data)
20
+ end
21
+
16
22
  def do_GET(req, res)
17
23
  begin
18
- data = open(@script_filename){|io| io.read }
19
- res.body = parse(data)
20
- res['content-type'] = content_type
24
+ process(req, res)
21
25
  rescue StandardError => ex
22
26
  raise
23
27
  rescue Exception => ex
@@ -106,7 +110,18 @@ module Serve #:nodoc:
106
110
  output << '</div><pre id="body" style="font-size: 110%; padding: 1em">'
107
111
  output << body
108
112
  output << '</pre></body></html>'
109
- output.join("\n")
113
+ output.join("\n")
114
+ end
115
+ end
116
+
117
+ class RedirectHandler < FileTypeHandler #:nodoc:
118
+ extension 'redirect'
119
+
120
+ def process(req, res)
121
+ data = super
122
+ res['location'] = data.strip
123
+ res.body = ''
124
+ raise WEBrick::HTTPStatus::Found
110
125
  end
111
126
  end
112
127
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: serve
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.1
7
- date: 2007-10-19 00:00:00 -04:00
6
+ version: 0.9.2
7
+ date: 2008-01-17 00:00:00 -05:00
8
8
  summary: Serve is a small Ruby script that makes it easy to start up a WEBrick server in any directory. Serve is ideal for HTML prototyping and simple file sharing. If the haml, redcloth, and bluecloth gems are installed serve can handle Haml, Sass, Textile, and Markdown (in addition to HTML).
9
9
  require_paths:
10
10
  - lib
metadata.gz.sig CHANGED
Binary file