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
data/lib/ramaze/setup.rb
CHANGED
@@ -117,14 +117,11 @@ module Ramaze
|
|
117
117
|
|
118
118
|
log "Activating gem #{name}"
|
119
119
|
|
120
|
-
|
121
|
-
require(lib_name)
|
122
|
-
|
120
|
+
activate(name, lib_name, *version)
|
123
121
|
# Gem not installed yet
|
124
|
-
rescue LoadError
|
122
|
+
rescue Gem::LoadError
|
125
123
|
install_gem(name, options)
|
126
|
-
|
127
|
-
require(lib_name)
|
124
|
+
activate(name, lib_name, *version)
|
128
125
|
end
|
129
126
|
|
130
127
|
##
|
@@ -165,6 +162,26 @@ module Ramaze
|
|
165
162
|
|
166
163
|
private
|
167
164
|
|
165
|
+
##
|
166
|
+
# Activates a gem and requires it.
|
167
|
+
#
|
168
|
+
# @author Yorick Peterse
|
169
|
+
# @author Lee Jarvis
|
170
|
+
# @since 20-08-2011
|
171
|
+
# @param [String] name The name of the gem to activate.
|
172
|
+
# @param [String] lib_name The name of the gem as it should be required.
|
173
|
+
# @param [Array] requirements An array with additional requirements.
|
174
|
+
#
|
175
|
+
def activate(name, lib_name, *requirements)
|
176
|
+
if Gem::Specification.respond_to?(:find_by_name)
|
177
|
+
Gem::Specification.find_by_name(name, *requirements).activate
|
178
|
+
else
|
179
|
+
Gem.activate(name, *requirements)
|
180
|
+
end
|
181
|
+
|
182
|
+
require(lib_name)
|
183
|
+
end
|
184
|
+
|
168
185
|
##
|
169
186
|
# Writes the message to the logger.
|
170
187
|
#
|
@@ -3,15 +3,11 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module CoreExtensions
|
6
|
-
|
7
6
|
# Extensions for Array
|
8
|
-
|
9
7
|
module Array
|
10
|
-
|
11
8
|
# a = [1, 2, 3]
|
12
9
|
# a.put_within(4, :after => 2, :before => 3)
|
13
10
|
# a # => [1, 2, 4, 3]
|
14
|
-
|
15
11
|
def put_within(object, constrain)
|
16
12
|
pre, post = constrain.values_at(:after, :before)
|
17
13
|
|
@@ -23,7 +19,6 @@ module Ramaze
|
|
23
19
|
# a = [1, 2, 3]
|
24
20
|
# a.put_after(2, 4)
|
25
21
|
# a # => [1, 2, 4, 3]
|
26
|
-
|
27
22
|
def put_after(element, object)
|
28
23
|
return self[index(element) + 1, 0] = object if include?(element)
|
29
24
|
|
@@ -33,12 +28,11 @@ module Ramaze
|
|
33
28
|
# a = [1, 2, 3]
|
34
29
|
# a.put_before(2, 4)
|
35
30
|
# a # => [1, 4, 2, 3]
|
36
|
-
|
37
31
|
def put_before(element, object)
|
38
32
|
return self[rindex(element), 0] = object if include?(element)
|
39
33
|
|
40
34
|
raise ArgumentError, "The given element doesn't exist"
|
41
35
|
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
36
|
+
end # Array
|
37
|
+
end # CoreExtensions
|
38
|
+
end # Ramaze
|
@@ -1,17 +1,13 @@
|
|
1
1
|
module Ramaze
|
2
2
|
module CoreExtensions
|
3
|
-
|
4
3
|
# Extensions for Binding
|
5
|
-
|
6
4
|
module Binding
|
7
|
-
|
8
5
|
# Returns a hash of localvar/localvar-values from binding, useful for
|
9
6
|
# template engines that do not accept bindings and force passing locals
|
10
7
|
# via hash
|
11
8
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
9
|
+
# @example
|
10
|
+
# x = 42; p binding.locals #=> {'x'=> 42}
|
15
11
|
def locals
|
16
12
|
::Kernel::eval '
|
17
13
|
local_variables.inject({}){|h,v|
|
@@ -19,7 +15,6 @@ module Ramaze
|
|
19
15
|
h.merge!(k => eval(k))
|
20
16
|
}', self
|
21
17
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
18
|
+
end # Binding
|
19
|
+
end # CoreExtensions
|
20
|
+
end # Ramaze
|
@@ -26,7 +26,7 @@ unless defined? Fiber
|
|
26
26
|
def wait
|
27
27
|
@resume.pop
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def self.yield *args
|
31
31
|
raise FiberError, "can't yield from root fiber" unless fiber = Thread.current[:fiber]
|
32
32
|
fiber.yield.push(args)
|
@@ -39,25 +39,3 @@ unless defined? Fiber
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|
43
|
-
if __FILE__ == $0
|
44
|
-
f = Fiber.new{ puts 'hi'; p Fiber.yield(1); puts 'bye'; :done }
|
45
|
-
p f.resume
|
46
|
-
p f.resume(2)
|
47
|
-
end
|
48
|
-
|
49
|
-
__END__
|
50
|
-
|
51
|
-
$ ruby fbr.rb
|
52
|
-
hi
|
53
|
-
1
|
54
|
-
2
|
55
|
-
bye
|
56
|
-
:done
|
57
|
-
|
58
|
-
$ ruby1.9 fbr.rb
|
59
|
-
hi
|
60
|
-
1
|
61
|
-
2
|
62
|
-
bye
|
63
|
-
:done
|
@@ -5,9 +5,7 @@ require 'pp'
|
|
5
5
|
|
6
6
|
module Ramaze
|
7
7
|
module CoreExtensions
|
8
|
-
|
9
8
|
# Extensions for Kernel
|
10
|
-
|
11
9
|
module Kernel
|
12
10
|
unless defined?(pretty_inspect)
|
13
11
|
# returns a pretty printed object as a string.
|
@@ -15,7 +13,6 @@ module Ramaze
|
|
15
13
|
PP.pp(self, '')
|
16
14
|
end
|
17
15
|
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
end
|
16
|
+
end # Kernel
|
17
|
+
end # CoreExtensions
|
18
|
+
end # Ramaze
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Ramaze
|
2
2
|
module CoreExtensions
|
3
|
-
|
4
3
|
# Extensions for Numeric
|
5
|
-
|
6
4
|
module Numeric
|
7
5
|
def seconds
|
8
6
|
self
|
@@ -56,8 +54,6 @@ module Ramaze
|
|
56
54
|
t + self
|
57
55
|
end
|
58
56
|
alias since from_now
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
57
|
+
end # Numeric
|
58
|
+
end # CoreExtensions
|
59
|
+
end # Ramaze
|
@@ -3,9 +3,7 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module CoreExtensions
|
6
|
-
|
7
6
|
# Extensions for Object
|
8
|
-
|
9
7
|
module Object
|
10
8
|
unless defined?(__DIR__)
|
11
9
|
|
@@ -16,14 +14,12 @@ module Ramaze
|
|
16
14
|
# This method is convenience for the
|
17
15
|
# File.expand_path(File.dirname(__FILE__))
|
18
16
|
# idiom.
|
19
|
-
|
20
17
|
def __DIR__(*args)
|
21
18
|
filename = caller[0][/^(.*):/, 1]
|
22
19
|
dir = File.expand_path(File.dirname(filename))
|
23
20
|
::File.expand_path(::File.join(dir, *args.map{|a| a.to_s}))
|
24
21
|
end
|
25
22
|
end
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
end
|
23
|
+
end # Object
|
24
|
+
end # CoreExtensions
|
25
|
+
end # Ramaze
|
@@ -3,17 +3,14 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module CoreExtensions
|
6
|
-
|
7
6
|
# Extensions for Object
|
8
7
|
module Object
|
9
8
|
# Available in 1.8.6 and later.
|
10
|
-
|
11
9
|
unless ::Object.method_defined?(:instance_variable_defined?)
|
12
10
|
def instance_variable_defined?(variable)
|
13
11
|
instance_variables.include?(variable.to_s)
|
14
12
|
end
|
15
13
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
end
|
14
|
+
end # Object
|
15
|
+
end # CoreExtensions
|
16
|
+
end # Ramaze
|
@@ -1,16 +1,12 @@
|
|
1
1
|
module Ramaze
|
2
2
|
module CoreExtensions
|
3
|
-
|
4
3
|
# Extensions for Object
|
5
4
|
module Object
|
6
|
-
|
7
5
|
# Returns the string that #pretty_inspect would yield
|
8
|
-
|
9
6
|
def pretty s = ''
|
10
7
|
PP.pp(self, s)
|
11
8
|
s
|
12
9
|
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
end
|
10
|
+
end # Object
|
11
|
+
end # CoreExtensions
|
12
|
+
end # Ramaze
|
@@ -1,18 +1,16 @@
|
|
1
1
|
module Ramaze
|
2
2
|
module CoreExtensions
|
3
|
-
|
4
3
|
# Extensions for Object
|
5
4
|
module Object
|
6
|
-
|
7
5
|
# returns a new clean binding for this object
|
8
|
-
# usage: eval 'self', object.scope #=> returns object
|
9
6
|
#
|
10
|
-
|
7
|
+
# Usage:
|
8
|
+
#
|
9
|
+
# eval 'self', object.scope #=> returns object
|
10
|
+
#
|
11
11
|
def scope
|
12
12
|
lambda{}
|
13
13
|
end
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
14
|
+
end # Object
|
15
|
+
end # CoreExtensions
|
16
|
+
end # Ramaze
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module Ramaze
|
2
2
|
module CoreExtensions
|
3
|
-
|
4
3
|
# Extensions for Proc
|
5
|
-
|
6
4
|
module Proc
|
7
|
-
|
8
|
-
#
|
9
|
-
# engines that do not accept bindings/proc and force passing
|
10
|
-
# hash
|
11
|
-
#
|
12
|
-
|
5
|
+
##
|
6
|
+
# Returns a hash of localvar/localvar-values from proc, useful for
|
7
|
+
# template engines that do not accept bindings/proc and force passing
|
8
|
+
# locals via hash
|
9
|
+
#
|
10
|
+
# Usage:
|
11
|
+
#
|
12
|
+
# x = 42; p Proc.new.locals #=> {'x'=> 42}
|
13
|
+
#
|
13
14
|
def locals
|
14
15
|
instance_eval('binding').locals
|
15
16
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
17
|
+
end # Proc
|
18
|
+
end # CoreExtensions
|
19
|
+
end # Ramaze
|
@@ -5,22 +5,23 @@ module Ramaze
|
|
5
5
|
# Require all .rb and .so files on the given globs, utilizes Dir::[].
|
6
6
|
#
|
7
7
|
# Examples:
|
8
|
-
# # Given following directory structure:
|
9
|
-
# # src/foo.rb
|
10
|
-
# # src/bar.so
|
11
|
-
# # src/foo.yaml
|
12
|
-
# # src/foobar/baz.rb
|
13
|
-
# # src/foobar/README
|
14
8
|
#
|
15
|
-
#
|
16
|
-
#
|
9
|
+
# # Given following directory structure:
|
10
|
+
# # src/foo.rb
|
11
|
+
# # src/bar.so
|
12
|
+
# # src/foo.yaml
|
13
|
+
# # src/foobar/baz.rb
|
14
|
+
# # src/foobar/README
|
17
15
|
#
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# # requires all files in 'src':
|
17
|
+
# Ramaze.acquire 'src/*'
|
18
|
+
#
|
19
|
+
# # requires all files in 'src' recursive:
|
20
|
+
# Ramaze.acquire 'src/**/*'
|
21
|
+
#
|
22
|
+
# # require 'src/foo.rb' and 'src/bar.so' and 'src/foobar/baz.rb'
|
23
|
+
# Ramaze.acquire 'src/*', 'src/foobar/*'
|
20
24
|
#
|
21
|
-
# # require 'src/foo.rb' and 'src/bar.so' and 'src/foobar/baz.rb'
|
22
|
-
# Ramaze.acquire 'src/*', 'src/foobar/*'
|
23
|
-
|
24
25
|
def self.acquire(*globs)
|
25
26
|
globs.flatten.each do |glob|
|
26
27
|
Dir[glob].each do |file|
|
@@ -28,4 +29,4 @@ module Ramaze
|
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
31
|
-
end
|
32
|
+
end # Ramaze
|
@@ -21,7 +21,6 @@ module Ramaze
|
|
21
21
|
# Copyright (c) 2009 Michael Fellinger <manveru@rubyists.com>
|
22
22
|
#
|
23
23
|
# You may redistribute it and/or modify it under the same terms as Ruby.
|
24
|
-
|
25
24
|
class LRUHash < Struct.new(:max_total, :max_value, :max_count, :expiration,
|
26
25
|
:hook, :objs, :total_size, :list, :hits, :misses)
|
27
26
|
CacheObject = Struct.new(:content, :size, :atime)
|
@@ -244,5 +243,5 @@ module Ramaze
|
|
244
243
|
raise ArgumentError, "invalid expiration `#{expiration}'"
|
245
244
|
end
|
246
245
|
end
|
247
|
-
end
|
248
|
-
end
|
246
|
+
end # LRUHash
|
247
|
+
end # Ramaze
|
@@ -4,7 +4,6 @@
|
|
4
4
|
|
5
5
|
module Ramaze
|
6
6
|
class Struct < ::Struct
|
7
|
-
|
8
7
|
# Makes it possible to access the keys directly by their name, not only
|
9
8
|
# their index. The original Struct#values_at tries to call #to_int on the
|
10
9
|
# arguments.
|
@@ -30,7 +29,6 @@ module Ramaze
|
|
30
29
|
# # Added new behaviour:
|
31
30
|
# point.values_at(:y, :x)
|
32
31
|
# # => [10, 15]
|
33
|
-
|
34
32
|
def values_at(*keys)
|
35
33
|
keys.map do |key|
|
36
34
|
case key
|
@@ -41,5 +39,5 @@ module Ramaze
|
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
44
|
-
end
|
45
|
-
end
|
42
|
+
end # Struct
|
43
|
+
end # Ramaze
|
@@ -3,19 +3,17 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module CoreExtensions
|
6
|
-
|
7
6
|
# Extensions for String
|
8
|
-
|
9
7
|
module String
|
10
|
-
|
11
|
-
#
|
8
|
+
##
|
9
|
+
# Simple transformation to CamelCase from snake_case
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# 'foo_bar'.camel_case # => 'FooBar'
|
12
13
|
#
|
13
|
-
# 'foo_bar'.camel_case # => 'FooBar'
|
14
|
-
|
15
14
|
def camel_case
|
16
15
|
split('_').map{|e| e.capitalize}.join
|
17
16
|
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
end
|
17
|
+
end # String
|
18
|
+
end # CoreExtensions
|
19
|
+
end # Ramaze
|