serverside 0.2.0 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +26 -0
- data/README +39 -22
- data/Rakefile +18 -2
- data/bin/serverside +21 -5
- data/doc/rdoc/classes/ServerSide/Application.html +12 -19
- data/doc/rdoc/classes/ServerSide/Connection/Base.html +203 -116
- data/doc/rdoc/classes/ServerSide/Connection/Const.html +35 -5
- data/doc/rdoc/classes/ServerSide/Connection/Router.html +107 -78
- data/doc/rdoc/classes/ServerSide/Server.html +1 -1
- data/doc/rdoc/classes/ServerSide/StaticFiles/Const.html +10 -0
- data/doc/rdoc/classes/ServerSide/StaticFiles.html +73 -43
- data/doc/rdoc/classes/ServerSide/Template.html +200 -0
- data/doc/rdoc/classes/ServerSide.html +13 -8
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGELOG.html +44 -1
- data/doc/rdoc/files/README.html +63 -35
- data/doc/rdoc/files/lib/serverside/application_rb.html +1 -1
- data/doc/rdoc/files/lib/serverside/connection_rb.html +1 -1
- data/doc/rdoc/files/lib/serverside/routing_rb.html +1 -1
- data/doc/rdoc/files/lib/serverside/server_rb.html +1 -1
- data/doc/rdoc/files/lib/serverside/static_rb.html +1 -1
- data/doc/rdoc/files/lib/serverside/template_rb.html +108 -0
- data/doc/rdoc/fr_class_index.html +1 -2
- data/doc/rdoc/fr_file_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +18 -16
- data/lib/serverside/application.rb +0 -28
- data/lib/serverside/connection.rb +38 -12
- data/lib/serverside/routing.rb +23 -2
- data/lib/serverside/server.rb +1 -1
- data/lib/serverside/static.rb +12 -0
- data/lib/serverside/template.rb +36 -0
- data/test/functional/primitive_static_server_test.rb +26 -2
- data/test/functional/static_rfuzz.rb +3 -39
- data/test/spec/core_ext_spec.rb +68 -0
- data/test/unit/connection_test.rb +37 -1
- data/test/unit/template_test.rb +78 -0
- metadata +8 -6
- data/doc/rdoc/classes/ServerSide/Application/Base.html +0 -196
- data/doc/rdoc/classes/ServerSide/Application/Static.html +0 -156
- data/test/unit/application_test.rb +0 -16
data/CHANGELOG
CHANGED
@@ -1,5 +1,31 @@
|
|
1
|
+
*0.2.5*
|
2
|
+
|
3
|
+
* Added template serving to static file module.
|
4
|
+
|
5
|
+
* Wrote a simple ERB template system.
|
6
|
+
|
7
|
+
* More documentation tweaks.
|
8
|
+
|
9
|
+
* Changed how response cookies are formatted for somewhat better performance.
|
10
|
+
|
11
|
+
* Updated documentation.
|
12
|
+
|
13
|
+
* Removed deprecated code in lib/serverside/application.rb.
|
14
|
+
|
15
|
+
* Added HTTP cookie functionality (parse, set and delete.)
|
16
|
+
|
17
|
+
* Updated rakefile to include a spec task, as well as an rcov task. Updated test task to include spec and rcov tasks.
|
18
|
+
|
19
|
+
* Started writing RSpec tests. This looks like a very interesting concept.
|
20
|
+
|
21
|
+
* Added /test/spec directory.
|
22
|
+
|
1
23
|
*0.2.0*
|
2
24
|
|
25
|
+
* Updated RFuzz script to work, but it doesn't still do anything interesting.
|
26
|
+
|
27
|
+
* Added a serve command to serverside script.
|
28
|
+
|
3
29
|
* Changed substition of embedded parameters from (.*) to (.+).
|
4
30
|
|
5
31
|
* Added rule compilation after setting the default handler.
|
data/README
CHANGED
@@ -5,47 +5,64 @@ as easy as possible to use. ServerSide includes a full-featured HTTP server, a
|
|
5
5
|
controller-view system and a bunch of other tools to easily create servers and
|
6
6
|
clusters of servers.
|
7
7
|
|
8
|
-
==
|
8
|
+
== Resources
|
9
|
+
|
10
|
+
* {Project page}[http://code.google.com/p/serverside/]
|
11
|
+
* {Source code}[http://serverside.googlecode.com/svn/]
|
12
|
+
* {Bug tracking}[http://code.google.com/p/serverside/issues/list]
|
13
|
+
* {RubyForge page}[http://rubyforge.org/projects/serverside/]
|
9
14
|
|
10
|
-
|
15
|
+
To check out the repository, just perform:
|
16
|
+
|
17
|
+
svn co {http://serverside.googlecode.com/svn/}[http://serverside.googlecode.com/svn/]
|
11
18
|
|
12
|
-
==
|
19
|
+
== Installation
|
13
20
|
|
14
|
-
|
21
|
+
sudo gem install serverside
|
15
22
|
|
16
|
-
==
|
23
|
+
== Usage
|
17
24
|
|
18
25
|
Once you have the ServerSide gem installed, you can use the <tt>serverside</tt>
|
19
26
|
script to control servers. For example:
|
20
27
|
|
21
|
-
|
28
|
+
serverside start .
|
29
|
+
|
30
|
+
will start an HTTP server on port 8000, serving the content of the working
|
31
|
+
directory. You can stop the server by running <tt>serverside stop .</tt>
|
22
32
|
|
23
|
-
|
24
|
-
|
33
|
+
To run the server without forking, use the 'serve' command:
|
34
|
+
|
35
|
+
serverside serve .
|
36
|
+
|
37
|
+
== Serving ERb Templates
|
38
|
+
|
39
|
+
ServerSide can render ERb[http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/]
|
40
|
+
templates in a fashion similar to PHP. You can store templates in .rhtml files,
|
41
|
+
and ServerSide takes care of all the rest. ServerSide is also smart enough to
|
42
|
+
allow you to use nice looking URL's with your templates, and automatically adds
|
43
|
+
the .rhtml extension if the file is there.
|
25
44
|
|
26
45
|
== Serving Dynamic Content
|
27
46
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
URL parameters etc.
|
32
|
-
|
33
|
-
To start your app, you can either supply the <tt>serverside</tt> script with
|
34
|
-
your Ruby code file:
|
47
|
+
By default ServerSide serves static files, but you can change the behavior by
|
48
|
+
creating custom {routing rules}[classes/ServerSide/Connection/Router.html].
|
49
|
+
Here's a simple routing rule:
|
35
50
|
|
36
|
-
|
51
|
+
ServerSide.route(:path => '/hello/:name') {
|
52
|
+
send_response(200, 'text', "Hello #{@parameters[:name]}!")
|
53
|
+
}
|
37
54
|
|
38
|
-
|
39
|
-
|
55
|
+
The ServerSide framework also lets you route requests based on any attribute of
|
56
|
+
incoming requests, such as host name, path, URL parameters etc.
|
40
57
|
|
41
|
-
|
58
|
+
To run your custom rules, you can either put them in a file called serverside.rb,
|
59
|
+
or tell serverside to explicitly load a specific file:
|
42
60
|
|
43
|
-
|
44
|
-
take care of everything else.
|
61
|
+
serverside start ~/myapp/myapp.rb
|
45
62
|
|
46
63
|
== Running a Cluster of Servers
|
47
64
|
|
48
65
|
ServerSide makes it easy to control a cluster of servers. Just supply a range of
|
49
66
|
ports instead of a single port:
|
50
67
|
|
51
|
-
|
68
|
+
serverside -p 8000..8009 start .
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'fileutils'
|
|
7
7
|
include FileUtils
|
8
8
|
|
9
9
|
NAME = "serverside"
|
10
|
-
VERS = "0.2.
|
10
|
+
VERS = "0.2.5"
|
11
11
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
12
12
|
RDOC_OPTS = ['--quiet', '--title', "ServerSide Documentation",
|
13
13
|
"--opname", "index.html",
|
@@ -68,7 +68,7 @@ task :uninstall => [:clean] do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
task :doc_rforge do
|
71
|
-
|
71
|
+
Rake::Task['doc'].execute
|
72
72
|
sh %{scp -r doc/rdoc/* ciconia@rubyforge.org:/var/www/gforge-projects/serverside}
|
73
73
|
end
|
74
74
|
|
@@ -86,6 +86,16 @@ Rake::TestTask.new('test_functional') do |t|
|
|
86
86
|
t.verbose = true
|
87
87
|
end
|
88
88
|
|
89
|
+
desc 'Run specification tests'
|
90
|
+
task :spec do
|
91
|
+
sh %{spec test/spec/*_spec.rb}
|
92
|
+
end
|
93
|
+
|
94
|
+
desc 'Run rcov'
|
95
|
+
task :rcov do
|
96
|
+
sh %{rcov test/unit/*_test.rb test/functional/*_test.rb}
|
97
|
+
end
|
98
|
+
|
89
99
|
desc 'Run all tests'
|
90
100
|
Rake::TestTask.new('test') do |t|
|
91
101
|
t.libs << 'test'
|
@@ -93,6 +103,12 @@ Rake::TestTask.new('test') do |t|
|
|
93
103
|
t.verbose = true
|
94
104
|
end
|
95
105
|
|
106
|
+
desc 'Run all tests, specs and finish with rcov'
|
107
|
+
task :aok do
|
108
|
+
Rake::Task['rcov'].execute
|
109
|
+
Rake::Task['spec'].execute
|
110
|
+
end
|
111
|
+
|
96
112
|
##############################################################################
|
97
113
|
# Statistics
|
98
114
|
##############################################################################
|
data/bin/serverside
CHANGED
@@ -10,10 +10,15 @@ $cmd_config = {
|
|
10
10
|
}
|
11
11
|
|
12
12
|
opts = OptionParser.new do |opts|
|
13
|
-
opts.banner = "Usage: serverside start|stop|restart [app1
|
13
|
+
opts.banner = "Usage: serverside start|stop|restart|serve [app1]"
|
14
14
|
opts.define_head "ServerSide, a fast and simple web framework for ruby."
|
15
15
|
opts.separator ""
|
16
|
-
opts.separator "The supplied app
|
16
|
+
opts.separator "The supplied app path can be directory or file references. \
|
17
|
+
If the path refers to a directory the system will try to load serverside.rb in \
|
18
|
+
that directory. If no path is given, the current working directory is assumed."
|
19
|
+
opts.separator ""
|
20
|
+
opts.separator "* The start, stop and restart commands are used to control the daemon."
|
21
|
+
opts.separator "* The serve command is used to start the server without forking."
|
17
22
|
opts.separator ""
|
18
23
|
opts.separator "Options:"
|
19
24
|
|
@@ -47,8 +52,8 @@ if ARGV.length < 1
|
|
47
52
|
end
|
48
53
|
|
49
54
|
$cmd = ARGV.shift
|
50
|
-
unless %w(start stop restart).include?($cmd)
|
51
|
-
puts "Invalid command specified. Known commands are: start, stop, restart."
|
55
|
+
unless %w(start stop restart serve).include?($cmd)
|
56
|
+
puts "Invalid command specified. Known commands are: start, stop, restart, serve."
|
52
57
|
exit
|
53
58
|
end
|
54
59
|
|
@@ -63,4 +68,15 @@ unless ServerSide::Connection::Router.has_routes?
|
|
63
68
|
ServerSide.route_default {serve_static('.'/@path)}
|
64
69
|
end
|
65
70
|
|
66
|
-
|
71
|
+
if $cmd == 'serve'
|
72
|
+
if $cmd_config[:ports].begin != $cmd_config[:ports].end
|
73
|
+
puts "Please specify a single port."
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
puts "Serving at #{$cmd_config[:host]}:#{$cmd_config[:ports].begin}..."
|
77
|
+
trap('INT') {exit}
|
78
|
+
ServerSide::Server.new($cmd_config[:host], $cmd_config[:ports].begin,
|
79
|
+
ServerSide::Connection::Router)
|
80
|
+
else
|
81
|
+
ServerSide::Application.daemonize($cmd_config, $cmd)
|
82
|
+
end
|
@@ -80,8 +80,8 @@
|
|
80
80
|
<h3 class="section-bar">Methods</h3>
|
81
81
|
|
82
82
|
<div class="name-list">
|
83
|
-
<a href="#
|
84
|
-
<a href="#
|
83
|
+
<a href="#M000028">config=</a>
|
84
|
+
<a href="#M000029">daemonize</a>
|
85
85
|
</div>
|
86
86
|
</div>
|
87
87
|
|
@@ -92,13 +92,6 @@
|
|
92
92
|
|
93
93
|
<div id="section">
|
94
94
|
|
95
|
-
<div id="class-list">
|
96
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
97
|
-
|
98
|
-
Class <a href="Application/Base.html" class="link">ServerSide::Application::Base</a><br />
|
99
|
-
Class <a href="Application/Static.html" class="link">ServerSide::Application::Static</a><br />
|
100
|
-
|
101
|
-
</div>
|
102
95
|
|
103
96
|
|
104
97
|
|
@@ -110,19 +103,19 @@ Class <a href="Application/Static.html" class="link">ServerSide::Application::St
|
|
110
103
|
<div id="methods">
|
111
104
|
<h3 class="section-bar">Public Class methods</h3>
|
112
105
|
|
113
|
-
<div id="method-
|
114
|
-
<a name="
|
106
|
+
<div id="method-M000028" class="method-detail">
|
107
|
+
<a name="M000028"></a>
|
115
108
|
|
116
109
|
<div class="method-heading">
|
117
|
-
<a href="#
|
110
|
+
<a href="#M000028" class="method-signature">
|
118
111
|
<span class="method-name">config=</span><span class="method-args">(c)</span>
|
119
112
|
</a>
|
120
113
|
</div>
|
121
114
|
|
122
115
|
<div class="method-description">
|
123
116
|
<p><a class="source-toggle" href="#"
|
124
|
-
onclick="toggleCode('
|
125
|
-
<div class="method-source-code" id="
|
117
|
+
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
118
|
+
<div class="method-source-code" id="M000028-source">
|
126
119
|
<pre>
|
127
120
|
<span class="ruby-comment cmt"># File lib/serverside/application.rb, line 9</span>
|
128
121
|
9: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">config=</span>(<span class="ruby-identifier">c</span>)
|
@@ -133,19 +126,19 @@ Class <a href="Application/Static.html" class="link">ServerSide::Application::St
|
|
133
126
|
</div>
|
134
127
|
</div>
|
135
128
|
|
136
|
-
<div id="method-
|
137
|
-
<a name="
|
129
|
+
<div id="method-M000029" class="method-detail">
|
130
|
+
<a name="M000029"></a>
|
138
131
|
|
139
132
|
<div class="method-heading">
|
140
|
-
<a href="#
|
133
|
+
<a href="#M000029" class="method-signature">
|
141
134
|
<span class="method-name">daemonize</span><span class="method-args">(config, cmd)</span>
|
142
135
|
</a>
|
143
136
|
</div>
|
144
137
|
|
145
138
|
<div class="method-description">
|
146
139
|
<p><a class="source-toggle" href="#"
|
147
|
-
onclick="toggleCode('
|
148
|
-
<div class="method-source-code" id="
|
140
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
141
|
+
<div class="method-source-code" id="M000029-source">
|
149
142
|
<pre>
|
150
143
|
<span class="ruby-comment cmt"># File lib/serverside/application.rb, line 13</span>
|
151
144
|
13: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">daemonize</span>(<span class="ruby-identifier">config</span>, <span class="ruby-identifier">cmd</span>)
|