merb-core 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/merb-core/autoload.rb +22 -23
- data/lib/merb-core/controller/abstract_controller.rb +578 -573
- data/lib/merb-core/controller/mixins/controller.rb +1 -1
- data/lib/merb-core/controller/template.rb +23 -21
- data/lib/merb-core/core_ext.rb +1 -0
- data/lib/merb-core/core_ext/class.rb +34 -0
- data/lib/merb-core/dispatch/request_parsers.rb +11 -0
- data/lib/merb-core/rack/middleware/profiler.rb +39 -5
- data/lib/merb-core/version.rb +1 -1
- metadata +4 -3
@@ -32,27 +32,29 @@ module Merb::Template
|
|
32
32
|
path.gsub(/[^\.a-zA-Z0-9]/, "__").gsub(/\./, "_")
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
35
|
+
chainable do
|
36
|
+
# For a given path, get an IO object that responds to #path.
|
37
|
+
#
|
38
|
+
# This is so that plugins can override this if they provide
|
39
|
+
# mechanisms for specifying templates that are not just simple
|
40
|
+
# files. The plugin is responsible for ensuring that the fake
|
41
|
+
# path provided will work with #template_for, and thus the
|
42
|
+
# RenderMixin in general.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# path<String>:: A full path to find a template for. This is the
|
46
|
+
# path that the RenderMixin assumes it should find the template
|
47
|
+
# in.
|
48
|
+
#
|
49
|
+
# ==== Returns
|
50
|
+
# IO#path:: An IO object that responds to path (File or VirtualFile).
|
51
|
+
#
|
52
|
+
# :api: plugin
|
53
|
+
# @overridable
|
54
|
+
def load_template_io(path)
|
55
|
+
file = Dir["#{path}.{#{template_extensions.join(',')}}"].first
|
56
|
+
File.open(file, "r") if file
|
57
|
+
end
|
56
58
|
end
|
57
59
|
|
58
60
|
# Get the name of the template method for a particular path.
|
data/lib/merb-core/core_ext.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Class
|
2
|
+
# Allows the definition of methods on a class that will be available via
|
3
|
+
# super.
|
4
|
+
#
|
5
|
+
# ==== Examples
|
6
|
+
# class Foo
|
7
|
+
# chainable do
|
8
|
+
# def hello
|
9
|
+
# "hello"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# class Foo
|
15
|
+
# def hello
|
16
|
+
# super + " Merb!"
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# Foo.new.hello #=> "hello Merb!"
|
21
|
+
#
|
22
|
+
# ==== Parameters
|
23
|
+
# &blk::
|
24
|
+
# a block containing method definitions that should be
|
25
|
+
# marked as chainable
|
26
|
+
#
|
27
|
+
# ==== Returns
|
28
|
+
# Module:: The anonymous module that was created
|
29
|
+
def chainable(&blk)
|
30
|
+
mod = Module.new(&blk)
|
31
|
+
include mod
|
32
|
+
mod
|
33
|
+
end
|
34
|
+
end
|
@@ -194,6 +194,17 @@ module Merb
|
|
194
194
|
}
|
195
195
|
end
|
196
196
|
|
197
|
+
# ==== Parameters
|
198
|
+
# s<String>:: String to XML escape.
|
199
|
+
#
|
200
|
+
# ==== returns
|
201
|
+
# String:: The escaped string.
|
202
|
+
#
|
203
|
+
# :api: public
|
204
|
+
def self.escape_xml(s)
|
205
|
+
Erubis::XmlHelper.escape_xml(s)
|
206
|
+
end
|
207
|
+
|
197
208
|
private
|
198
209
|
|
199
210
|
# Converts a query string snippet to a hash and adds it to existing
|
@@ -1,21 +1,55 @@
|
|
1
|
+
begin
|
2
|
+
require "ruby-prof"
|
3
|
+
rescue LoadError => e
|
4
|
+
Merb.fatal! "You need ruby-prof installed to use the profiler middleware", e
|
5
|
+
end
|
6
|
+
|
1
7
|
module Merb
|
2
8
|
module Rack
|
3
9
|
class Profiler < Merb::Rack::Middleware
|
4
10
|
|
5
11
|
# :api: private
|
6
|
-
def initialize(app,
|
12
|
+
def initialize(app, types = [RubyProf::ALLOCATIONS, RubyProf::PROCESS_TIME])
|
7
13
|
super(app)
|
8
|
-
@
|
14
|
+
@types = types
|
9
15
|
end
|
10
16
|
|
11
17
|
# :api: plugin
|
12
18
|
def call(env)
|
13
|
-
|
14
|
-
|
19
|
+
measure_names = { RubyProf::ALLOCATIONS => 'allocations',
|
20
|
+
RubyProf::PROCESS_TIME => 'time', RubyProf::MEMORY => "memory" }
|
21
|
+
|
22
|
+
ret = nil
|
23
|
+
|
24
|
+
GC.disable
|
25
|
+
@types.each do |type|
|
26
|
+
next if type.nil?
|
27
|
+
|
28
|
+
if GC.respond_to?(:enable_stats)
|
29
|
+
GC.enable_stats || GC.clear_stats
|
30
|
+
end
|
31
|
+
|
32
|
+
RubyProf.measure_mode = type
|
33
|
+
RubyProf.start
|
34
|
+
100.times do
|
35
|
+
ret = super
|
36
|
+
end
|
37
|
+
result = RubyProf.stop
|
38
|
+
printer = RubyProf::CallTreePrinter.new(result)
|
39
|
+
path = "merb_profile_results" / env["PATH_INFO"]
|
40
|
+
FileUtils.mkdir_p(path)
|
41
|
+
printer.print(
|
42
|
+
File.open(
|
43
|
+
"#{path}/callgrind.out.#{measure_names[RubyProf::measure_mode]}",
|
44
|
+
'w'))
|
45
|
+
|
46
|
+
GC.disable_stats if GC.respond_to?(:disable_stats)
|
15
47
|
end
|
48
|
+
GC.enable
|
49
|
+
ret
|
16
50
|
end
|
17
51
|
|
18
52
|
|
19
53
|
end
|
20
54
|
end
|
21
|
-
end
|
55
|
+
end
|
data/lib/merb-core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Zygmuntowicz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.9.
|
93
|
+
version: 0.9.9
|
94
94
|
version:
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: webrat
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/merb-core/controller/mixins/responder.rb
|
141
141
|
- lib/merb-core/controller/template.rb
|
142
142
|
- lib/merb-core/core_ext
|
143
|
+
- lib/merb-core/core_ext/class.rb
|
143
144
|
- lib/merb-core/core_ext/hash.rb
|
144
145
|
- lib/merb-core/core_ext/kernel.rb
|
145
146
|
- lib/merb-core/core_ext.rb
|