ramaze 2011.07.25 → 2011.10.23
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.mailmap +3 -2
- data/.travis.yml +17 -0
- data/.yardopts +13 -0
- data/README.md +95 -352
- data/examples/app/blog/app.rb +25 -64
- data/examples/app/blog/config.ru +11 -9
- data/examples/app/blog/controller/init.rb +29 -86
- data/examples/app/blog/controller/posts.rb +232 -0
- data/examples/app/blog/controller/users.rb +160 -0
- data/examples/app/blog/layout/default.xhtml +61 -0
- data/examples/app/blog/migrations/01_create_schema.rb +50 -0
- data/examples/app/blog/model/comment.rb +41 -54
- data/examples/app/blog/model/init.rb +41 -13
- data/examples/app/blog/model/post.rb +35 -0
- data/examples/app/blog/model/user.rb +105 -0
- data/examples/app/blog/public/.htaccess +24 -0
- data/examples/app/blog/public/css/grid.css +107 -0
- data/examples/app/blog/public/css/layout.css +203 -0
- data/examples/app/blog/public/css/reset.css +123 -0
- data/examples/app/blog/public/css/text.css +109 -0
- data/examples/app/blog/public/dispatch.fcgi +11 -0
- data/examples/app/blog/public/favicon.ico +0 -0
- data/examples/app/blog/public/images/bg.png +0 -0
- data/examples/app/blog/start.rb +18 -3
- data/examples/app/blog/view/feed.xhtml +23 -0
- data/examples/app/blog/view/form.xhtml +11 -0
- data/examples/app/blog/view/index.xhtml +44 -0
- data/examples/app/blog/view/users/form.xhtml +12 -0
- data/examples/app/blog/view/users/index.xhtml +30 -0
- data/examples/app/blog/view/users/login.xhtml +8 -0
- data/examples/app/blog/view/view.xhtml +68 -0
- data/{doc → guide}/AUTHORS +5 -3
- data/{doc → guide}/CHANGELOG +428 -0
- data/{doc/GPL → guide/GPL_LICENSE} +0 -0
- data/{doc/COPYING → guide/RUBY_LICENSE} +3 -6
- data/guide/_static/logo.png +0 -0
- data/guide/_static/logo.svg +49 -0
- data/guide/_static/ramaze_console.png +0 -0
- data/guide/css/common.css +20 -0
- data/guide/general/cache.md +167 -0
- data/guide/general/configuration.md +168 -0
- data/guide/general/contributing.md +108 -0
- data/guide/general/controllers.md +115 -0
- data/guide/general/helpers.md +76 -0
- data/guide/general/installation.md +58 -0
- data/guide/general/logging.md +99 -0
- data/guide/general/middlewares.md +100 -0
- data/guide/general/models.md +78 -0
- data/guide/general/principles.md +53 -0
- data/guide/general/ramaze_command.md +155 -0
- data/guide/general/routes.md +81 -0
- data/guide/general/sessions.md +140 -0
- data/guide/general/special_thanks.md +67 -0
- data/guide/general/testing.md +61 -0
- data/guide/general/views.md +322 -0
- data/guide/tutorials/introduction.md +259 -0
- data/lib/proto/config.ru +1 -1
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/view/index.xhtml +7 -7
- data/lib/ramaze.rb +4 -4
- data/lib/ramaze/app.rb +11 -11
- data/lib/ramaze/app_graph.rb +2 -4
- data/lib/ramaze/bin/console.rb +3 -3
- data/lib/ramaze/bin/create.rb +2 -2
- data/lib/ramaze/bin/restart.rb +4 -4
- data/lib/ramaze/bin/runner.rb +5 -5
- data/lib/ramaze/bin/start.rb +19 -4
- data/lib/ramaze/bin/status.rb +3 -3
- data/lib/ramaze/bin/stop.rb +3 -3
- data/lib/ramaze/cache.rb +1 -0
- data/lib/ramaze/cache/lru.rb +8 -4
- data/lib/ramaze/cache/memcache.rb +32 -13
- data/lib/ramaze/cache/redis.rb +164 -0
- data/lib/ramaze/cache/sequel.rb +43 -28
- data/lib/ramaze/controller.rb +1 -2
- data/lib/ramaze/dependencies.rb +40 -3
- data/lib/ramaze/helper/bench.rb +26 -16
- data/lib/ramaze/helper/blue_form.rb +46 -73
- data/lib/ramaze/helper/cache.rb +10 -6
- data/lib/ramaze/helper/csrf.rb +35 -39
- data/lib/ramaze/helper/disqus.rb +5 -4
- data/lib/ramaze/helper/email.rb +35 -24
- data/lib/ramaze/helper/erector.rb +9 -13
- data/lib/ramaze/helper/flash.rb +7 -9
- data/lib/ramaze/helper/formatting.rb +194 -179
- data/lib/ramaze/helper/gravatar.rb +4 -8
- data/lib/ramaze/helper/identity.rb +3 -3
- data/lib/ramaze/helper/layout.rb +23 -8
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/paginate.rb +46 -39
- data/lib/ramaze/helper/request_accessor.rb +3 -1
- data/lib/ramaze/helper/simple_captcha.rb +18 -17
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/helper/tagz.rb +4 -2
- data/lib/ramaze/helper/upload.rb +523 -0
- data/lib/ramaze/helper/user.rb +4 -8
- data/lib/ramaze/helper/xhtml.rb +11 -15
- data/lib/ramaze/log.rb +9 -6
- data/lib/ramaze/log/rotatinginformer.rb +62 -27
- data/lib/ramaze/log/syslog.rb +20 -15
- data/lib/ramaze/log/xosd.rb +2 -1
- data/lib/ramaze/reloader.rb +2 -0
- data/lib/ramaze/request.rb +11 -10
- data/lib/ramaze/setup.rb +23 -6
- data/lib/ramaze/snippets/array/put_within.rb +3 -9
- data/lib/ramaze/snippets/binding/locals.rb +5 -10
- data/lib/ramaze/snippets/fiber.rb +1 -23
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +3 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +3 -5
- data/lib/ramaze/snippets/numeric/time.rb +3 -7
- data/lib/ramaze/snippets/object/__dir__.rb +3 -7
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +3 -6
- data/lib/ramaze/snippets/object/pretty.rb +3 -7
- data/lib/ramaze/snippets/object/scope.rb +7 -9
- data/lib/ramaze/snippets/proc/locals.rb +12 -12
- data/lib/ramaze/snippets/ramaze/acquire.rb +15 -14
- data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -1
- data/lib/ramaze/snippets/ramaze/fiber.rb +1 -1
- data/lib/ramaze/snippets/ramaze/lru_hash.rb +2 -3
- data/lib/ramaze/snippets/ramaze/struct.rb +2 -4
- data/lib/ramaze/snippets/string/camel_case.rb +8 -10
- data/lib/ramaze/snippets/string/color.rb +3 -4
- data/lib/ramaze/snippets/string/end_with.rb +3 -6
- data/lib/ramaze/snippets/string/esc.rb +3 -8
- data/lib/ramaze/snippets/string/ord.rb +3 -8
- data/lib/ramaze/snippets/string/snake_case.rb +6 -9
- data/lib/ramaze/snippets/string/start_with.rb +3 -8
- data/lib/ramaze/snippets/string/unindent.rb +3 -6
- data/lib/ramaze/snippets/thread/into.rb +1 -3
- data/lib/ramaze/spec.rb +2 -31
- data/lib/ramaze/spec/bacon.rb +18 -2
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +1 -1
- data/ramaze.gemspec +1 -1
- data/spec/helper.rb +2 -1
- data/spec/ramaze/bin/start.rb +16 -20
- data/spec/ramaze/cache/localmemcache.rb +4 -7
- data/spec/ramaze/cache/memcache.rb +3 -1
- data/spec/ramaze/cache/redis.rb +62 -0
- data/spec/ramaze/helper/blue_form.rb +33 -4
- data/spec/ramaze/helper/layout.rb +40 -7
- data/spec/ramaze/helper/upload.rb +149 -0
- data/spec/ramaze/helper/uploads/text_1.txt +1 -0
- data/spec/ramaze/helper/uploads/text_2.txt +1 -0
- data/spec/ramaze/log/growl.rb +4 -6
- data/spec/ramaze/log/syslog.rb +6 -0
- data/spec/ramaze/view/lokar.rb +5 -0
- data/spec/ramaze/view/nagoro.rb +5 -0
- data/tasks/authors.rake +1 -1
- data/tasks/bacon.rake +14 -5
- data/tasks/changelog.rake +1 -1
- data/tasks/yard.rake +12 -4
- metadata +277 -239
- data/doc/LEGAL +0 -26
- data/examples/app/blog/README +0 -3
- data/examples/app/blog/controller/comment.rb +0 -45
- data/examples/app/blog/controller/entry.rb +0 -85
- data/examples/app/blog/controller/main.rb +0 -20
- data/examples/app/blog/controller/tag.rb +0 -9
- data/examples/app/blog/layout/default.nag +0 -31
- data/examples/app/blog/model/entry.rb +0 -89
- data/examples/app/blog/model/tag.rb +0 -36
- data/examples/app/blog/public/css/screen.css +0 -273
- data/examples/app/blog/spec/blog.rb +0 -87
- data/examples/app/blog/view/comment/form.nag +0 -10
- data/examples/app/blog/view/comment/show.nag +0 -16
- data/examples/app/blog/view/entry/edit.nag +0 -14
- data/examples/app/blog/view/entry/feed.atom.nag +0 -8
- data/examples/app/blog/view/entry/feed.rss.nag +0 -7
- data/examples/app/blog/view/entry/index.nag +0 -7
- data/examples/app/blog/view/entry/new.nag +0 -13
- data/examples/app/blog/view/entry/show.nag +0 -36
- data/examples/app/blog/view/feed.atom.nag +0 -18
- data/examples/app/blog/view/feed.rss.nag +0 -25
- data/examples/app/blog/view/index.nag +0 -6
- data/examples/app/blog/view/tag/index.nag +0 -5
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/ramaze/rest.rb +0 -36
- data/spec/ramaze/rest.rb +0 -28
- data/tasks/rcov.rake +0 -22
@@ -0,0 +1,259 @@
|
|
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 two lines of code:
|
65
|
+
|
66
|
+
require 'rubygems' # Only required on Ruby < 1.9
|
67
|
+
require 'ramaze' # Always required
|
68
|
+
|
69
|
+
This will load the Ramaze gem, without it you won't be able to create a Ramaze
|
70
|
+
application. Besides this you'll obviously need to load a few more files in
|
71
|
+
order to get a working application. Let's create our first controller and load
|
72
|
+
it in this file, because we've already opened app.rb we'll just add the require
|
73
|
+
statement for it right away:
|
74
|
+
|
75
|
+
require __DIR__('controller/tutorial')
|
76
|
+
|
77
|
+
This line of code will tell Ruby to load the file "tutorial.rb" from
|
78
|
+
$DIR/controller/ where $DIR is the project directory. __DIR__ is a special
|
79
|
+
method provided by Ramaze that basically does the same as the following:
|
80
|
+
|
81
|
+
File.expand_path("../#{some_path}", __FILE__)
|
82
|
+
|
83
|
+
Whenever you want to load something relative to a file it's best to use
|
84
|
+
__DIR__ (or require_relative if you're on 1.9).
|
85
|
+
|
86
|
+
Right, time to create the controller we just loaded (don't actually start the
|
87
|
+
application, it will trigger an error!)::
|
88
|
+
|
89
|
+
$ mkdir controller/
|
90
|
+
$ touch controller/tutorial.rb
|
91
|
+
|
92
|
+
Now open the tutorial.rb file in your favorite editor. Obviously this file is
|
93
|
+
still empty so we'll need to add some code to the file. We'll be creating a
|
94
|
+
class called "Tutorial" that will be mapped to "/" (the root of your
|
95
|
+
application). This can be done as following:
|
96
|
+
|
97
|
+
class Tutorial < Ramaze::Controller
|
98
|
+
map '/'
|
99
|
+
end
|
100
|
+
|
101
|
+
It's important that you always extend Ramaze::Controller, whether it's extended
|
102
|
+
directly or via another class. Without this Ramaze won't recognize the class as
|
103
|
+
a controller nor will you be able to use controller specific methods.
|
104
|
+
|
105
|
+
## Running Applications
|
106
|
+
|
107
|
+
Currently we have the following files:
|
108
|
+
|
109
|
+
* config.ru
|
110
|
+
* app.rb
|
111
|
+
* controller/tutorial.rb
|
112
|
+
|
113
|
+
Let's see if our application is working, start it with the following command::
|
114
|
+
|
115
|
+
$ ramaze start
|
116
|
+
|
117
|
+
If everything went well the output of this command should look like the
|
118
|
+
following::
|
119
|
+
|
120
|
+
[2011-05-24 17:37:31] INFO WEBrick 1.3.1
|
121
|
+
[2011-05-24 17:37:31] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.0]
|
122
|
+
[2011-05-24 17:37:31] INFO WEBrick::HTTPServer#start: pid=74568 port=7000
|
123
|
+
|
124
|
+
If you now were to navigate your browser to http://localhost:7000/ you'd get the
|
125
|
+
following response:
|
126
|
+
|
127
|
+
No action found at: "/"
|
128
|
+
|
129
|
+
This message is displayed because while there is a controller (Tutorial) it
|
130
|
+
doesn't have any methods available for the requested URI. Let's go ahead and add
|
131
|
+
a method to our controller, shut down WEBRick (Ctrl + C) and open the file
|
132
|
+
controller/tutorial.rb. Modify it so that it's code looks like the following:
|
133
|
+
|
134
|
+
class Tutorial < Ramaze::Controller
|
135
|
+
map '/'
|
136
|
+
|
137
|
+
def index
|
138
|
+
"Hello, world!"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
Save the file and restart WEBRick using ``ramaze start``. If you now refresh
|
143
|
+
the page you'd see the message "Hello, world!" opposed to the "No action found.."
|
144
|
+
message. This is because we now have a method for the URI "/". Ramaze maps the
|
145
|
+
public methods of a controller to the URI of the controller. This means that if
|
146
|
+
you added another method to this controller named "cookie" you'd be able to
|
147
|
+
access it from /cookie. The method used for a URI of / is "index" by default but
|
148
|
+
this can be changed as following:
|
149
|
+
|
150
|
+
class Tutorial < Ramaze::Controller
|
151
|
+
map '/'
|
152
|
+
|
153
|
+
trait :default_action_name => 'default'
|
154
|
+
|
155
|
+
def default
|
156
|
+
"Hello, world!"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
The trait() method is a method provided by Ramaze that can be used to set
|
161
|
+
configuration options in a class, don't worry about it for now.
|
162
|
+
|
163
|
+
Obviously a plain text message is boring, let's get started with "views". Views
|
164
|
+
are files that will contain the presentation layer (usually HTML) of your
|
165
|
+
application. In order to create a view we'll have to create a view directory
|
166
|
+
first::
|
167
|
+
|
168
|
+
$ mkdir view/
|
169
|
+
|
170
|
+
In order to render a view you'll have to create a view that matches a method's
|
171
|
+
name and is placed in the correct directory. In this case our method is called
|
172
|
+
"index" and the controller is mapped to /. This means that our view would be
|
173
|
+
located in view/index.xhtml. If our method was named "default" the view would
|
174
|
+
be in view/default.xhtml. If the controller was mapped to /cookie the view would
|
175
|
+
be located in view/cookie.index.xhtml and so on. Let's create and edit the file::
|
176
|
+
|
177
|
+
$ touch view/index.xhtml
|
178
|
+
$ $EDITOR view/index.xhtml
|
179
|
+
|
180
|
+
Just like all the other files this one is empty. A view can contain HTML and
|
181
|
+
Ruby code based on the template engine you're using. By default Ramaze uses
|
182
|
+
Etanni which allows you to wrap your Ruby code in #{} for outputting variables
|
183
|
+
and <?r ?> for statements:
|
184
|
+
|
185
|
+
<?r if !@username.nil? ?>
|
186
|
+
#{@username}
|
187
|
+
<?r end ?>
|
188
|
+
|
189
|
+
Let's add the following data to the view:
|
190
|
+
|
191
|
+
<p>Hello, #{@username}!</p>
|
192
|
+
|
193
|
+
Once this is done modify your Tutorial controller so that it looks like the
|
194
|
+
following:
|
195
|
+
|
196
|
+
class Tutorial < Ramaze::Controller
|
197
|
+
map '/'
|
198
|
+
|
199
|
+
def index
|
200
|
+
@username = "Ramaze"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
From this point on all requests made to / will not result in a response of
|
205
|
+
"Hello, world!" but instead will display "Hello, Ramaze!". The cool thing is
|
206
|
+
that you don't have to manually load the view (but you still can if you like).
|
207
|
+
If the method of a controller has no return value Ramaze will try to load the
|
208
|
+
corresponding view.
|
209
|
+
|
210
|
+
## Debugging Applications
|
211
|
+
|
212
|
+
Quite often you'll want to quickly look something up, say the list of available
|
213
|
+
methods of a class, in your application. A common approach is to restart your
|
214
|
+
application every time
|
215
|
+
you've made your changes but this can become really annoying. To solve this issue
|
216
|
+
Ramaze comes with the command ``ramaze console``. This command basically loads
|
217
|
+
IRB along with your application, allowing you to play with it without having to
|
218
|
+
restart your server every time.
|
219
|
+
|
220
|
+
In order for us to be able to use the console we'll have to add a new file to
|
221
|
+
our project, called "start.rb". start.rb works the same as config.ru but
|
222
|
+
instead of being used for Rackup it's used to tell Ramaze how to run it in IRB.
|
223
|
+
Create the file and open it in your editor ($EDITOR is the command used for
|
224
|
+
opening a file in your editor)::
|
225
|
+
|
226
|
+
$ touch start.rb
|
227
|
+
$ $EDITOR start.rb
|
228
|
+
|
229
|
+
Add the following code to it:
|
230
|
+
|
231
|
+
require File.expand_path('../app', __FILE__)
|
232
|
+
|
233
|
+
Ramaze.start(:adapter => :webrick, :port => 7000, :file => __FILE__)
|
234
|
+
|
235
|
+
Anything that looks familiar? This code is almost identical except that instead
|
236
|
+
of calling "run Ramaze" it invokes the Ramaze.start command without telling it
|
237
|
+
it will be started by something else (this is done using the :started option).
|
238
|
+
Don't bother too much about this file as it's pretty boring, save it and leave
|
239
|
+
it alone.
|
240
|
+
|
241
|
+
Now that we've added the required file we can invoke the console. This is done
|
242
|
+
as following::
|
243
|
+
|
244
|
+
$ ramaze console
|
245
|
+
ruby-1.9.2-p180 :001 >
|
246
|
+
|
247
|
+
You can use the console for everything you'd normally use IRB for but it comes
|
248
|
+
with the added value of being able to do Ramaze specific things::
|
249
|
+
|
250
|
+
ruby-1.9.2-p180 :001 > Ramaze.options.app.name
|
251
|
+
=> :pristine
|
252
|
+
|
253
|
+
If you're done playing you can close the console with Ctrl + D.
|
254
|
+
|
255
|
+
And that's really about it. While we've only scratched the surface of Ramaze
|
256
|
+
we've already managed to write some Ramaze specific code as well as learning
|
257
|
+
how to use the console and how to start applications. The source code created in
|
258
|
+
this tutorial can be found here:
|
259
|
+
https://github.com/Ramaze/ramaze-user-guide-code/tree/master/introduction
|
data/lib/proto/config.ru
CHANGED
Binary file
|
data/lib/proto/view/index.xhtml
CHANGED
@@ -19,27 +19,27 @@
|
|
19
19
|
</ul>
|
20
20
|
|
21
21
|
<p>
|
22
|
-
For more information, check out <a href="http://ramaze.net">ramaze.net</a> and
|
22
|
+
For more information, check out <a href="http://ramaze.net">ramaze.net</a> and
|
23
23
|
<a href="http://ramaze.net/documentation/index.html">the documentation</a>.
|
24
24
|
<br />
|
25
|
-
You can also read the
|
25
|
+
You can also read the
|
26
26
|
<a href="http://doc.rubyists.com/ramaze%2binnate/">YARD documentation</a>
|
27
27
|
or browse around the <a href="https://github.com/ramaze/ramaze">Ramaze source code</a>.
|
28
28
|
</p>
|
29
29
|
|
30
30
|
<p>
|
31
|
-
For help with Ramaze, visit
|
31
|
+
For help with Ramaze, visit
|
32
32
|
<a href="irc://chat.freenode.net/ramaze">#ramaze on irc.freenode.net</a>.
|
33
33
|
<br />
|
34
|
-
You can use <a href="http://embed.mibbit.com/?server=irc.freenode.net&channel
|
35
|
-
an AJAX based IRC client or
|
34
|
+
You can use <a href="http://embed.mibbit.com/?server=irc.freenode.net&channel=%23ramaze,%23ruby-lang&forcePrompt=true">Mibbit</a>,
|
35
|
+
an AJAX based IRC client or
|
36
36
|
<a href="http://java.freenode.net/?channel=ramaze">
|
37
37
|
the official freenode irc java applet
|
38
38
|
</a>.
|
39
39
|
</p>
|
40
40
|
|
41
41
|
<p>
|
42
|
-
Feel free to post to the
|
43
|
-
<a href="https://groups.google.com/forum/#!forum/ramaze">Ramaze Google Group</a>, your
|
42
|
+
Feel free to post to the
|
43
|
+
<a href="https://groups.google.com/forum/#!forum/ramaze">Ramaze Google Group</a>, your
|
44
44
|
first mail has to go through moderation, so please be patient.
|
45
45
|
</p>
|
data/lib/ramaze.rb
CHANGED
@@ -12,16 +12,16 @@
|
|
12
12
|
module Ramaze
|
13
13
|
ROOT = File.expand_path(File.dirname(__FILE__)) unless defined?(Ramaze::ROOT)
|
14
14
|
|
15
|
-
unless $LOAD_PATH.any?{|lp| File.expand_path(lp) == ROOT }
|
16
|
-
$LOAD_PATH.unshift(ROOT)
|
17
|
-
end
|
18
|
-
|
19
15
|
# 3rd party
|
20
16
|
require 'innate'
|
21
17
|
|
22
18
|
@options = Innate.options
|
23
19
|
class << self; attr_accessor :options; end
|
24
20
|
|
21
|
+
unless $LOAD_PATH.any?{|lp| File.expand_path(lp) == ROOT }
|
22
|
+
$LOAD_PATH.unshift(ROOT)
|
23
|
+
end
|
24
|
+
|
25
25
|
# vendored, will go into rack-contrib
|
26
26
|
require 'vendor/route_exceptions'
|
27
27
|
|
data/lib/ramaze/app.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module Ramaze
|
2
|
-
# An application is a collection of controllers and options that have a
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# to Rack::URLMap.
|
2
|
+
# An application is a collection of controllers and options that have a common
|
3
|
+
# name. Every application has a location it dispatches from, this behaves
|
4
|
+
# similar to Rack::URLMap.
|
6
5
|
AppMap = Innate::URLMap.new
|
7
6
|
|
8
7
|
#:nodoc:
|
@@ -11,18 +10,19 @@ module Ramaze
|
|
11
10
|
App[app_name].to(object)
|
12
11
|
end
|
13
12
|
|
13
|
+
##
|
14
14
|
# App is the superclass for applications and acts as their prototype when it
|
15
15
|
# comes to configuration.
|
16
16
|
#
|
17
17
|
# An application consists of options, a location, and a list of objects. The
|
18
|
-
# objects are usually {Controller}s.
|
18
|
+
# objects are usually {Ramaze::Controller}s.
|
19
19
|
#
|
20
20
|
# The options are inherited, the basics are set in Ramaze.options, from there
|
21
21
|
# to Ramaze::App.options, and finally into every instance of App.
|
22
22
|
#
|
23
|
-
# This allows to collect {Controller}s of your application into a
|
24
|
-
# group that can easily be used in other applications, while retaining
|
25
|
-
# original options.
|
23
|
+
# This allows to collect {Ramaze::Controller}s of your application into a
|
24
|
+
# common group that can easily be used in other applications, while retaining
|
25
|
+
# the original options.
|
26
26
|
#
|
27
27
|
# Every instance of {App} is mapped in {AppMap}, which is the default
|
28
28
|
# location to #call from Rack.
|
@@ -35,11 +35,10 @@ module Ramaze
|
|
35
35
|
# also has a subset of middleware that handles serving static files, routes
|
36
36
|
# and rewrites.
|
37
37
|
#
|
38
|
-
# To indicate that a {Controller} belongs to a specific application,
|
39
|
-
# pass a second argument to {Controller::map}
|
38
|
+
# To indicate that a {Ramaze::Controller} belongs to a specific application,
|
39
|
+
# you can pass a second argument to {Ramaze::Controller::map}
|
40
40
|
#
|
41
41
|
# @example adding Controller to application
|
42
|
-
#
|
43
42
|
# class WikiController < Ramaze::Controller
|
44
43
|
# map '/', :wiki
|
45
44
|
# end
|
@@ -57,6 +56,7 @@ module Ramaze
|
|
57
56
|
#
|
58
57
|
# The naming of an App has no influence on any other aspects of dispatching
|
59
58
|
# or configuration.
|
59
|
+
#
|
60
60
|
class App
|
61
61
|
include Innate::Optioned
|
62
62
|
|
data/lib/ramaze/app_graph.rb
CHANGED
@@ -5,14 +5,12 @@ module Ramaze
|
|
5
5
|
# The AppGraph class can be used to generate a graph of all the URLs mapped in
|
6
6
|
# a Ramaze application and saves this graph as an image.
|
7
7
|
#
|
8
|
-
# == Usage
|
9
|
-
#
|
10
8
|
# In order to generate a graph of your application all you need to do is the
|
11
9
|
# following:
|
12
10
|
#
|
13
|
-
#
|
11
|
+
# require 'ramaze/app_graph'
|
14
12
|
#
|
15
|
-
#
|
13
|
+
# graph = Ramaze::AppGraph.new graph.generate graph.show
|
16
14
|
#
|
17
15
|
# Once this code is executed you can find the .dot and PNG files in the root
|
18
16
|
# directory of your application.
|
data/lib/ramaze/bin/console.rb
CHANGED
@@ -8,10 +8,10 @@ module Ramaze
|
|
8
8
|
# Allows the user to enter an IRB like session that takes advantage of
|
9
9
|
# everything provided by Ramaze.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# Usage:
|
12
12
|
#
|
13
|
-
#
|
14
|
-
#
|
13
|
+
# ramaze console
|
14
|
+
# ramaze console /path/to/app/start.rb
|
15
15
|
#
|
16
16
|
# @author Yorick Peterse
|
17
17
|
# @since 21-07-2011
|
data/lib/ramaze/bin/create.rb
CHANGED
@@ -7,9 +7,9 @@ module Ramaze
|
|
7
7
|
# Simple command that allows users to easily create a new application based
|
8
8
|
# on the prototype that ships with Ramaze.
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# Usage:
|
11
11
|
#
|
12
|
-
#
|
12
|
+
# ramaze create blog
|
13
13
|
#
|
14
14
|
# @author Yorick Peterse
|
15
15
|
# @since 21-07-2011
|
data/lib/ramaze/bin/restart.rb
CHANGED
@@ -6,11 +6,11 @@ module Ramaze
|
|
6
6
|
# PID. The PID is used to kill the process, the Rackup file is used to start
|
7
7
|
# the process again after it has been killed.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# Usage:
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
11
|
+
# ramaze restart
|
12
|
+
# ramaze restart /home/foobar/projects/ramaze/ \
|
13
|
+
# -P /home/foobar/projects/ramaze/ramaze.pid
|
14
14
|
#
|
15
15
|
# @author Yorick Peterse
|
16
16
|
# @since 21-07-2011
|
data/lib/ramaze/bin/runner.rb
CHANGED
@@ -16,13 +16,13 @@ module Ramaze
|
|
16
16
|
# Module used for running a particular command based on the specified
|
17
17
|
# command line arguments.
|
18
18
|
#
|
19
|
-
#
|
19
|
+
# Usage:
|
20
20
|
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
21
|
+
# ramaze --help # Shows a help message
|
22
|
+
# ramaze -h # Shows a help message as well
|
23
|
+
# ramaze -v # Shows the version of Ramaze
|
24
24
|
#
|
25
|
-
#
|
25
|
+
# ramaze [COMMAND] # Runs [COMMAND]
|
26
26
|
#
|
27
27
|
# @author Yorick Peterse
|
28
28
|
# @since 21-07-2011
|