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/testing.md
CHANGED
data/guide/general/views.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
# @title Views
|
|
1
2
|
# Views
|
|
2
3
|
|
|
3
4
|
Views are the last step in the process of a request to a MVC framework such as
|
|
4
5
|
Ramaze. A controller loads a model, the model processes a certain amount of
|
|
5
6
|
data and the controller will then pass this data to a view. The typical flow of
|
|
6
|
-
a MVC framework (or any framework using a view system) looks like the following
|
|
7
|
+
a MVC framework (or any framework using a view system) looks like the following:
|
|
7
8
|
|
|
8
9
|
Request --> Controller --> View
|
|
9
10
|
^ |
|
|
@@ -62,10 +63,10 @@ The first way is passing a block to the layout() method:
|
|
|
62
63
|
end
|
|
63
64
|
end
|
|
64
65
|
|
|
65
|
-
In this example two layouts are used,
|
|
66
|
-
|
|
66
|
+
In this example two layouts are used, `index_layout` for the index() method and
|
|
67
|
+
`alternative_layout` for all other methods.
|
|
67
68
|
|
|
68
|
-
The second way is using the method
|
|
69
|
+
The second way is using the method `set_layout`. This method works almost
|
|
69
70
|
identical to layout() but has one big advantage: it can set method specific
|
|
70
71
|
layouts. Changing the code posted above so that it uses this method would look
|
|
71
72
|
like the following:
|
|
@@ -78,7 +79,7 @@ like the following:
|
|
|
78
79
|
set_layout 'index_layout' => [:index]
|
|
79
80
|
end
|
|
80
81
|
|
|
81
|
-
The set_layout method takes a hash where the keys are the names of the layouts
|
|
82
|
+
The `set_layout` method takes a hash where the keys are the names of the layouts
|
|
82
83
|
to use and the values the methods for which to use each layout. Below is another
|
|
83
84
|
example that specifies a few extra layout/method combinations.
|
|
84
85
|
|
|
@@ -90,6 +91,14 @@ example that specifies a few extra layout/method combinations.
|
|
|
90
91
|
set_layout 'main' => [:index, :edit], 'extra' => [:add, :synchronize]
|
|
91
92
|
end
|
|
92
93
|
|
|
94
|
+
<div class="note todo">
|
|
95
|
+
<p>
|
|
96
|
+
<strong>Note:</strong> layouts should be set <strong>outside</strong>
|
|
97
|
+
controller actions. Doing so can lead to unexpected behaviour as the
|
|
98
|
+
layout won't be visible until the next request.
|
|
99
|
+
</p>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
93
102
|
## Loading Views
|
|
94
103
|
|
|
95
104
|
Loading views can be done in two different ways. When not explicitly calling a
|
|
@@ -122,18 +131,18 @@ because Ramaze will use the return value of a controller method as the body for
|
|
|
122
131
|
the response that will be sent back to the visitor.
|
|
123
132
|
|
|
124
133
|
Let's take a look at the other() method in our controller. As you can see it
|
|
125
|
-
calls a method
|
|
134
|
+
calls a method `render_view`. This method is used to render a different view
|
|
126
135
|
(in this case foobar.xhtml) but without calling it's action, once this is done
|
|
127
136
|
the contents of the view will be returned to the controller. When calling custom
|
|
128
137
|
views you can use any of the following methods:
|
|
129
138
|
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
139
|
+
* render\_view
|
|
140
|
+
* render\_partial
|
|
141
|
+
* render\_file
|
|
142
|
+
* render\_custom
|
|
143
|
+
* render\_full
|
|
135
144
|
|
|
136
|
-
###
|
|
145
|
+
### render\_view
|
|
137
146
|
|
|
138
147
|
As mentioned earlier this method is used to render a view without calling it's
|
|
139
148
|
action. This can be useful if you have several methods that share the same view
|
|
@@ -148,13 +157,17 @@ variables to send to the view (more on this later).
|
|
|
148
157
|
# Render "foo.xhtml" and send some extra data to it
|
|
149
158
|
render_view :foo, :name => "Ramaze"
|
|
150
159
|
|
|
151
|
-
###
|
|
160
|
+
### render\_partial
|
|
161
|
+
|
|
162
|
+
The `render_partial` method works similar to the `render_view` method but with
|
|
163
|
+
two differences:
|
|
164
|
+
|
|
165
|
+
1. This method *does* execute a matching action.
|
|
166
|
+
2. This method *does not* render a layout.
|
|
152
167
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Ajax calls that don't need (or don't want to) load both the view and the layout.
|
|
157
|
-
This method has the same arguments as the render_view method.
|
|
168
|
+
This makes the `render_partial` method useful for responses to Ajax calls that
|
|
169
|
+
don't need (or don't want to) load both the view and the layout. This method has
|
|
170
|
+
the same arguments as the `render_view` method.
|
|
158
171
|
|
|
159
172
|
# Render the view "partial.xhtml"
|
|
160
173
|
render_partial :partial
|
|
@@ -162,10 +175,10 @@ This method has the same arguments as the render_view method.
|
|
|
162
175
|
# Render the partial "partial.xhtml" and send some extra data to it
|
|
163
176
|
render_partial :partial, :name => "Ramaze"
|
|
164
177
|
|
|
165
|
-
###
|
|
178
|
+
### render\_file
|
|
166
179
|
|
|
167
180
|
There comes a time when you may want to render a file that's located somewhere
|
|
168
|
-
else. For this there is the render_file() method. This method takes a path,
|
|
181
|
+
else. For this there is the `render_file()`` method. This method takes a path,
|
|
169
182
|
either relative or absolute to a file that should be rendered. This can be
|
|
170
183
|
useful if you have a cache directory located outside of your project directory
|
|
171
184
|
and you want to load a view from it.
|
|
@@ -187,7 +200,7 @@ action.
|
|
|
187
200
|
action.layout = nil
|
|
188
201
|
end
|
|
189
202
|
|
|
190
|
-
###
|
|
203
|
+
### render\_custom
|
|
191
204
|
|
|
192
205
|
The render_custom() method can be used to create your personal render method and
|
|
193
206
|
is actually used by methods such as the render_partial method. The syntax is the
|
|
@@ -202,7 +215,7 @@ argument should be the name of the action to render.
|
|
|
202
215
|
action.method = nil
|
|
203
216
|
end
|
|
204
217
|
|
|
205
|
-
###
|
|
218
|
+
### render\_full
|
|
206
219
|
|
|
207
220
|
Last but not least there's the render_full() method. This is the method Ramaze
|
|
208
221
|
uses for calling a controller along with it's views and such. This method takes
|
data/lib/proto/Gemfile
ADDED
data/lib/proto/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Ramaze Application
|
|
2
|
+
|
|
3
|
+
Welcome to your new Ramaze application. This README serves as a starting point
|
|
4
|
+
for writing an application using the code you just generated.
|
|
5
|
+
|
|
6
|
+
Once you've started working on your application you'll probably want to update
|
|
7
|
+
this README so that its contents reflect your application's state and purpose.
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
In order to run this application you'll need to have Ramaze 2.0.0 or newer and
|
|
12
|
+
Rake. Optionally you can install Bundler and use it for Gem management, this
|
|
13
|
+
can be done as following:
|
|
14
|
+
|
|
15
|
+
$ gem install bundler
|
|
16
|
+
$ bundle install
|
|
17
|
+
|
|
18
|
+
## Rake Tasks
|
|
19
|
+
|
|
20
|
+
This application comes with a few predefined Rake tasks that make it easy to
|
|
21
|
+
get started. You can list these tasks by running `rake -T` or `rake -D` (this
|
|
22
|
+
shows longer descriptions for tasks if there are any).
|
|
23
|
+
|
|
24
|
+
For example, to start a Ramaze console using Pry you'd run the following
|
|
25
|
+
command:
|
|
26
|
+
|
|
27
|
+
$ rake ramaze:pry
|
|
28
|
+
|
|
29
|
+
## Resources
|
|
30
|
+
|
|
31
|
+
In case you need help you can refer to the following resources:
|
|
32
|
+
|
|
33
|
+
* Ramaze website: <http://ramaze.net/>
|
|
34
|
+
* Github repository: <https://github.com/ramaze/ramaze>
|
|
35
|
+
* IRC channel: \#ramaze on Freenode
|
data/lib/proto/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir.glob(File.expand_path('../task/*.rake', __FILE__)) { |task| import task }
|
data/lib/proto/app.rb
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
# This file contains your application, it requires dependencies and necessary
|
|
2
|
-
# the application.
|
|
3
|
-
#
|
|
4
|
-
# It will be required from either `config.ru` or `start.rb`
|
|
1
|
+
# This file contains your application, it requires dependencies and necessary
|
|
2
|
+
# parts of the application.
|
|
5
3
|
require 'rubygems'
|
|
6
4
|
require 'ramaze'
|
|
7
5
|
|
|
8
6
|
# Make sure that Ramaze knows where you are
|
|
9
7
|
Ramaze.options.roots = [__DIR__]
|
|
10
8
|
|
|
11
|
-
# Initialize controllers and models
|
|
12
|
-
require __DIR__('model/init')
|
|
13
9
|
require __DIR__('controller/init')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require File.expand_path('../../app', __FILE__)
|
|
2
|
+
|
|
3
|
+
# This file can be used to set various configuration options for your testing
|
|
4
|
+
# suite. Ramaze itself uses Bacon but you're not forced to use this. Want to
|
|
5
|
+
# use Rspec instead? Go ahead!
|
|
6
|
+
#
|
|
7
|
+
# If you do happen to use Bacon you can uncomment the following lines to get
|
|
8
|
+
# started with testing Ramaze using Bacon:
|
|
9
|
+
#
|
|
10
|
+
# require 'bacon'
|
|
11
|
+
# require 'ramaze/spec/bacon'
|
|
12
|
+
|
|
13
|
+
# The following code is an example on how to set up Capybara
|
|
14
|
+
# (https://github.com/jnicklas/capybara) for Ramaze. If you don't use Capybara
|
|
15
|
+
# you can safely remove these comments.
|
|
16
|
+
#
|
|
17
|
+
# require 'capybara/dsl'
|
|
18
|
+
#
|
|
19
|
+
# Capybara.configure do |config|
|
|
20
|
+
# config.default_driver = :rack_test
|
|
21
|
+
# config.app = Ramaze
|
|
22
|
+
# end
|
|
23
|
+
#
|
|
24
|
+
# shared :capybara do
|
|
25
|
+
# Ramaze.setup_dependencies
|
|
26
|
+
#
|
|
27
|
+
# extend Capybara::DSL
|
|
28
|
+
# end
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
# The following few lines of code are the most basic settings you'll want to
|
|
32
|
+
# use for testing Ramaze. They ensure that the environment is set correctly and
|
|
33
|
+
# that your output isn't clogged with non important information.
|
|
34
|
+
Ramaze.middleware :spec do
|
|
35
|
+
run Ramaze.core
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
Ramaze::Log.level = Logger::ERROR
|
|
39
|
+
Ramaze.options.mode = :spec
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# This file contains a predefined set of Rake tasks that can be useful when
|
|
2
|
+
# developing Ramaze applications. You're free to modify these tasks to your
|
|
3
|
+
# liking, they will not be overwritten when updating Ramaze.
|
|
4
|
+
|
|
5
|
+
namespace :ramaze do
|
|
6
|
+
app = File.expand_path('../../app', __FILE__)
|
|
7
|
+
|
|
8
|
+
desc 'Starts a Ramaze console using IRB'
|
|
9
|
+
task :irb do
|
|
10
|
+
require app
|
|
11
|
+
require 'irb'
|
|
12
|
+
require 'irb/completion'
|
|
13
|
+
|
|
14
|
+
ARGV.clear
|
|
15
|
+
IRB.start
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Pry can be installed using `gem install pry`.
|
|
19
|
+
desc 'Starts a Ramaze console using Pry'
|
|
20
|
+
task :pry do
|
|
21
|
+
require app
|
|
22
|
+
require 'pry'
|
|
23
|
+
|
|
24
|
+
ARGV.clear
|
|
25
|
+
Pry.start
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# In case you want to use a different server or port you can freely modify
|
|
29
|
+
# the options passed to `Ramaze.start()`.
|
|
30
|
+
desc 'Starts Ramaze for development'
|
|
31
|
+
task :start do
|
|
32
|
+
require app
|
|
33
|
+
|
|
34
|
+
Ramaze.start(
|
|
35
|
+
:adapter => :webrick,
|
|
36
|
+
:port => 7000,
|
|
37
|
+
:file => __FILE__,
|
|
38
|
+
:root => Ramaze.options.roots
|
|
39
|
+
)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc 'Lists all the routes defined using Ramaze::Route'
|
|
43
|
+
task :routes do
|
|
44
|
+
require app
|
|
45
|
+
|
|
46
|
+
if Ramaze::Route::ROUTES.empty?
|
|
47
|
+
abort 'No routes have been defined using Ramaze::Route'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
spacing = Ramaze::Route::ROUTES.map { |k, v| k.to_s }
|
|
51
|
+
spacing = spacing.sort { |l, r| r.length <=> l.length }[0].length
|
|
52
|
+
|
|
53
|
+
Ramaze::Route::ROUTES.each do |from, to|
|
|
54
|
+
puts "%-#{spacing}s => %s" % [from, to]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
data/lib/ramaze.rb
CHANGED
|
@@ -22,6 +22,8 @@ module Ramaze
|
|
|
22
22
|
$LOAD_PATH.unshift(ROOT)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
extend Innate::SingletonMethods
|
|
26
|
+
|
|
25
27
|
# vendored, will go into rack-contrib
|
|
26
28
|
require 'vendor/route_exceptions'
|
|
27
29
|
|
|
@@ -34,11 +36,8 @@ module Ramaze
|
|
|
34
36
|
require 'ramaze/controller'
|
|
35
37
|
require 'ramaze/cache'
|
|
36
38
|
require 'ramaze/reloader'
|
|
37
|
-
require 'ramaze/setup'
|
|
38
39
|
require 'ramaze/app'
|
|
39
40
|
require 'ramaze/files'
|
|
40
|
-
require 'ramaze/middleware_compiler'
|
|
41
|
-
require 'ramaze/plugin'
|
|
42
41
|
require 'ramaze/request'
|
|
43
42
|
require 'ramaze/current'
|
|
44
43
|
|
|
@@ -55,44 +54,18 @@ module Ramaze
|
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
m.use Rack::Lint
|
|
64
|
-
m.use Rack::CommonLogger, Ramaze::Log
|
|
65
|
-
m.use Rack::ShowExceptions
|
|
66
|
-
m.use Rack::ShowStatus
|
|
67
|
-
m.use Rack::RouteExceptions
|
|
68
|
-
m.use Rack::ConditionalGet
|
|
57
|
+
##
|
|
58
|
+
# @see Innate.core
|
|
59
|
+
#
|
|
60
|
+
def self.core
|
|
61
|
+
roots, publics = options[:roots], options[:publics]
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
else
|
|
74
|
-
m.use Rack::ETag, 'public'
|
|
75
|
-
end
|
|
63
|
+
joined = roots.map { |r| publics.map { |p| File.join(r, p) } }
|
|
64
|
+
joined = joined.flatten.map { |p| Rack::File.new(p) }
|
|
65
|
+
current = Current.new(Route.new(AppMap), Rewrite.new(AppMap))
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
m.use Ramaze::Reloader
|
|
79
|
-
m.run Ramaze::AppMap
|
|
67
|
+
return Rack::Cascade.new(joined << current, [404, 405])
|
|
80
68
|
end
|
|
81
69
|
|
|
82
|
-
|
|
83
|
-
m.use Rack::CommonLogger, Ramaze::Log
|
|
84
|
-
m.use Rack::RouteExceptions
|
|
85
|
-
m.use Rack::ShowStatus
|
|
86
|
-
m.use Rack::ConditionalGet
|
|
87
|
-
|
|
88
|
-
# FIXME: This works around differences between Rack 1.2.1 and the git HEAD
|
|
89
|
-
if Rack::ETag.instance_method(:initialize).arity == 1
|
|
90
|
-
m.use Rack::ETag
|
|
91
|
-
else
|
|
92
|
-
m.use Rack::ETag, 'public'
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
m.use Rack::Head
|
|
96
|
-
m.run Ramaze::AppMap
|
|
97
|
-
end
|
|
70
|
+
require 'ramaze/default_middleware'
|
|
98
71
|
end
|
data/lib/ramaze/bin/create.rb
CHANGED
|
@@ -15,10 +15,8 @@ module Ramaze
|
|
|
15
15
|
# @since 21-07-2011
|
|
16
16
|
#
|
|
17
17
|
class Create
|
|
18
|
-
|
|
19
|
-
Description = 'Allows developers to easily create new Ramaze applications.'
|
|
18
|
+
Description = 'Creates a new Ramaze application'
|
|
20
19
|
|
|
21
|
-
# The banner of this command.
|
|
22
20
|
Banner = <<-TXT.strip
|
|
23
21
|
Allows developers to easily create new Ramaze applications based on the
|
|
24
22
|
prototype that ships with Ramaze.
|
data/lib/ramaze/bin/runner.rb
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
require 'optparse'
|
|
2
2
|
require 'pathname'
|
|
3
3
|
|
|
4
|
-
require __DIR__('helper')
|
|
5
|
-
require __DIR__('start')
|
|
6
|
-
require __DIR__('restart')
|
|
7
|
-
require __DIR__('stop')
|
|
8
4
|
require __DIR__('create')
|
|
9
|
-
require __DIR__('status')
|
|
10
|
-
require __DIR__('console')
|
|
11
5
|
|
|
12
6
|
module Ramaze
|
|
13
7
|
#:nodoc:
|
|
@@ -28,18 +22,10 @@ module Ramaze
|
|
|
28
22
|
# @since 21-07-2011
|
|
29
23
|
#
|
|
30
24
|
module Runner
|
|
31
|
-
# Hash containing all the available commands, their names and their
|
|
32
|
-
# classes.
|
|
33
25
|
Commands = {
|
|
34
|
-
:start => Ramaze::Bin::Start,
|
|
35
|
-
:stop => Ramaze::Bin::Stop,
|
|
36
|
-
:restart => Ramaze::Bin::Restart,
|
|
37
|
-
:status => Ramaze::Bin::Status,
|
|
38
26
|
:create => Ramaze::Bin::Create,
|
|
39
|
-
:console => Ramaze::Bin::Console,
|
|
40
27
|
}
|
|
41
28
|
|
|
42
|
-
# String containing the banner of the main command.
|
|
43
29
|
Banner = <<-TXT.strip
|
|
44
30
|
Ramaze is a simple, light and modular open-source web application
|
|
45
31
|
framework written in Ruby.
|
data/lib/ramaze/cache.rb
CHANGED
|
@@ -13,6 +13,27 @@ module Ramaze
|
|
|
13
13
|
autoload :Sequel, 'ramaze/cache/sequel'
|
|
14
14
|
autoload :Redis, 'ramaze/cache/redis'
|
|
15
15
|
|
|
16
|
+
##
|
|
17
|
+
# Overwrites {Innate::Cache#initialize} to make cache classes application
|
|
18
|
+
# aware. This prevents different applications running on the same host and
|
|
19
|
+
# user from overwriting eachothers data.
|
|
20
|
+
#
|
|
21
|
+
# @since 14-05-2012
|
|
22
|
+
# @see Innate::Cache#initialize
|
|
23
|
+
#
|
|
24
|
+
def initialize(name, klass = nil)
|
|
25
|
+
@name = name.to_s.dup.freeze
|
|
26
|
+
klass ||= options[@name.to_sym]
|
|
27
|
+
@instance = klass.new
|
|
28
|
+
|
|
29
|
+
@instance.cache_setup(
|
|
30
|
+
ENV['HOSTNAME'],
|
|
31
|
+
ENV['USER'],
|
|
32
|
+
Ramaze.options.app.name.to_s,
|
|
33
|
+
@name
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
16
37
|
##
|
|
17
38
|
# Clears the cache after a file has been reloaded.
|
|
18
39
|
#
|