merb 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +138 -56
- data/Rakefile +23 -8
- data/app_generators/merb/templates/Rakefile +13 -0
- data/app_generators/merb/templates/app/helpers/global_helper.rb +1 -1
- data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +12 -3
- data/app_generators/merb/templates/config/merb.yml +14 -1
- data/app_generators/merb/templates/spec/spec_helper.rb +6 -0
- data/app_generators/merb/templates/test/test_helper.rb +1 -0
- data/lib/merb.rb +27 -7
- data/lib/merb/abstract_controller.rb +76 -36
- data/lib/merb/caching/store/memcache.rb +20 -0
- data/lib/merb/constants.rb +2 -4
- data/lib/merb/controller.rb +44 -2
- data/lib/merb/core_ext/get_args.rb +23 -4
- data/lib/merb/core_ext/hash.rb +16 -11
- data/lib/merb/core_ext/inflections.rb +1 -1
- data/lib/merb/core_ext/kernel.rb +106 -26
- data/lib/merb/core_ext/numeric.rb +1 -1
- data/lib/merb/core_ext/string.rb +10 -13
- data/lib/merb/dispatcher.rb +2 -2
- data/lib/merb/exceptions.rb +3 -1
- data/lib/merb/logger.rb +15 -6
- data/lib/merb/mail_controller.rb +18 -2
- data/lib/merb/mailer.rb +1 -1
- data/lib/merb/mixins/controller.rb +64 -228
- data/lib/merb/mixins/erubis_capture.rb +1 -1
- data/lib/merb/mixins/general_controller.rb +258 -0
- data/lib/merb/mixins/render.rb +45 -24
- data/lib/merb/mixins/responder.rb +89 -18
- data/lib/merb/mixins/view_context.rb +32 -5
- data/lib/merb/mixins/web_controller.rb +8 -1
- data/lib/merb/mongrel_handler.rb +27 -17
- data/lib/merb/part_controller.rb +10 -0
- data/lib/merb/request.rb +34 -14
- data/lib/merb/router.rb +77 -45
- data/lib/merb/server.rb +116 -72
- data/lib/merb/session/cookie_store.rb +14 -22
- data/lib/merb/session/mem_cache_session.rb +2 -2
- data/lib/merb/session/memory_session.rb +12 -1
- data/lib/merb/template/erubis.rb +31 -0
- data/lib/merb/template/haml.rb +4 -14
- data/lib/merb/template/xml_builder.rb +1 -1
- data/lib/merb/test/helper.rb +90 -18
- data/lib/merb/test/rspec.rb +145 -74
- data/lib/merb/version.rb +11 -0
- data/lib/merb/view_context.rb +3 -6
- data/lib/patch +69 -0
- data/lib/tasks/merb.rake +1 -1
- data/spec/fixtures/config/environments/environment_config_test.yml +1 -0
- data/spec/fixtures/controllers/render_spec_controllers.rb +63 -4
- data/spec/fixtures/views/examples/template_throw_content_without_block.html.erb +3 -0
- data/spec/fixtures/views/partials/_erubis.html.erb +1 -1
- data/spec/merb/abstract_controller_spec.rb +1 -0
- data/spec/merb/controller_filters_spec.rb +68 -3
- data/spec/merb/controller_spec.rb +35 -68
- data/spec/merb/cookie_store_spec.rb +7 -20
- data/spec/merb/core_ext_spec.rb +35 -1
- data/spec/merb/dispatch_spec.rb +8 -2
- data/spec/merb/generator_spec.rb +12 -4
- data/spec/merb/mail_controller_spec.rb +33 -0
- data/spec/merb/part_controller_spec.rb +33 -1
- data/spec/merb/render_spec.rb +74 -0
- data/spec/merb/request_spec.rb +43 -0
- data/spec/merb/responder_spec.rb +1 -0
- data/spec/merb/router_spec.rb +118 -13
- data/spec/merb/server_spec.rb +19 -0
- data/spec/merb/view_context_spec.rb +31 -3
- data/spec/spec_helper.rb +8 -0
- data/spec/spec_helpers/url_shared_behaviour.rb +112 -0
- metadata +124 -87
data/README
CHANGED
@@ -1,24 +1,16 @@
|
|
1
1
|
= Merb
|
2
2
|
|
3
|
-
|
3
|
+
Like Ruby on Rails, Merb (Mongrel + ERB) is an MVC framework. Unlike Rails, Merb is ORM-agnostic, JavaScript library agnostic, and template language agnostic, preferring plugins that add in support for a particular feature rather than trying to produce a monolithic library with everything in the core. In fact, this is a guiding principle of the project, which has led to third-party support for the ActiveRecord, DataMapper, and Sequel ORMs.
|
4
4
|
|
5
|
-
|
5
|
+
In addition, it means that the core code in Merb is kept simple and well organised. This has multiple benefits. It means it's faster for one thing. It's also easier to understand, maintain and extend.
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
* erubis
|
11
|
-
* mime-types
|
12
|
-
* rspec
|
13
|
-
* hpricot
|
14
|
-
* mocha
|
15
|
-
* rubigen
|
16
|
-
* haml
|
17
|
-
* markaby
|
18
|
-
* mailfactory
|
19
|
-
* Ruby2Ruby
|
7
|
+
=== Get Merb
|
8
|
+
|
9
|
+
The simplest way to get Merb is to install the gem:
|
20
10
|
|
21
|
-
|
11
|
+
$ sudo gem install merb --include-dependencies
|
12
|
+
|
13
|
+
If you want to contribute (or just use the latest code), you can build the gem from the svn trunk:
|
22
14
|
|
23
15
|
$ sudo gem install mongrel json json_pure erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory Ruby2Ruby -y
|
24
16
|
$ svn co http://svn.devjavu.com/merb/trunk merb
|
@@ -26,8 +18,40 @@ Then you can build the merb gem from svn trunk like so:
|
|
26
18
|
$ rake install
|
27
19
|
|
28
20
|
To generate a new merb app after the gem is installed:
|
21
|
+
|
22
|
+
$ merb myapp
|
29
23
|
|
30
|
-
|
24
|
+
==== Dependencies
|
25
|
+
|
26
|
+
Currently, Merb itself depends on the following gems:
|
27
|
+
|
28
|
+
* mongrel
|
29
|
+
* json_pure
|
30
|
+
* erubis
|
31
|
+
* mime-types
|
32
|
+
* rspec
|
33
|
+
* rubigen
|
34
|
+
* ruby2ruby
|
35
|
+
* rake
|
36
|
+
|
37
|
+
** If you are on windows see this blog post oj how to get up and running:
|
38
|
+
http://www.ghostonthird.com/2007/11/17/merb-on-windows-it-works/
|
39
|
+
|
40
|
+
You must also have either the json or json_pure gem installed. Note that the json gem
|
41
|
+
provides a faster library but will not work with jRuby.
|
42
|
+
|
43
|
+
Optionally, merb can take advantage of the following gems:
|
44
|
+
|
45
|
+
* mailfactory (if you wish to use merb's mailers)
|
46
|
+
* haml (if you wish to use HAML templates, i.e. .haml files)
|
47
|
+
* markaby (if you wish to use Markaby template, i.e. .mab files)
|
48
|
+
* builder (if you wish to use Builder templates, i.e. .rxml, .rerb or .builder files)
|
49
|
+
* memcache-client (for use with Danga Interactive's memcached)
|
50
|
+
* swiftiply
|
51
|
+
* eventmachine
|
52
|
+
* rcov
|
53
|
+
|
54
|
+
You will also probably need to install your ORM of choice as well as any gem plugins you want to use (see below).
|
31
55
|
|
32
56
|
=== The +merb+ server
|
33
57
|
|
@@ -53,46 +77,49 @@ use the -i flag
|
|
53
77
|
$ merb -i
|
54
78
|
|
55
79
|
To see all the available command line flags use:
|
56
|
-
|
57
|
-
|
80
|
+
|
81
|
+
$ merb -h
|
82
|
+
|
83
|
+
|
84
|
+
== Using Merb
|
85
|
+
|
86
|
+
Merb uses the Model-View-Controller (MVC) pattern. Incoming requests are matched in the Router and
|
87
|
+
directed to an appropriate controller action.
|
88
|
+
|
89
|
+
=== Model
|
90
|
+
|
91
|
+
Merb does not come with its own model layer. While you are free to use whatever data system you like,
|
92
|
+
the merb core team does maintain plugins for the following Object Relational Mappers (ORM's):
|
93
|
+
|
94
|
+
ActiveRecord:: The same ORM that Rails uses. (<tt>sudo gem install merb_activerecord</tt>)
|
95
|
+
DataMapper:: Fairly new ORM. (<tt>sudo gem install merb_datamapper</tt>)
|
96
|
+
Sequel:: Fairly new ORM. (<tt>sudo gem install merb_sequel</tt>)
|
97
|
+
|
98
|
+
To use your choice ORM, install the appropriate gem and uncomment the appropriate +use_orm+ line in
|
99
|
+
MERB_ROOT/config/dependencies.rb
|
58
100
|
|
59
101
|
=== Controllers
|
60
102
|
|
61
|
-
|
62
|
-
with instance vars available in the views automatically. Merb also supports
|
63
|
-
layouts. It will look for a layout named after your controller class first and
|
64
|
-
then fall back to application.html.erb if no layout exists named after your
|
65
|
-
controller. You can use render <tt>:layout => :none</tt>.
|
66
|
-
|
67
|
-
Merb does not automatically render for you in your controller actions, you have
|
68
|
-
to call render yourself. I consider this a big advantage over the way rails does
|
69
|
-
it for a few reasons. The main reason is that in rails you can only render once
|
70
|
-
per action, so it knows if you haven’t rendered it shoudl auto render. Merb on
|
71
|
-
the other hand, returns to the browser whatever the return value of your
|
72
|
-
controller’s action method is. This opens up more possibilities imho because
|
73
|
-
now you can return any string from your action and that will be sent down
|
74
|
-
the pipe. So Merb’s render method just returns a string and needs to be the
|
75
|
-
last thing you call in your action. You can render multiple times and capture
|
76
|
-
the results into @ivars and then render a master template with many embeded
|
77
|
-
templates. Also if you return a handle on a File or IO object from your action
|
78
|
-
then merb will hand that over to mongrel to be streamed out to the client. And
|
79
|
-
if you return a Proc object from your action, it will be called and the
|
80
|
-
return value sent to the client.
|
103
|
+
(MERB_ROOT/app/controllers/*)
|
81
104
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
process. By returning a Proc object from your action, you allow merb to
|
87
|
-
release the lock and the proc is called in multi threaded way. This allows
|
88
|
-
for all kinds of cool streaming and ‘futures’ where you return the proc and
|
89
|
-
release the mutex. It’s basically like handing over the proc to mongrel and
|
90
|
-
mongrel handles calling it in a thread safe manner.
|
105
|
+
Merb controllers inherit from Merb::Controller and contain built in view/template rendering.
|
106
|
+
Incoming requests are usually mapped to a specific method in a controller. For example, using
|
107
|
+
the default routes, a request to http://www.yourapp.com/posts/show/1 would call the the #show
|
108
|
+
method of your PostsController (and params[:id] would = 1.)
|
91
109
|
|
110
|
+
The return value of your action function gets sent back to the client as the view. In most cases,
|
111
|
+
you are going to want to end your functions with a call to +render+. By default, +render+ will
|
112
|
+
render the view template associated with your action (in default merb that would be
|
113
|
+
MERB_ROOT/app/views/<controller>/<action>.html.erb - see the View section for more info.)
|
92
114
|
|
93
|
-
|
115
|
+
Controllers can be generated by calling MERB_ROOT/script/generate controller ControllerName.
|
116
|
+
By default, generated controllers inherit from the Application class (MERB_ROOT/app/controllers/application.rb)
|
117
|
+
which itself inherits from Merb:Controller. Application is a good place to put code pertinent to all controllers.
|
118
|
+
An example would be setting a filter to check if a user is logged in or to preload user data for each controller.
|
94
119
|
|
95
|
-
|
120
|
+
==== +before+ and +after+ filters
|
121
|
+
|
122
|
+
Use the +before+ method in your controllers. +before+ accepts either a symbol, string or a Proc/lambda object. If you give it a symbol it will call a method with the same name as the symbol. If you give it a proc that takes one argument it will call the proc with the current controller as that argument. You can use :only and :exclude as options to your filters to exclude or include actions from certain filters. :only and :exclude take :symbols or [:sym, :sam] array of symbols.
|
96
123
|
|
97
124
|
class Foo < Merb::Controller
|
98
125
|
|
@@ -141,8 +168,62 @@ After filters accept a symbol, string or Proc and call that proc with the contro
|
|
141
168
|
|
142
169
|
after Proc.new {|c| Tidy.new(c.body) }, :only => :index
|
143
170
|
|
171
|
+
|
172
|
+
=== Views
|
173
|
+
|
174
|
+
(MERB_ROOT/app/views/*)
|
175
|
+
|
176
|
+
A view can be loosely defined as any data sent back to the client (a "view" of your data.)
|
177
|
+
By default, Merb controllers send the return value of your controller action as the view.
|
178
|
+
The Controller#render method simply renders the specified view and returns it as a string.
|
179
|
+
By default, a call to +render+ without any options renders the view template associated
|
180
|
+
with that controller action. Using the default ERB templating system, this means that a
|
181
|
+
call to +render+ in Posts#index would render the file MERB_ROOT/app/views/posts/index.html.erb
|
182
|
+
|
183
|
+
==== Layouts
|
184
|
+
|
185
|
+
(MERB_ROOT/app/views/layout/*)
|
186
|
+
|
187
|
+
Layouts are generic templates in which your specific view templates are rendered. A sample
|
188
|
+
layout could look like:
|
189
|
+
|
190
|
+
<html>
|
191
|
+
<head><title>My Application Layout</title></head>
|
192
|
+
<body>
|
193
|
+
<img src="header" />
|
194
|
+
<div id="content">
|
195
|
+
<%= catch_content :layout %>
|
196
|
+
</div>
|
197
|
+
</body>
|
198
|
+
</html>
|
199
|
+
|
200
|
+
By default, +render+ will look for a corresponding layout for your controller in the form
|
201
|
+
of MERB_ROOT/app/views/layout/<controller>.html.erb . If no specific layout is present,
|
202
|
+
+render+ will attempt to use MERB_ROOT/app/view/layout/application.html.erb
|
203
|
+
|
204
|
+
<i>See #render for more details/options, as well as how to use different templating systems
|
205
|
+
in your app.</i>
|
206
|
+
|
207
|
+
You can return several different types of values from your controller actions:
|
208
|
+
|
209
|
+
* String: Any string will get sent to the browser as standard text/html
|
210
|
+
* File/IO: Any file descriptor will get handed over to mongrel to be streamed to the client.
|
211
|
+
* Proc Object: The object will be called and the return value sent to the client.
|
212
|
+
|
213
|
+
That last point has some cool connotations if you think about it. Merb does
|
214
|
+
have a mutex lock around the call to your controller’s action anywhere that
|
215
|
+
you can call AR objects. Merb’s lock is way smaller then rails giant lock
|
216
|
+
though and allows for many more concurrent requests to be handled by one
|
217
|
+
process. By returning a Proc object from your action, you allow merb to
|
218
|
+
release the lock and the proc is called in multi threaded way. This allows
|
219
|
+
for all kinds of cool streaming and ‘futures’ where you return the proc and
|
220
|
+
release the mutex. It’s basically like handing over the proc to mongrel and
|
221
|
+
mongrel handles calling it in a thread safe manner.
|
222
|
+
|
144
223
|
=== Helpers
|
145
224
|
|
225
|
+
(MERB_ROOT/app/helpers/*)
|
226
|
+
|
146
227
|
app/helpers/global_helper.rb will be available to all of your views.
|
147
228
|
Helpers named after your controller plus _helper.rb will be included in the views
|
148
229
|
for that controller only.
|
@@ -172,17 +253,18 @@ A file upload will have a hash of params like this:
|
|
172
253
|
|
173
254
|
app
|
174
255
|
controllers
|
256
|
+
helpers
|
257
|
+
mailers
|
175
258
|
models
|
176
|
-
views
|
177
259
|
parts
|
178
|
-
|
260
|
+
views
|
179
261
|
config
|
262
|
+
gems
|
180
263
|
lib
|
264
|
+
log
|
181
265
|
public
|
182
|
-
schema
|
183
266
|
Rakefile
|
184
|
-
|
267
|
+
script
|
268
|
+
spec
|
185
269
|
test
|
186
|
-
spec
|
187
270
|
unit
|
188
|
-
plugins
|
data/Rakefile
CHANGED
@@ -14,10 +14,15 @@ require __DIR__+'/tools/annotation_extract'
|
|
14
14
|
include FileUtils
|
15
15
|
|
16
16
|
NAME = "merb"
|
17
|
-
|
17
|
+
require 'lib/merb/version'
|
18
18
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
19
19
|
|
20
|
-
|
20
|
+
|
21
|
+
windows = (PLATFORM =~ /win32|cygwin/)
|
22
|
+
|
23
|
+
SUDO = windows ? "" : "sudo"
|
24
|
+
|
25
|
+
setup_clean [ "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", 'coverage', "cache", "log"]
|
21
26
|
|
22
27
|
|
23
28
|
desc "Packages up Merb."
|
@@ -33,14 +38,14 @@ Rake::RDocTask.new do |rdoc|
|
|
33
38
|
rdoc.rdoc_files.add(files)
|
34
39
|
rdoc.main = 'README'
|
35
40
|
rdoc.title = 'Merb Docs'
|
36
|
-
rdoc.template =
|
41
|
+
rdoc.template = __DIR__ + '/tools/allison-2.0/lib/allison.rb'
|
37
42
|
rdoc.rdoc_dir = 'doc/rdoc'
|
38
43
|
rdoc.options << '--line-numbers' << '--inline-source'
|
39
44
|
end
|
40
45
|
|
41
46
|
spec = Gem::Specification.new do |s|
|
42
47
|
s.name = NAME
|
43
|
-
s.version =
|
48
|
+
s.version = Merb::VERSION
|
44
49
|
s.platform = Gem::Platform::RUBY
|
45
50
|
s.has_rdoc = true
|
46
51
|
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
@@ -57,6 +62,10 @@ spec = Gem::Specification.new do |s|
|
|
57
62
|
s.add_dependency('erubis')
|
58
63
|
s.add_dependency('mime-types')
|
59
64
|
s.add_dependency('rubigen')
|
65
|
+
s.add_dependency('rake')
|
66
|
+
s.add_dependency('ruby2ruby')
|
67
|
+
s.add_dependency('json_pure')
|
68
|
+
s.requirements << 'install the json gem to get faster json parsing'
|
60
69
|
s.required_ruby_version = '>= 1.8.4'
|
61
70
|
|
62
71
|
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{bin,spec,lib,examples,app_generators,merb_generators,merb_default_generators,rspec_generators,test_unit_generators,script}/**/*")
|
@@ -72,11 +81,11 @@ end
|
|
72
81
|
|
73
82
|
task :install do
|
74
83
|
sh %{rake package}
|
75
|
-
sh %{
|
84
|
+
sh %{#{SUDO} gem install pkg/#{NAME}-#{Merb::VERSION} --no-rdoc --no-ri}
|
76
85
|
end
|
77
86
|
|
78
87
|
task :uninstall => [:clean] do
|
79
|
-
sh %{
|
88
|
+
sh %{#{SUDO} gem uninstall #{NAME}}
|
80
89
|
end
|
81
90
|
|
82
91
|
desc "run webgen"
|
@@ -87,7 +96,7 @@ end
|
|
87
96
|
desc "rdoc to rubyforge"
|
88
97
|
task :doc_rforge do
|
89
98
|
sh %{rake doc}
|
90
|
-
sh %{
|
99
|
+
sh %{#{SUDO} chmod -R 755 doc} unless windows
|
91
100
|
sh %{/usr/bin/scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
|
92
101
|
end
|
93
102
|
|
@@ -138,7 +147,11 @@ task :stats do
|
|
138
147
|
end
|
139
148
|
|
140
149
|
task :release => :package do
|
141
|
-
|
150
|
+
if ENV['RELEASE']
|
151
|
+
sh %{rubyforge add_release merb merb "#{ENV['RELEASE']}" pkg/#{NAME}-#{Merb::VERSION}.gem}
|
152
|
+
else
|
153
|
+
puts 'Usage: rake release RELEASE="Clever tag line goes here"'
|
154
|
+
end
|
142
155
|
end
|
143
156
|
|
144
157
|
##############################################################################
|
@@ -171,3 +184,5 @@ rule "" do |t|
|
|
171
184
|
sh "#{spec_cmd} #{run_file_name} --format specdoc --colour #{example}"
|
172
185
|
end
|
173
186
|
end
|
187
|
+
|
188
|
+
|
@@ -6,6 +6,7 @@ require 'fileutils'
|
|
6
6
|
require 'rubygems'
|
7
7
|
|
8
8
|
MERB_ENV = ENV['MERB_ENV'] if ENV['MERB_ENV']
|
9
|
+
$RAKE_ENV = true
|
9
10
|
|
10
11
|
require File.dirname(__FILE__)+'/config/boot.rb'
|
11
12
|
require MERB_FRAMEWORK_ROOT+'/tasks'
|
@@ -56,6 +57,18 @@ Spec::Rake::SpecTask.new('specs') do |t|
|
|
56
57
|
t.spec_files = Dir['spec/**/*_spec.rb'].sort
|
57
58
|
end
|
58
59
|
|
60
|
+
desc "Run all model specs"
|
61
|
+
Spec::Rake::SpecTask.new('model_specs') do |t|
|
62
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
63
|
+
t.spec_files = Dir['spec/models/**/*_spec.rb'].sort
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Run all controller specs"
|
67
|
+
Spec::Rake::SpecTask.new('controller_specs') do |t|
|
68
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
69
|
+
t.spec_files = Dir['spec/controllers/**/*_spec.rb'].sort
|
70
|
+
end
|
71
|
+
|
59
72
|
desc "Run a specific spec with TASK=xxxx"
|
60
73
|
Spec::Rake::SpecTask.new('spec') do |t|
|
61
74
|
t.spec_opts = ["--format", "specdoc", "--colour"]
|
@@ -105,6 +105,10 @@
|
|
105
105
|
font-weight:bold;
|
106
106
|
color:#00BF10;
|
107
107
|
}
|
108
|
+
table.trace tr td.code a {
|
109
|
+
width: 20px;
|
110
|
+
float: left;
|
111
|
+
}
|
108
112
|
table.trace tr td.code .more {
|
109
113
|
color:#666;
|
110
114
|
}
|
@@ -164,17 +168,22 @@
|
|
164
168
|
<td class="expand">
|
165
169
|
</td>
|
166
170
|
<td class="path">
|
167
|
-
<%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
|
171
|
+
<%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
|
172
|
+
<% unless line.match(/\.erb:/) %>
|
173
|
+
in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>"
|
174
|
+
<% else %>
|
175
|
+
(<strong>ERB Template</strong>)
|
176
|
+
<% end %>
|
168
177
|
</td>
|
169
178
|
<td class="line">
|
170
|
-
<a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a
|
179
|
+
<a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a>
|
171
180
|
</td>
|
172
181
|
</tr>
|
173
182
|
<tr class="source">
|
174
183
|
<td class="collapse">
|
175
184
|
</td>
|
176
185
|
<td class="code" colspan="2"><% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %>
|
177
|
-
<a href="txmt://open?url=file://<%=file%>&line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? lcode[0..90]+'<span class="more">......</span>' : lcode %><%='</em>' if llineno==lineno.to_i %>
|
186
|
+
<a href="txmt://open?url=file://<%=file%>&line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%='</em>' if llineno==lineno.to_i %>
|
178
187
|
<% end %>
|
179
188
|
|
180
189
|
</td>
|
@@ -32,6 +32,11 @@
|
|
32
32
|
# automatically in production mode.
|
33
33
|
#:cache_templates: true
|
34
34
|
|
35
|
+
# this is true if you want mongrel to emulate the X-Sendfile header internally,
|
36
|
+
# false if you want it to fall thru to apache or whatever front end server you use.
|
37
|
+
# true by default
|
38
|
+
#:mongrel_x_sendfile: false
|
39
|
+
|
35
40
|
# Uncomment and set this if you want to run a drb server for upload progress
|
36
41
|
# or other drb services.
|
37
42
|
#:drb_server_port: 32323
|
@@ -61,4 +66,12 @@
|
|
61
66
|
# It is often useful to use a differant layout from 'application' for errors
|
62
67
|
# set this to the layout template (or :none) that you want to use by default
|
63
68
|
#:exception_layout: :none
|
64
|
-
|
69
|
+
|
70
|
+
# You can override settings for specific environments by creating a yaml
|
71
|
+
# file for that environment in config/environments. For example, to
|
72
|
+
# change the configuration only for development create
|
73
|
+
# config/environments/development.yml
|
74
|
+
|
75
|
+
# If you don't intend to parse JSON, use ActiveSupport, or want to roll your own
|
76
|
+
# set this to true, to disable the loading of the JSON gem
|
77
|
+
# :disable_json_gem: true
|
@@ -6,4 +6,10 @@ require File.join(MERB_ROOT, 'config', 'merb_init')
|
|
6
6
|
require 'merb/test/helper'
|
7
7
|
require 'merb/test/rspec'
|
8
8
|
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
config.include(Merb::Test::Helper)
|
11
|
+
config.include(Merb::Test::RspecMatchers)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
9
15
|
### METHODS BELOW THIS LINE SHOULD BE EXTRACTED TO MERB ITSELF
|
data/lib/merb.rb
CHANGED
@@ -15,25 +15,28 @@ elsif ENV['EVENT']
|
|
15
15
|
require 'mongrel'
|
16
16
|
puts "EVENT variable set but swiftiply not installed - falling back to normal Mongrel"
|
17
17
|
end
|
18
|
+
elsif ENV['PACKET']
|
19
|
+
begin
|
20
|
+
require 'packet_mongrel'
|
21
|
+
puts "Using Packet Mongrel"
|
22
|
+
rescue LoadError
|
23
|
+
require 'mongrel'
|
24
|
+
puts "PACKET variable set but packet not installed - falling back to normal Mongrel"
|
25
|
+
end
|
18
26
|
else
|
19
27
|
require 'mongrel'
|
20
28
|
end
|
21
29
|
require 'fileutils'
|
22
30
|
require 'merb/erubis_ext'
|
23
31
|
require 'merb/logger'
|
24
|
-
begin
|
25
|
-
require 'json/ext'
|
26
|
-
rescue LoadError
|
27
|
-
puts "Using pure ruby JSON lib"
|
28
|
-
require 'json/pure'
|
29
|
-
end
|
30
32
|
|
31
33
|
require 'set'
|
32
34
|
autoload :MerbUploadHandler, 'merb/upload_handler'
|
33
35
|
autoload :MerbHandler, 'merb/mongrel_handler'
|
34
36
|
|
37
|
+
require 'merb/version'
|
38
|
+
|
35
39
|
module Merb
|
36
|
-
VERSION='0.4.1' unless defined?(::Merb::VERSION)
|
37
40
|
autoload :Authentication, 'merb/mixins/basic_authentication'
|
38
41
|
autoload :ControllerMixin, 'merb/mixins/controller'
|
39
42
|
autoload :ErubisCaptureMixin, 'merb/mixins/erubis_capture'
|
@@ -42,6 +45,7 @@ module Merb
|
|
42
45
|
autoload :ResponderMixin, 'merb/mixins/responder'
|
43
46
|
autoload :ViewContextMixin, 'merb/mixins/view_context'
|
44
47
|
autoload :WebControllerMixin, 'merb/mixins/web_controller'
|
48
|
+
autoload :GeneralControllerMixin, 'merb/mixins/general_controller'
|
45
49
|
autoload :Caching, 'merb/caching'
|
46
50
|
autoload :AbstractController, 'merb/abstract_controller'
|
47
51
|
autoload :Const, 'merb/constants'
|
@@ -109,3 +113,19 @@ if $TESTING
|
|
109
113
|
test_files = File.join(lib, 'test', '*.rb')
|
110
114
|
Dir[test_files].each { |file| require file }
|
111
115
|
end
|
116
|
+
|
117
|
+
# If we're in the TEST environment or if running from Rake make sure to load
|
118
|
+
# config/merb.yml - which is normally done by Merb::Server.run
|
119
|
+
Merb::Server.load_config if $TESTING || $RAKE_ENV
|
120
|
+
|
121
|
+
# If you don't use the JSON gem, disable auto-parsing of json params too
|
122
|
+
if Merb::Server.config[:disable_json_gem]
|
123
|
+
Merb::Request::parse_json_params = false
|
124
|
+
else
|
125
|
+
begin
|
126
|
+
require 'json/ext'
|
127
|
+
rescue LoadError
|
128
|
+
puts "Using pure ruby JSON lib"
|
129
|
+
require 'json/pure'
|
130
|
+
end
|
131
|
+
end
|