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
data/guide/general/cache.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Configuration
|
|
1
2
|
# Configuration
|
|
2
3
|
|
|
3
4
|
Ramaze provides two ways of setting configuration options, using
|
|
@@ -132,7 +133,7 @@ value, etc:
|
|
|
132
133
|
|
|
133
134
|
While Ramaze is a very flexible framework it requires some basic information
|
|
134
135
|
about the location of your views, layouts and so on. Ramaze does not
|
|
135
|
-
automatically
|
|
136
|
+
automatically try to locate these but instead uses a set of defined locations
|
|
136
137
|
to look for. These paths are set using ``Ramaze::Optioned`` and can be found in
|
|
137
138
|
the following options:
|
|
138
139
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Controllers
|
|
1
2
|
# Controllers
|
|
2
3
|
|
|
3
4
|
When developing web applications controllers are the elements that are called
|
|
@@ -12,7 +13,7 @@ instead it will merely tell the cooks to make the dinner and bring it to you onc
|
|
|
12
13
|
it's done. The waiter is our controller, the cook is our model and our meal can
|
|
13
14
|
be seen as the view.
|
|
14
15
|
|
|
15
|
-
In a typical application the entire flow of a request is as following
|
|
16
|
+
In a typical application the entire flow of a request is as following:
|
|
16
17
|
|
|
17
18
|
Request --> Server (Thin, Unicorn, etc) --> Rack --> Ramaze --> Controller
|
|
18
19
|
|
|
@@ -30,10 +31,10 @@ most basic controller looks like the following:
|
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
Let's walk through this snippet step by step. The first line declares a new
|
|
33
|
-
class that extends Ramaze::Controller. Extending this base class is very
|
|
34
|
+
class that extends {Ramaze::Controller}. Extending this base class is very
|
|
34
35
|
important, without it we won't be able to call controller specific methods such
|
|
35
|
-
as the map() method. This method, which is called on line 2, is used to instruct
|
|
36
|
-
Ramaze what controller is bound to what URI(Uniform Resource Identifier). The
|
|
36
|
+
as the `map()` method. This method, which is called on line 2, is used to instruct
|
|
37
|
+
Ramaze what controller is bound to what URI (Uniform Resource Identifier). The
|
|
37
38
|
argument of this method should be a string starting with a /. The reason for
|
|
38
39
|
this is that the URIs are relative to URL the application is running on. For
|
|
39
40
|
example, if our application was running at ramaze.net a URI of "/blog" would
|
|
@@ -42,12 +43,12 @@ mean the controller can be found at ramaze.net/blog.
|
|
|
42
43
|
Let's move to the next lines of code. The next lines of code define a new method
|
|
43
44
|
called "index". By default Ramaze will try to call this method if no URI after
|
|
44
45
|
the mapped URI is given. In our /blog example a call to ramaze.net/blog would
|
|
45
|
-
call BlogController#index but a call to ramaze.net/blog/entry/10 would call
|
|
46
|
-
BlogController#entry(10)
|
|
46
|
+
call `BlogController#index` but a call to `ramaze.net/blog/entry/10` would call
|
|
47
|
+
`BlogController#entry(10)`.
|
|
47
48
|
|
|
48
49
|
All methods that are declared as public can be accessed by a user and by default
|
|
49
|
-
the index() method is called if no other method is specified. Don't like the
|
|
50
|
-
index() method? No problem, you can specify a different default method to call
|
|
50
|
+
the `index()` method is called if no other method is specified. Don't like the
|
|
51
|
+
`index()` method? No problem, you can specify a different default method to call
|
|
51
52
|
as following:
|
|
52
53
|
|
|
53
54
|
class ControllerName < Ramaze::Controller
|
|
@@ -60,10 +61,104 @@ as following:
|
|
|
60
61
|
|
|
61
62
|
We're not going to cover Traits too much in this chapter as there's a dedicated
|
|
62
63
|
chapter for them but in short they're a way of setting configuration options. In
|
|
63
|
-
this case we're using the trait
|
|
64
|
+
this case we're using the trait `default_action_name` to specify what the name
|
|
64
65
|
of the default method should be. By default this is set to "index" but in the
|
|
65
66
|
above example it was changed to "default".
|
|
66
67
|
|
|
68
|
+
### Method Arguments
|
|
69
|
+
|
|
70
|
+
As mentioned above methods are bound to URLs given they're declared as public
|
|
71
|
+
methods. The same applies to the arguments of such methods, if the method is
|
|
72
|
+
public these arguments can be set from the URL. This means that you don't have
|
|
73
|
+
to use a special DSL just to bind methods to certain URLs while taking various
|
|
74
|
+
parameters into account. An example is the following:
|
|
75
|
+
|
|
76
|
+
class Pages < Ramaze::Controller
|
|
77
|
+
map '/pages'
|
|
78
|
+
|
|
79
|
+
def index
|
|
80
|
+
# Overview of all pages
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def edit(id)
|
|
84
|
+
# Edit the page for the given ID
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
This controller would allow users to navigate to `/pages/edit/10` which would
|
|
89
|
+
invoke `Pages#edit("10")`. There's no restriction on the values of parameters
|
|
90
|
+
(as long as they don't include slashes), they are however always passed as
|
|
91
|
+
strings to the method.
|
|
92
|
+
|
|
93
|
+
One thing to keep in mind is that if a method takes a set of required parameters
|
|
94
|
+
that are *not* specified Ramaze will *not* call the method, it will instead show
|
|
95
|
+
a message that the request could not be executed due to a missing
|
|
96
|
+
method/controller (unless your application has a custom handler for this).
|
|
97
|
+
|
|
98
|
+
Using the code above navigating to `/pages/edit/10` would work but navigating to
|
|
99
|
+
`/pages/edit` would not since the "id" parameter is specified as a required
|
|
100
|
+
parameter but wasn't given in the URL. Don't worry, working around this is as
|
|
101
|
+
easy as specifying a default value for your parameters:
|
|
102
|
+
|
|
103
|
+
class Pages < Ramaze::Controller
|
|
104
|
+
map '/pages'
|
|
105
|
+
|
|
106
|
+
def index
|
|
107
|
+
# Overview of all pages
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def edit(id = nil)
|
|
111
|
+
# Edit the page for the given ID
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
With this modification the `edit` method will be called for URLs such as
|
|
116
|
+
`/pages/edit`, `/pages/edit/10` and so on.
|
|
117
|
+
|
|
118
|
+
### Catch-all Methods
|
|
119
|
+
|
|
120
|
+
Sometimes you want to create a controller in which a single method handles all
|
|
121
|
+
the requests. This can be done by creating an `index` method that takes a
|
|
122
|
+
variable amount of parameters:
|
|
123
|
+
|
|
124
|
+
class Pages < Ramaze::Controller
|
|
125
|
+
map '/pages'
|
|
126
|
+
|
|
127
|
+
def index(*args)
|
|
128
|
+
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
In this example `Pages#index` would be called for URLs such as `/pages`,
|
|
133
|
+
`/pages/example`, `/pages/edit/10` and so on. The exception to this is URLs that
|
|
134
|
+
point to existing methods. An example:
|
|
135
|
+
|
|
136
|
+
class Pages < Ramaze::Controller
|
|
137
|
+
map '/pages'
|
|
138
|
+
|
|
139
|
+
def index(*args)
|
|
140
|
+
return 'index'
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def example
|
|
144
|
+
return 'example'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
If a user were to browse to `/pages/hello` the index method would be called and
|
|
149
|
+
"index" would be displayed, when the user instead goes to `/pages/example` the
|
|
150
|
+
text "example" would be displayed as there's an existing method for this URI.
|
|
151
|
+
However, if the user would request `/pages/example/10` the index method would
|
|
152
|
+
again be called, this is because the example method does not take any
|
|
153
|
+
parameters. Below is a list of various URLs and what method calls they'd result
|
|
154
|
+
in.
|
|
155
|
+
|
|
156
|
+
/pages # => Pages#index
|
|
157
|
+
/pages/index # => Pages#index
|
|
158
|
+
/pages/edit/10 # => Pages#index("edit", "10")
|
|
159
|
+
/pages/example # => Pages#example
|
|
160
|
+
/pages/example/10 # => Pages#index("example", "10")
|
|
161
|
+
|
|
67
162
|
## Registering Controllers
|
|
68
163
|
|
|
69
164
|
By now you might be thinking "How does Ramaze know what controller to call? I
|
|
@@ -77,7 +172,7 @@ for a given URI.
|
|
|
77
172
|
|
|
78
173
|
The basic process of the map() method is as following:
|
|
79
174
|
|
|
80
|
-
1. Call map()
|
|
175
|
+
1. Call `map()`.
|
|
81
176
|
2. Validate the given URI.
|
|
82
177
|
3. Store the controller constant.
|
|
83
178
|
4. Done.
|
data/guide/general/helpers.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Helpers
|
|
1
2
|
# Helpers
|
|
2
3
|
|
|
3
4
|
Helpers are simple modules that can be used in controllers to prevent developers
|
|
@@ -50,7 +51,6 @@ load all helpers the Ramaze way.
|
|
|
50
51
|
* {Ramaze::Helper::Cache}: caching of entire actions and custom values in your
|
|
51
52
|
controllers.
|
|
52
53
|
* {Ramaze::Helper::CSRF}: protect your controllers from CSRF attacks.
|
|
53
|
-
* {Ramaze::Helper::Disqus}
|
|
54
54
|
* {Ramaze::Helper::Email}: quick and easy way to send Emails.
|
|
55
55
|
* {Ramaze::Helper::Erector}
|
|
56
56
|
* {Ramaze::Helper::Flash}
|
|
@@ -70,21 +70,20 @@ load all helpers the Ramaze way.
|
|
|
70
70
|
* {Ramaze::Helper::Stack}
|
|
71
71
|
* {Ramaze::Helper::Tagz}
|
|
72
72
|
* {Ramaze::Helper::Thread}
|
|
73
|
-
* {Ramaze::Helper::Ultraviolet}
|
|
74
73
|
* {Ramaze::Helper::Upload}: uploading files made easy.
|
|
75
74
|
* {Ramaze::Helper::UserHelper}: authenticate users using a model.
|
|
76
75
|
* {Ramaze::Helper::XHTML}
|
|
77
76
|
|
|
78
77
|
## Innate Helpers
|
|
79
78
|
|
|
80
|
-
Note that you may also find some popular helpers, that are used by default in
|
|
79
|
+
Note that you may also find some popular helpers, that are used by default in
|
|
81
80
|
Ramaze, under the Innate project.
|
|
82
81
|
|
|
83
82
|
* {Innate::Helper::Aspect}: provides before/after wrappers for actions.
|
|
84
83
|
* {Innate::Helper::CGI}: gives shortcuts to some CGI methods.
|
|
85
|
-
* {Innate::Helper::Flash}: gives simple access to session.flash.
|
|
84
|
+
* {Innate::Helper::Flash}: gives simple access to session.flash.
|
|
86
85
|
* {Innate::Helper::Link}: provides the path to a given Node and action.
|
|
87
|
-
* {Innate::Helper::Redirect}: provides the request redirect, raw_redirect
|
|
88
|
-
and respond convenience methods.
|
|
89
|
-
* {Innate::Helper::Render}: provides variants for partial, custom, full
|
|
86
|
+
* {Innate::Helper::Redirect}: provides the request redirect, raw_redirect
|
|
87
|
+
and respond convenience methods.
|
|
88
|
+
* {Innate::Helper::Render}: provides variants for partial, custom, full
|
|
90
89
|
view rendering.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Installation
|
|
1
2
|
# Installation
|
|
2
3
|
|
|
3
4
|
Ramaze can be installed by using [Rubygems][rubygems], direct download or by
|
|
@@ -23,7 +24,7 @@ install all required gems and optionally set up an RVM environment in case
|
|
|
23
24
|
you're using RVM:
|
|
24
25
|
|
|
25
26
|
$ cd ramaze
|
|
26
|
-
$
|
|
27
|
+
$ bundle install
|
|
27
28
|
|
|
28
29
|
Once installed you can build a gem manually or just require the local
|
|
29
30
|
installation manually:
|
data/guide/general/logging.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Logging
|
|
1
2
|
# Logging
|
|
2
3
|
|
|
3
4
|
Similar to the caching system Ramaze makes it easy to log information using a
|
|
@@ -86,14 +87,10 @@ whatever you want.
|
|
|
86
87
|
|
|
87
88
|
## Available Loggers
|
|
88
89
|
|
|
89
|
-
* {Ramaze::Logger::Analogger}
|
|
90
|
-
* {Ramaze::Logger::Growl}: uses Growl for log messages (requires Mac OS).
|
|
91
90
|
* {Ramaze::Logger::LogHub}
|
|
92
91
|
* {Ramaze::Logger::Informer}
|
|
93
|
-
* {Ramaze::Logger::Knotify}
|
|
94
92
|
* {Ramaze::Logger::Logger}: wrapper around the Logger class from the Stdlib.
|
|
95
93
|
* {Ramaze::Logging}: basic skeleton for your own loggers.
|
|
96
94
|
* {Ramaze::Logger::RotatingInformer}: logger that rotates log files based on the
|
|
97
95
|
current date.
|
|
98
96
|
* {Ramaze::Logger::Syslog}: logger that uses syslog.
|
|
99
|
-
* {Ramaze::Logger::Xosd}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Rack Middlewares
|
|
1
2
|
# Rack Middlewares
|
|
2
3
|
|
|
3
4
|
Ramaze is a Rack based framework and thus allows you to create so called Rack
|
|
@@ -6,7 +7,7 @@ in order to intercept and process sequentially each incoming request and outgoin
|
|
|
6
7
|
response between Rack and Ramaze. You can think of a collection of middlewares
|
|
7
8
|
as a stack at whose bottom lies your Ramaze app.
|
|
8
9
|
|
|
9
|
-
The flow of a Rack request (including middlewares) looks as following
|
|
10
|
+
The flow of a Rack request (including middlewares) looks as following:
|
|
10
11
|
|
|
11
12
|
Request --> Server (Thin, Unicorn, etc) --> Rack --> Middleware(s) -->
|
|
12
13
|
Ramaze --> Controller
|
|
@@ -83,7 +84,7 @@ banned". Our final middleware looks like the following:
|
|
|
83
84
|
## Using Middlewares
|
|
84
85
|
|
|
85
86
|
Now it's time to tell Ramaze to actually use the middleware. This can be done
|
|
86
|
-
by calling Ramaze#middleware
|
|
87
|
+
by calling Ramaze#middleware. This method accepts a block in which one defines
|
|
87
88
|
which middlewares to use for a specific mode and the name for this Ramaze mode
|
|
88
89
|
(Ramaze comes with "live" and "dev").
|
|
89
90
|
|
|
@@ -91,29 +92,20 @@ In the block you can call two Innate#MiddlewareCompiler methods
|
|
|
91
92
|
```use()``` and ```run()```. The ```use()``` method is used in order to add and
|
|
92
93
|
configure a middleware, while ```run()``` is used to determine what class is used
|
|
93
94
|
to run our Ramaze application. Unless you're using a custom class this should
|
|
94
|
-
always be set to
|
|
95
|
+
always be set to `Ramaze.core`.
|
|
95
96
|
|
|
96
97
|
Assuming we're running in "dev" mode our call will look like the following:
|
|
97
98
|
|
|
98
|
-
Ramaze.middleware
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
Ramaze.middleware :dev do
|
|
100
|
+
use Banlist
|
|
101
|
+
run Ramaze.core
|
|
101
102
|
end
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Ramaze.middleware! :dev do |mode|
|
|
112
|
-
current_mw.each do |mw|
|
|
113
|
-
mode.use(mw[0],*mw[1], &mw[2]) # middleware, args, block
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
mode.use(Banlist)
|
|
117
|
-
mode.run(Ramaze::AppMap)
|
|
118
|
-
end
|
|
119
|
-
|
|
104
|
+
<div class="note todo">
|
|
105
|
+
<p>
|
|
106
|
+
The method <code>Ramaze.middleware</code> can no longer be used to
|
|
107
|
+
retrieve the used middleware, instead it can only be used to set
|
|
108
|
+
these. The method <code>Ramaze.middleware!</code> also no longer
|
|
109
|
+
exists.
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
data/guide/general/models.md
CHANGED
data/guide/general/principles.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
# @title Ramaze Command
|
|
2
|
+
# Ramaze Command
|
|
2
3
|
|
|
3
4
|
Ramaze ships with a relatively simple command, named "ramaze". This command can
|
|
4
5
|
be used to create new applications as well as starting them. To make reading
|
|
@@ -25,39 +26,6 @@ directory name. If the application was named "blog" there would now be a
|
|
|
25
26
|
directory called "blog" in the current one. This directory will contain all
|
|
26
27
|
basic files that can be used for a Ramaze powered application.
|
|
27
28
|
|
|
28
|
-
Each new application has the following structure:
|
|
29
|
-
|
|
30
|
-
.__ app.rb
|
|
31
|
-
|__ config.ru
|
|
32
|
-
|__ controller
|
|
33
|
-
| |__ init.rb
|
|
34
|
-
| |__ main.rb
|
|
35
|
-
|
|
|
36
|
-
|__ layout
|
|
37
|
-
| |__ default.xhtml
|
|
38
|
-
|
|
|
39
|
-
|__ model
|
|
40
|
-
| |__ init.rb
|
|
41
|
-
|
|
|
42
|
-
|__ public
|
|
43
|
-
| |
|
|
44
|
-
| |__ css
|
|
45
|
-
| | |__ screen.css
|
|
46
|
-
| |
|
|
47
|
-
| |__ dispatch.fcgi
|
|
48
|
-
| |__ favicon.ico
|
|
49
|
-
| |__ js
|
|
50
|
-
| | |__ jquery.js
|
|
51
|
-
| |
|
|
52
|
-
| |__ ramaze.png
|
|
53
|
-
|
|
|
54
|
-
|__ spec
|
|
55
|
-
| |__ main.rb
|
|
56
|
-
|
|
|
57
|
-
|__ start.rb
|
|
58
|
-
|__ view
|
|
59
|
-
|__ index.xhtml
|
|
60
|
-
|
|
61
29
|
## Application Prototypes
|
|
62
30
|
|
|
63
31
|
Due to Ramaze's nature it's very easy to create your own application prototype
|
|
@@ -109,7 +77,6 @@ This is only a basic example of the flexibility of Ramaze, I highly recommend
|
|
|
109
77
|
you playing around with your own prototypes as it's a great way to learn the
|
|
110
78
|
basics of Ramaze and to really understand how flexible Ramaze is.
|
|
111
79
|
|
|
112
|
-
|
|
113
80
|
<div class="note todo">
|
|
114
81
|
<p>
|
|
115
82
|
<strong>Note</strong>: This prototype does not come with Ramaze, it's
|
|
@@ -121,19 +88,12 @@ basics of Ramaze and to really understand how flexible Ramaze is.
|
|
|
121
88
|
|
|
122
89
|
When you've created an application there are three ways of running it. You can
|
|
123
90
|
either use your server's command such as `thin` or `unicorn` but you can also
|
|
124
|
-
use
|
|
125
|
-
appropriate server according to the settings set in "config.ru" or "star.rb".
|
|
126
|
-
An example of using this command is as simple as the following:
|
|
127
|
-
|
|
128
|
-
$ ramaze start
|
|
129
|
-
|
|
130
|
-
On top of these two ways you can also start your Ramaze application by calling
|
|
131
|
-
the "start.rb" file using the ruby binary:
|
|
91
|
+
use a supplied Rake task:
|
|
132
92
|
|
|
133
|
-
$
|
|
93
|
+
$ rake ramaze:start
|
|
134
94
|
|
|
135
|
-
If you want to stop the running application you can simply close it by using
|
|
136
|
-
key combination Ctrl+C.
|
|
95
|
+
If you want to stop the running application you can simply close it by using
|
|
96
|
+
the key combination Ctrl+C.
|
|
137
97
|
|
|
138
98
|
<div class="note todo">
|
|
139
99
|
<p>
|
|
@@ -145,11 +105,6 @@ key combination Ctrl+C.
|
|
|
145
105
|
|
|
146
106
|
## Ramaze Console
|
|
147
107
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
access to your application and thus can be very useful for debugging purposes.
|
|
152
|
-
|
|
153
|
-
An example of a Ramaze console session can be seen in the image below.
|
|
154
|
-
|
|
155
|
-

|
|
108
|
+
By default Ramaze allows you to start a console using either IRB or Pry. These
|
|
109
|
+
consoles can be started by running `rake ramaze:irb` and `rake ramaze:pry`
|
|
110
|
+
respectively.
|
data/guide/general/routes.md
CHANGED
data/guide/general/sessions.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# @title Sessions
|
|
1
2
|
# Sessions
|
|
2
3
|
|
|
3
4
|
The term sessions is used for data associated to a specific client. The easiest
|
|
@@ -61,7 +62,7 @@ simple and works a bit like you're storing data in a hash:
|
|
|
61
62
|
session[:logged_in] = true
|
|
62
63
|
|
|
63
64
|
In the above example we stored a boolean with a value of "true" in the current
|
|
64
|
-
client's session under the name
|
|
65
|
+
client's session under the name `:logged_in`. If we want to retrieve this data
|
|
65
66
|
somewhere else in the application all we'd have to do is the following:
|
|
66
67
|
|
|
67
68
|
session[:logged_in] # => true
|
|
@@ -161,7 +162,7 @@ application:
|
|
|
161
162
|
|
|
162
163
|
If a client were to visit the index method for the first time nothing would be
|
|
163
164
|
displayed because the flash data isn't there yet. As soon as the client visits
|
|
164
|
-
|
|
165
|
+
`/set_message` he would be redirected back to the index method and the message
|
|
165
166
|
"Hello, Ramaze!" would be displayed. Refreshing the page would clear the flash
|
|
166
167
|
data and the message would no longer be displayed until the client visits
|
|
167
168
|
/set\_message again.
|