ramaze 2012.04.14 → 2012.12.08b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gems +28 -35
- data/.gitignore +4 -0
- data/.travis.yml +3 -3
- data/Gemfile +3 -0
- data/README.md +1 -5
- data/Rakefile +9 -20
- data/examples/app/blog/app.rb +5 -14
- data/examples/app/todolist/start.rb +1 -5
- data/guide/AUTHORS +8 -3
- data/guide/CHANGELOG +587 -0
- data/guide/general/cache.md +1 -0
- data/guide/general/configuration.md +2 -1
- data/guide/general/contributing.md +1 -0
- data/guide/general/controllers.md +105 -10
- data/guide/general/helpers.md +6 -7
- data/guide/general/installation.md +2 -1
- data/guide/general/logging.md +1 -4
- data/guide/general/middlewares.md +15 -23
- data/guide/general/models.md +1 -0
- data/guide/general/principles.md +1 -0
- data/guide/general/ramaze_command.md +9 -54
- data/guide/general/routes.md +1 -0
- data/guide/general/sessions.md +3 -2
- data/guide/general/special_thanks.md +1 -0
- data/guide/general/testing.md +1 -0
- data/guide/general/views.md +35 -22
- data/lib/proto/Gemfile +4 -0
- data/lib/proto/README.md +35 -0
- data/lib/proto/Rakefile +1 -0
- data/lib/proto/app.rb +2 -6
- data/lib/proto/spec/helper.rb +39 -0
- data/lib/proto/task/ramaze.rake +57 -0
- data/lib/ramaze.rb +12 -39
- data/lib/ramaze/bin/create.rb +1 -3
- data/lib/ramaze/bin/runner.rb +0 -14
- data/lib/ramaze/cache.rb +21 -0
- data/lib/ramaze/cache/memcache.rb +1 -3
- data/lib/ramaze/cache/redis.rb +2 -4
- data/lib/ramaze/cache/sequel.rb +4 -5
- data/lib/ramaze/controller.rb +10 -3
- data/lib/ramaze/default_middleware.rb +24 -0
- data/lib/ramaze/files.rb +5 -5
- data/lib/ramaze/gestalt.rb +10 -10
- data/lib/ramaze/helper/blue_form.rb +33 -6
- data/lib/ramaze/helper/csrf.rb +22 -30
- data/lib/ramaze/helper/flash.rb +1 -1
- data/lib/ramaze/helper/upload.rb +5 -3
- data/lib/ramaze/helper/user.rb +1 -0
- data/lib/ramaze/log.rb +0 -5
- data/lib/ramaze/log/informer.rb +3 -3
- data/lib/ramaze/log/logging.rb +4 -4
- data/lib/ramaze/log/syslog.rb +2 -2
- data/lib/ramaze/response.rb +1 -1
- data/lib/ramaze/snippets.rb +0 -20
- data/lib/ramaze/spec/bacon.rb +5 -13
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view/erector.rb +1 -3
- data/lib/ramaze/view/erubis.rb +1 -3
- data/lib/ramaze/view/ezamar.rb +1 -3
- data/lib/ramaze/view/haml.rb +1 -4
- data/lib/ramaze/view/liquid.rb +1 -3
- data/lib/ramaze/view/lokar.rb +1 -3
- data/lib/ramaze/view/mustache.rb +1 -3
- data/lib/ramaze/view/nagoro.rb +1 -4
- data/lib/ramaze/view/remarkably.rb +1 -4
- data/lib/ramaze/view/sass.rb +2 -5
- data/lib/ramaze/view/slim.rb +1 -3
- data/lib/ramaze/view/slippers.rb +1 -3
- data/lib/ramaze/view/tagz.rb +1 -3
- data/lib/ramaze/view/tenjin.rb +1 -3
- data/ramaze.gemspec +45 -16
- data/spec/helper.rb +0 -1
- data/spec/ramaze/cache/localmemcache.rb +0 -4
- data/spec/ramaze/controller/mapping.rb +17 -0
- data/spec/ramaze/dispatcher/directory.rb +6 -5
- data/spec/ramaze/dispatcher/file.rb +7 -4
- data/spec/ramaze/files.rb +0 -2
- data/spec/ramaze/helper/csrf.rb +0 -26
- data/spec/ramaze/helper/upload.rb +1 -0
- data/spec/ramaze/helper/user.rb +12 -0
- data/spec/ramaze/log/syslog.rb +5 -1
- data/spec/ramaze/view/lokar.rb +1 -1
- data/spec/ramaze/view/nagoro.rb +1 -1
- data/tasks/bacon.rake +1 -1
- data/tasks/gems.rake +15 -0
- data/tasks/release.rake +37 -8
- metadata +106 -139
- data/guide/_static/ramaze_console.png +0 -0
- data/guide/tutorials/introduction.md +0 -263
- data/lib/proto/model/init.rb +0 -6
- data/lib/proto/public/.htaccess +0 -24
- data/lib/proto/public/dispatch.fcgi +0 -11
- data/lib/proto/spec/main.rb +0 -20
- data/lib/proto/start.rb +0 -20
- data/lib/ramaze/app_graph.rb +0 -105
- data/lib/ramaze/bin/console.rb +0 -87
- data/lib/ramaze/bin/helper.rb +0 -107
- data/lib/ramaze/bin/restart.rb +0 -95
- data/lib/ramaze/bin/start.rb +0 -221
- data/lib/ramaze/bin/status.rb +0 -152
- data/lib/ramaze/bin/stop.rb +0 -112
- data/lib/ramaze/dependencies.rb +0 -84
- data/lib/ramaze/helper/disqus.rb +0 -27
- data/lib/ramaze/helper/ultraviolet.rb +0 -49
- data/lib/ramaze/log/analogger.rb +0 -50
- data/lib/ramaze/log/growl.rb +0 -55
- data/lib/ramaze/log/knotify.rb +0 -31
- data/lib/ramaze/log/xosd.rb +0 -94
- data/lib/ramaze/middleware_compiler.rb +0 -36
- data/lib/ramaze/plugin.rb +0 -69
- data/lib/ramaze/setup.rb +0 -210
- data/lib/ramaze/snippets/array/put_within.rb +0 -38
- data/lib/ramaze/snippets/binding/locals.rb +0 -20
- data/lib/ramaze/snippets/fiber.rb +0 -41
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +0 -18
- data/lib/ramaze/snippets/metaid.rb +0 -17
- data/lib/ramaze/snippets/numeric/filesize_format.rb +0 -30
- data/lib/ramaze/snippets/numeric/time.rb +0 -59
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +0 -16
- data/lib/ramaze/snippets/object/pretty.rb +0 -12
- data/lib/ramaze/snippets/object/scope.rb +0 -16
- data/lib/ramaze/snippets/ordered_set.rb +0 -51
- data/lib/ramaze/snippets/proc/locals.rb +0 -19
- data/lib/ramaze/snippets/ramaze/acquire.rb +0 -32
- data/lib/ramaze/snippets/ramaze/dictionary.rb +0 -400
- data/lib/ramaze/snippets/ramaze/fiber.rb +0 -24
- data/lib/ramaze/snippets/ramaze/struct.rb +0 -43
- data/lib/ramaze/snippets/string/end_with.rb +0 -17
- data/lib/ramaze/snippets/string/ord.rb +0 -16
- data/lib/ramaze/snippets/string/start_with.rb +0 -14
- data/lib/ramaze/snippets/thread/into.rb +0 -16
- data/lib/ramaze/spec.rb +0 -4
- data/spec/ramaze/bin/start.rb +0 -34
- data/spec/ramaze/log/growl.rb +0 -45
- data/spec/ramaze/struct.rb +0 -50
- data/spec/snippets/array/put_within.rb +0 -38
- data/spec/snippets/binding/locals.rb +0 -12
- data/spec/snippets/numeric/filesize_format.rb +0 -15
- data/spec/snippets/numeric/time.rb +0 -15
- data/spec/snippets/ordered_set.rb +0 -66
- data/spec/snippets/ramaze/acquire.rb +0 -80
- data/spec/snippets/ramaze/dictionary.rb +0 -113
- data/spec/snippets/ramaze/struct.rb +0 -15
- data/spec/snippets/thread/into.rb +0 -12
- data/tasks/gem.rake +0 -21
- data/tasks/setup.rake +0 -14
|
Binary file
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
# Introduction Tutorial
|
|
2
|
-
|
|
3
|
-
This tutorial focuses on teaching the basics of Ramaze. Before reading this
|
|
4
|
-
tutorial it's recommended that you first read some of the other chapters to get
|
|
5
|
-
a bit of an understanding what Ramaze really is and what it does. It's required
|
|
6
|
-
that you've read the following chapters before reading this tutorial (or any of
|
|
7
|
-
the other tutorials):
|
|
8
|
-
|
|
9
|
-
* {file:README READE}
|
|
10
|
-
* {file:general/installation Installation}
|
|
11
|
-
|
|
12
|
-
In this tutorial we'll cover te following:
|
|
13
|
-
|
|
14
|
-
* Creating applications and running them.
|
|
15
|
-
* Debugging applications using ``ramaze console``
|
|
16
|
-
* Basic introduction to controllers and views.
|
|
17
|
-
|
|
18
|
-
<div class="note todo">
|
|
19
|
-
<p>
|
|
20
|
-
<strong>Note</strong>: Do not blindly copy-paste the code found in this
|
|
21
|
-
tutorial. It's extremely important that you type it manually as this
|
|
22
|
-
makes the learning process much easier and faster.
|
|
23
|
-
</p>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
## Creating Applications
|
|
27
|
-
|
|
28
|
-
Creating applications can be done in two different ways, using the Ramaze
|
|
29
|
-
executable (called "ramaze") or by manually writing the code. In this tutorial
|
|
30
|
-
we'll use the last approach as it teaches more about what each file does. If
|
|
31
|
-
you're interested in learning more about the executable read the chapter
|
|
32
|
-
{file:general/ramaze_command Ramaze Command}.
|
|
33
|
-
|
|
34
|
-
The first step is to create our project directory, let's call it "tutorial"::
|
|
35
|
-
|
|
36
|
-
$ mkdir tutorial
|
|
37
|
-
$ cd tutorial
|
|
38
|
-
|
|
39
|
-
Each Ramaze application requires a Rackup configuration file ("config.ru") and
|
|
40
|
-
a base file that's used to load all the bits and pieces of your application,
|
|
41
|
-
typically called "app.rb". The Rackup configuration file is used to tell
|
|
42
|
-
webservers such as Thin or Unicorn how they should run Ramaze. Let's start with
|
|
43
|
-
the Rackup file:
|
|
44
|
-
|
|
45
|
-
require ::File.expand_path('../app', __FILE__)
|
|
46
|
-
|
|
47
|
-
Ramaze.start(:root => Ramaze.options.roots, :started => true)
|
|
48
|
-
|
|
49
|
-
run Ramaze
|
|
50
|
-
|
|
51
|
-
The first line of code is used to load our main file "app.rb" (more on this in
|
|
52
|
-
a bit). The path is constructed so that the file is loaded from the same
|
|
53
|
-
directory as the config.ru file. The next line is used to start Ramaze and tell
|
|
54
|
-
it that it's running as well as setting the root directory from which the
|
|
55
|
-
command should be executed. The last line simply tells Rack to start Ramaze.
|
|
56
|
-
Simple right? No? Well here's the good part, you should only have to write this
|
|
57
|
-
code once. If you're lazy you can just copy-paste the code above and save
|
|
58
|
-
yourself some time.
|
|
59
|
-
|
|
60
|
-
The next step is to create our app.rb file. Note that this file can be named
|
|
61
|
-
anything you like but in all the tutorials "app.rb" will be used, on top of
|
|
62
|
-
that it's somewhat of a standard so it's best to just stick with the name. The
|
|
63
|
-
contents of this file can be anything you like as long as it contains the
|
|
64
|
-
following lines of code:
|
|
65
|
-
|
|
66
|
-
require 'rubygems' # Only required on Ruby < 1.9
|
|
67
|
-
require 'ramaze' # Always required
|
|
68
|
-
|
|
69
|
-
# Sets the root directory to the current directory by default. Feel free to
|
|
70
|
-
# add more directories when needed.
|
|
71
|
-
Ramaze.options.roots = [__DIR__]
|
|
72
|
-
|
|
73
|
-
This will load the Ramaze gem, without it you won't be able to create a Ramaze
|
|
74
|
-
application. Besides this you'll obviously need to load a few more files in
|
|
75
|
-
order to get a working application. Let's create our first controller and load
|
|
76
|
-
it in this file, because we've already opened app.rb we'll just add the require
|
|
77
|
-
statement for it right away:
|
|
78
|
-
|
|
79
|
-
require __DIR__('controller/tutorial')
|
|
80
|
-
|
|
81
|
-
This line of code will tell Ruby to load the file "tutorial.rb" from
|
|
82
|
-
$DIR/controller/ where $DIR is the project directory. __DIR__ is a special
|
|
83
|
-
method provided by Ramaze that basically does the same as the following:
|
|
84
|
-
|
|
85
|
-
File.expand_path("../#{some_path}", __FILE__)
|
|
86
|
-
|
|
87
|
-
Whenever you want to load something relative to a file it's best to use
|
|
88
|
-
__DIR__ (or require_relative if you're on 1.9).
|
|
89
|
-
|
|
90
|
-
Right, time to create the controller we just loaded (don't actually start the
|
|
91
|
-
application, it will trigger an error!)::
|
|
92
|
-
|
|
93
|
-
$ mkdir controller/
|
|
94
|
-
$ touch controller/tutorial.rb
|
|
95
|
-
|
|
96
|
-
Now open the tutorial.rb file in your favorite editor. Obviously this file is
|
|
97
|
-
still empty so we'll need to add some code to the file. We'll be creating a
|
|
98
|
-
class called "Tutorial" that will be mapped to "/" (the root of your
|
|
99
|
-
application). This can be done as following:
|
|
100
|
-
|
|
101
|
-
class Tutorial < Ramaze::Controller
|
|
102
|
-
map '/'
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
It's important that you always extend Ramaze::Controller, whether it's extended
|
|
106
|
-
directly or via another class. Without this Ramaze won't recognize the class as
|
|
107
|
-
a controller nor will you be able to use controller specific methods.
|
|
108
|
-
|
|
109
|
-
## Running Applications
|
|
110
|
-
|
|
111
|
-
Currently we have the following files:
|
|
112
|
-
|
|
113
|
-
* config.ru
|
|
114
|
-
* app.rb
|
|
115
|
-
* controller/tutorial.rb
|
|
116
|
-
|
|
117
|
-
Let's see if our application is working, start it with the following command::
|
|
118
|
-
|
|
119
|
-
$ ramaze start
|
|
120
|
-
|
|
121
|
-
If everything went well the output of this command should look like the
|
|
122
|
-
following::
|
|
123
|
-
|
|
124
|
-
[2011-05-24 17:37:31] INFO WEBrick 1.3.1
|
|
125
|
-
[2011-05-24 17:37:31] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.0]
|
|
126
|
-
[2011-05-24 17:37:31] INFO WEBrick::HTTPServer#start: pid=74568 port=7000
|
|
127
|
-
|
|
128
|
-
If you now were to navigate your browser to http://localhost:7000/ you'd get the
|
|
129
|
-
following response:
|
|
130
|
-
|
|
131
|
-
No action found at: "/"
|
|
132
|
-
|
|
133
|
-
This message is displayed because while there is a controller (Tutorial) it
|
|
134
|
-
doesn't have any methods available for the requested URI. Let's go ahead and add
|
|
135
|
-
a method to our controller, shut down WEBRick (Ctrl + C) and open the file
|
|
136
|
-
controller/tutorial.rb. Modify it so that it's code looks like the following:
|
|
137
|
-
|
|
138
|
-
class Tutorial < Ramaze::Controller
|
|
139
|
-
map '/'
|
|
140
|
-
|
|
141
|
-
def index
|
|
142
|
-
"Hello, world!"
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
Save the file and restart WEBRick using ``ramaze start``. If you now refresh
|
|
147
|
-
the page you'd see the message "Hello, world!" opposed to the "No action found.."
|
|
148
|
-
message. This is because we now have a method for the URI "/". Ramaze maps the
|
|
149
|
-
public methods of a controller to the URI of the controller. This means that if
|
|
150
|
-
you added another method to this controller named "cookie" you'd be able to
|
|
151
|
-
access it from /cookie. The method used for a URI of / is "index" by default but
|
|
152
|
-
this can be changed as following:
|
|
153
|
-
|
|
154
|
-
class Tutorial < Ramaze::Controller
|
|
155
|
-
map '/'
|
|
156
|
-
|
|
157
|
-
trait :default_action_name => 'default'
|
|
158
|
-
|
|
159
|
-
def default
|
|
160
|
-
"Hello, world!"
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
The trait() method is a method provided by Ramaze that can be used to set
|
|
165
|
-
configuration options in a class, don't worry about it for now.
|
|
166
|
-
|
|
167
|
-
Obviously a plain text message is boring, let's get started with "views". Views
|
|
168
|
-
are files that will contain the presentation layer (usually HTML) of your
|
|
169
|
-
application. In order to create a view we'll have to create a view directory
|
|
170
|
-
first::
|
|
171
|
-
|
|
172
|
-
$ mkdir view/
|
|
173
|
-
|
|
174
|
-
In order to render a view you'll have to create a view that matches a method's
|
|
175
|
-
name and is placed in the correct directory. In this case our method is called
|
|
176
|
-
"index" and the controller is mapped to /. This means that our view would be
|
|
177
|
-
located in view/index.xhtml. If our method was named "default" the view would
|
|
178
|
-
be in view/default.xhtml. If the controller was mapped to /cookie the view would
|
|
179
|
-
be located in view/cookie.index.xhtml and so on. Let's create and edit the file::
|
|
180
|
-
|
|
181
|
-
$ touch view/index.xhtml
|
|
182
|
-
$ $EDITOR view/index.xhtml
|
|
183
|
-
|
|
184
|
-
Just like all the other files this one is empty. A view can contain HTML and
|
|
185
|
-
Ruby code based on the template engine you're using. By default Ramaze uses
|
|
186
|
-
Etanni which allows you to wrap your Ruby code in #{} for outputting variables
|
|
187
|
-
and <?r ?> for statements:
|
|
188
|
-
|
|
189
|
-
<?r if !@username.nil? ?>
|
|
190
|
-
#{@username}
|
|
191
|
-
<?r end ?>
|
|
192
|
-
|
|
193
|
-
Let's add the following data to the view:
|
|
194
|
-
|
|
195
|
-
<p>Hello, #{@username}!</p>
|
|
196
|
-
|
|
197
|
-
Once this is done modify your Tutorial controller so that it looks like the
|
|
198
|
-
following:
|
|
199
|
-
|
|
200
|
-
class Tutorial < Ramaze::Controller
|
|
201
|
-
map '/'
|
|
202
|
-
|
|
203
|
-
def index
|
|
204
|
-
@username = "Ramaze"
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
From this point on all requests made to / will not result in a response of
|
|
209
|
-
"Hello, world!" but instead will display "Hello, Ramaze!". The cool thing is
|
|
210
|
-
that you don't have to manually load the view (but you still can if you like).
|
|
211
|
-
If the method of a controller has no return value Ramaze will try to load the
|
|
212
|
-
corresponding view.
|
|
213
|
-
|
|
214
|
-
## Debugging Applications
|
|
215
|
-
|
|
216
|
-
Quite often you'll want to quickly look something up, say the list of available
|
|
217
|
-
methods of a class, in your application. A common approach is to restart your
|
|
218
|
-
application every time
|
|
219
|
-
you've made your changes but this can become really annoying. To solve this issue
|
|
220
|
-
Ramaze comes with the command ``ramaze console``. This command basically loads
|
|
221
|
-
IRB along with your application, allowing you to play with it without having to
|
|
222
|
-
restart your server every time.
|
|
223
|
-
|
|
224
|
-
In order for us to be able to use the console we'll have to add a new file to
|
|
225
|
-
our project, called "start.rb". start.rb works the same as config.ru but
|
|
226
|
-
instead of being used for Rackup it's used to tell Ramaze how to run it in IRB.
|
|
227
|
-
Create the file and open it in your editor ($EDITOR is the command used for
|
|
228
|
-
opening a file in your editor)::
|
|
229
|
-
|
|
230
|
-
$ touch start.rb
|
|
231
|
-
$ $EDITOR start.rb
|
|
232
|
-
|
|
233
|
-
Add the following code to it:
|
|
234
|
-
|
|
235
|
-
require File.expand_path('../app', __FILE__)
|
|
236
|
-
|
|
237
|
-
Ramaze.start(:adapter => :webrick, :port => 7000, :file => __FILE__)
|
|
238
|
-
|
|
239
|
-
Anything that looks familiar? This code is almost identical except that instead
|
|
240
|
-
of calling "run Ramaze" it invokes the Ramaze.start command without telling it
|
|
241
|
-
it will be started by something else (this is done using the :started option).
|
|
242
|
-
Don't bother too much about this file as it's pretty boring, save it and leave
|
|
243
|
-
it alone.
|
|
244
|
-
|
|
245
|
-
Now that we've added the required file we can invoke the console. This is done
|
|
246
|
-
as following::
|
|
247
|
-
|
|
248
|
-
$ ramaze console
|
|
249
|
-
ruby-1.9.2-p180 :001 >
|
|
250
|
-
|
|
251
|
-
You can use the console for everything you'd normally use IRB for but it comes
|
|
252
|
-
with the added value of being able to do Ramaze specific things::
|
|
253
|
-
|
|
254
|
-
ruby-1.9.2-p180 :001 > Ramaze.options.app.name
|
|
255
|
-
=> :pristine
|
|
256
|
-
|
|
257
|
-
If you're done playing you can close the console with Ctrl + D.
|
|
258
|
-
|
|
259
|
-
And that's really about it. While we've only scratched the surface of Ramaze
|
|
260
|
-
we've already managed to write some Ramaze specific code as well as learning
|
|
261
|
-
how to use the console and how to start applications. The source code created in
|
|
262
|
-
this tutorial can be found here:
|
|
263
|
-
https://github.com/Ramaze/ramaze-user-guide-code/tree/master/introduction
|
data/lib/proto/model/init.rb
DELETED
data/lib/proto/public/.htaccess
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# General Apache options
|
|
2
|
-
Options +FollowSymLinks +ExecCGI
|
|
3
|
-
AddHandler cgi-script cgi rb
|
|
4
|
-
<IfModule mod_fastcgi.c>
|
|
5
|
-
AddHandler fastcgi-script fcgi
|
|
6
|
-
</IfModule>
|
|
7
|
-
<IfModule mod_fcgid.c>
|
|
8
|
-
AddHandler fcgid-script fcgi
|
|
9
|
-
</IfModule>
|
|
10
|
-
|
|
11
|
-
# Redirect all requests not available on the filesystem to Ramaze.
|
|
12
|
-
|
|
13
|
-
RewriteEngine On
|
|
14
|
-
RewriteCond %{REQUEST_FILENAME} !-f
|
|
15
|
-
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
|
|
16
|
-
|
|
17
|
-
# In case Ramaze experiences terminal errors.
|
|
18
|
-
# Instead of displaying this message you can supply a
|
|
19
|
-
# file here which will be rendered instead.
|
|
20
|
-
#
|
|
21
|
-
# Example:
|
|
22
|
-
# ErrorDocument 500 /500.html
|
|
23
|
-
|
|
24
|
-
ErrorDocument 500 "<h2>Application error</h2>Ramaze failed to start properly"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'ramaze'
|
|
5
|
-
|
|
6
|
-
# FCGI doesn't like you writing to stdout
|
|
7
|
-
Ramaze::Log.loggers = [ Ramaze::Logger::Informer.new( __DIR__("../ramaze.fcgi.log") ) ]
|
|
8
|
-
Ramaze.options.adapter.handler = :fastcgi
|
|
9
|
-
|
|
10
|
-
$0 = __DIR__("../start.rb")
|
|
11
|
-
require $0
|
data/lib/proto/spec/main.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'ramaze'
|
|
2
|
-
require 'ramaze/spec/bacon'
|
|
3
|
-
|
|
4
|
-
require __DIR__('../app')
|
|
5
|
-
|
|
6
|
-
describe MainController do
|
|
7
|
-
behaves_like :rack_test
|
|
8
|
-
|
|
9
|
-
should 'show start page' do
|
|
10
|
-
get('/').status.should == 200
|
|
11
|
-
last_response['Content-Type'].should == 'text/html'
|
|
12
|
-
last_response.should =~ /Congratulations, Ramaze is running fine/
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
should 'show /notemplate' do
|
|
16
|
-
get('/notemplate').status.should == 200
|
|
17
|
-
last_response['Content-Type'].should == 'text/html'
|
|
18
|
-
last_response.should =~ /There is no 'notemplate\.xhtml' associated with this action\./
|
|
19
|
-
end
|
|
20
|
-
end
|
data/lib/proto/start.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
# Use this file directly like `ruby start.rb` if you don't want to use the
|
|
4
|
-
# `ramaze start` command.
|
|
5
|
-
#
|
|
6
|
-
# All application related things should go into `app.rb`, this file is simply
|
|
7
|
-
# for options related to running the application locally.
|
|
8
|
-
#
|
|
9
|
-
# You can run this file as following:
|
|
10
|
-
#
|
|
11
|
-
# $ ruby start.rb
|
|
12
|
-
# $ ./start.rb
|
|
13
|
-
#
|
|
14
|
-
# If you want to be able to do the latter you'll have to make sure the file can be
|
|
15
|
-
# executed:
|
|
16
|
-
#
|
|
17
|
-
# $ chmod +x ./start.rb
|
|
18
|
-
require File.expand_path('../app', __FILE__)
|
|
19
|
-
|
|
20
|
-
Ramaze.start(:adapter => :webrick, :port => 7000, :file => __FILE__)
|
data/lib/ramaze/app_graph.rb
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
require 'set'
|
|
2
|
-
|
|
3
|
-
module Ramaze
|
|
4
|
-
##
|
|
5
|
-
# The AppGraph class can be used to generate a graph of all the URLs mapped in
|
|
6
|
-
# a Ramaze application and saves this graph as an image.
|
|
7
|
-
#
|
|
8
|
-
# In order to generate a graph of your application all you need to do is the
|
|
9
|
-
# following:
|
|
10
|
-
#
|
|
11
|
-
# require 'ramaze/app_graph'
|
|
12
|
-
#
|
|
13
|
-
# graph = Ramaze::AppGraph.new graph.generate graph.show
|
|
14
|
-
#
|
|
15
|
-
# Once this code is executed you can find the .dot and PNG files in the root
|
|
16
|
-
# directory of your application.
|
|
17
|
-
#
|
|
18
|
-
# @author Michael Fellinger
|
|
19
|
-
#
|
|
20
|
-
class AppGraph
|
|
21
|
-
##
|
|
22
|
-
# Creates a new instance of the class.
|
|
23
|
-
#
|
|
24
|
-
# @author Michael Fellinger
|
|
25
|
-
#
|
|
26
|
-
def initialize
|
|
27
|
-
@out = Set.new
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
##
|
|
31
|
-
# Generates the graph based on all the current routes. The graph is saved in
|
|
32
|
-
# the application directory.
|
|
33
|
-
#
|
|
34
|
-
# @author Michael Fellinger
|
|
35
|
-
#
|
|
36
|
-
def generate
|
|
37
|
-
Ramaze::AppMap.to_hash.each do |location, app|
|
|
38
|
-
connect(location => app.name)
|
|
39
|
-
|
|
40
|
-
app.url_map.to_hash.each do |c_location, c_node|
|
|
41
|
-
connect(app.name => c_node)
|
|
42
|
-
connect(c_node.mapping => c_node)
|
|
43
|
-
|
|
44
|
-
c_node.update_template_mappings
|
|
45
|
-
c_node.view_templates.each do |wish, mapping|
|
|
46
|
-
mapping.each do |action_name, template|
|
|
47
|
-
action_path = File.join(c_node.mapping, action_name)
|
|
48
|
-
connect(c_node => action_path, action_path => template)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
c_node.update_method_arities
|
|
53
|
-
c_node.method_arities.each do |method, arity|
|
|
54
|
-
action_path = File.join(c_node.mapping, method.to_s)
|
|
55
|
-
connect(
|
|
56
|
-
action_path => "#{c_node}##{method}[#{arity}]",
|
|
57
|
-
c_node => action_path
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
##
|
|
65
|
-
# Connects various elements in the graph to each other.
|
|
66
|
-
#
|
|
67
|
-
# @author Michael Fellinger
|
|
68
|
-
#
|
|
69
|
-
def connect(hash)
|
|
70
|
-
hash.each do |from, to|
|
|
71
|
-
@out << (" %p -> %p;" % [from.to_s, to.to_s])
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
##
|
|
76
|
-
# Writes the dot file containing the graph data.
|
|
77
|
-
#
|
|
78
|
-
# @author Michael Fellinger
|
|
79
|
-
#
|
|
80
|
-
def write_dot
|
|
81
|
-
File.open('graph.dot', 'w+') do |dot|
|
|
82
|
-
dot.puts 'digraph appmap {'
|
|
83
|
-
dot.puts(*@out)
|
|
84
|
-
dot.puts '}'
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
##
|
|
89
|
-
# Generates a PNG file based on the .dot file.
|
|
90
|
-
#
|
|
91
|
-
# @author Michael Fellinger
|
|
92
|
-
#
|
|
93
|
-
def show
|
|
94
|
-
write_dot
|
|
95
|
-
options = {
|
|
96
|
-
'rankdir' => 'LR',
|
|
97
|
-
'splines' => 'true',
|
|
98
|
-
'overlap' => 'false',
|
|
99
|
-
}
|
|
100
|
-
args = options.map{|k,v| "-G#{k}=#{v}" }
|
|
101
|
-
system("dot -O -Tpng #{args.join(' ')} graph.dot")
|
|
102
|
-
system('feh graph.dot.png')
|
|
103
|
-
end
|
|
104
|
-
end # AppGraph
|
|
105
|
-
end # Ramaze
|