ramaze 2008.06 → 2008.11
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/README.markdown +6 -6
- data/Rakefile +33 -3
- data/bin/ramaze +18 -0
- data/doc/CHANGELOG +960 -0
- data/doc/LEGAL +5 -1
- data/doc/meta/announcement.txt +20 -36
- data/doc/tutorial/todolist.html +421 -313
- data/doc/tutorial/todolist.mkd +33 -16
- data/examples/app/blog/spec/blog.rb +3 -3
- data/examples/app/rapaste/controller/paste.rb +8 -1
- data/examples/app/rapaste/model/paste.rb +3 -0
- data/examples/app/rapaste/spec/rapaste.rb +3 -1
- data/examples/app/rapaste/start.rb +3 -2
- data/examples/app/sourceview/public/sourceview.js +2 -2
- data/examples/app/todolist/spec/todolist.rb +6 -6
- data/examples/app/todolist/template/index.xhtml +1 -1
- data/examples/app/whywiki/spec/whywiki.rb +2 -2
- data/examples/app/wikore/spec/wikore.rb +2 -2
- data/examples/app/wikore/src/model.rb +4 -3
- data/examples/app/wiktacular/spec/wiktacular.rb +7 -7
- data/examples/basic/simple.rb +2 -2
- data/examples/helpers/paginate.rb +71 -0
- data/examples/misc/simple_auth.rb +20 -8
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +1 -3
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/dispatch.fcgi +1 -1
- data/lib/proto/spec/main.rb +2 -1
- data/lib/proto/start.rb +3 -3
- data/lib/proto/start.ru +1 -1
- data/lib/proto/view/error.xhtml +4 -4
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action.rb +6 -6
- data/lib/ramaze/adapter.rb +1 -6
- data/lib/ramaze/adapter/base.rb +30 -27
- data/lib/ramaze/adapter/cgi.rb +1 -0
- data/lib/ramaze/cache.rb +1 -3
- data/lib/ramaze/cache/memcached.rb +3 -5
- data/lib/ramaze/contrib/auto_params.rb +2 -2
- data/lib/ramaze/contrib/auto_params/get_args.rb +2 -1
- data/lib/ramaze/contrib/gems.rb +17 -18
- data/lib/ramaze/contrib/gzip_filter.rb +22 -9
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +1 -1
- data/lib/ramaze/contrib/rest.rb +16 -13
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/controller.rb +33 -34
- data/lib/ramaze/controller/resolve.rb +29 -9
- data/lib/ramaze/current.rb +60 -20
- data/lib/ramaze/current/request.rb +8 -7
- data/lib/ramaze/current/response.rb +15 -3
- data/lib/ramaze/current/session/flash.rb +8 -0
- data/lib/ramaze/dispatcher.rb +17 -9
- data/lib/ramaze/dispatcher/action.rb +4 -5
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +4 -4
- data/lib/ramaze/dispatcher/file.rb +4 -4
- data/lib/ramaze/gestalt.rb +15 -20
- data/lib/ramaze/helper/cgi.rb +7 -15
- data/lib/ramaze/helper/formatting.rb +41 -1
- data/lib/ramaze/helper/httpdigest.rb +20 -7
- data/lib/ramaze/helper/link.rb +4 -6
- data/lib/ramaze/helper/paginate.rb +233 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/helper/rest.rb +1 -1
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +4 -9
- data/lib/ramaze/log.rb +2 -2
- data/lib/ramaze/log/analogger.rb +21 -23
- data/lib/ramaze/log/growl.rb +21 -23
- data/lib/ramaze/log/hub.rb +1 -1
- data/lib/ramaze/log/informer.rb +97 -99
- data/lib/ramaze/log/knotify.rb +14 -16
- data/lib/ramaze/log/logger.rb +11 -13
- data/lib/ramaze/log/logging.rb +61 -63
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/log/syslog.rb +41 -31
- data/lib/ramaze/log/xosd.rb +70 -72
- data/lib/ramaze/option.rb +9 -6
- data/lib/ramaze/option/holder.rb +5 -27
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/setup.rb +1 -1
- data/lib/ramaze/snippets.rb +13 -0
- data/lib/ramaze/snippets/array/put_within.rb +31 -24
- data/lib/ramaze/snippets/binding/locals.rb +23 -11
- data/lib/ramaze/snippets/dictionary.rb +2 -2
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +36 -21
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +12 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +24 -17
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/acquire.rb +40 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +16 -5
- data/lib/ramaze/snippets/object/pretty.rb +14 -4
- data/lib/ramaze/snippets/object/scope.rb +14 -7
- data/lib/ramaze/snippets/ordered_set.rb +25 -14
- data/lib/ramaze/snippets/proc/locals.rb +17 -9
- data/lib/ramaze/snippets/ramaze/deprecated.rb +13 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +13 -8
- data/lib/ramaze/snippets/string/color.rb +24 -20
- data/lib/ramaze/snippets/string/each.rb +14 -3
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +26 -21
- data/lib/ramaze/snippets/string/ord.rb +12 -6
- data/lib/ramaze/snippets/string/snake_case.rb +13 -7
- data/lib/ramaze/snippets/string/start_with.rb +16 -5
- data/lib/ramaze/snippets/string/unindent.rb +23 -15
- data/lib/ramaze/snippets/thread/into.rb +3 -3
- data/lib/ramaze/spec/helper/bacon.rb +5 -5
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +2 -2
- data/lib/ramaze/spec/helper/snippets.rb +8 -0
- data/lib/ramaze/template.rb +4 -1
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/tagz.rb +2 -2
- data/lib/ramaze/template/xslt.rb +2 -2
- data/lib/ramaze/tool/create.rb +27 -53
- data/lib/ramaze/tool/localize.rb +8 -4
- data/lib/ramaze/tool/mime.rb +11 -1
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/trinity.rb +4 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/gem.rake +10 -1
- data/rake_tasks/maintenance.rake +40 -2
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +17 -4
- data/rake_tasks/spec.rake +1 -2
- data/ramaze.gemspec +549 -495
- data/spec/contrib/auto_params.rb +3 -3
- data/spec/contrib/profiling.rb +2 -2
- data/spec/examples/simple_auth.rb +2 -2
- data/spec/examples/templates/template_haml.rb +0 -2
- data/spec/ramaze/action/file_cache.rb +22 -0
- data/spec/ramaze/adapter.rb +2 -2
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/subclass.rb +15 -0
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/current/session.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +2 -2
- data/spec/ramaze/helper/aspect.rb +26 -17
- data/spec/ramaze/helper/formatting.rb +13 -0
- data/spec/ramaze/log/informer.rb +10 -10
- data/spec/ramaze/log/syslog.rb +67 -4
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/route.rb +1 -1
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/tagz.rb +1 -1
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/{kernel → object}/__dir__.rb +0 -0
- data/spec/snippets/{kernel → object}/acquire.rb +0 -0
- metadata +90 -81
- data/cache.yaml +0 -7
- data/examples/app/rammit/spec/rammit.rb +0 -31
- data/examples/app/rammit/src/controller/main.rb +0 -3
- data/examples/app/rammit/src/controller/page.rb +0 -16
- data/examples/app/rammit/src/model.rb +0 -33
- data/examples/app/rammit/start.rb +0 -8
- data/examples/app/rammit/template/index.xhtml +0 -14
- data/examples/app/rammit/template/page/view.xhtml +0 -4
- data/lib/ramaze/snippets/kernel/__dir__.rb +0 -23
- data/lib/ramaze/snippets/kernel/acquire.rb +0 -34
- data/lib/ramaze/snippets/object/thread_accessor.rb +0 -5
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +0 -58
- data/lib/ramaze/snippets/struct/fill.rb +0 -23
- data/lib/ramaze/snippets/struct/values_at.rb +0 -39
- data/lib/ramaze/snippets/symbol/to_proc.rb +0 -24
- data/lib/ramaze/sourcereload.rb +0 -176
- data/spec/snippets/struct/fill.rb +0 -26
- data/spec/snippets/struct/values_at.rb +0 -52
- data/spec/snippets/symbol/to_proc.rb +0 -13
@@ -1,26 +1,41 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for Kernel
|
8
|
+
|
9
|
+
module Object
|
10
|
+
|
11
|
+
# Original from Trans (Facets 1.4.5)
|
12
|
+
# This is similar to +Module#const_get+ but is accessible at all levels,
|
13
|
+
# and, unlike +const_get+, can handle module hierarchy.
|
14
|
+
#
|
15
|
+
# constant("Fixnum") # -> Fixnum
|
16
|
+
# constant(:Fixnum) # -> Fixnum
|
17
|
+
#
|
18
|
+
# constant("Process::Sys") # -> Process::Sys
|
19
|
+
# constant("Regexp::MULTILINE") # -> 4
|
20
|
+
#
|
21
|
+
# require 'test/unit'
|
22
|
+
# Test.constant("Unit::Assertions") # -> Test::Unit::Assertions
|
23
|
+
# Test.constant("::Test::Unit") # -> Test::Unit
|
24
|
+
|
25
|
+
def constant(const)
|
26
|
+
const = const.to_s.dup
|
27
|
+
|
28
|
+
if const.sub!(/^::/, '')
|
29
|
+
base = Object
|
30
|
+
elsif self.kind_of?(Module)
|
31
|
+
base = self
|
32
|
+
else
|
33
|
+
base = self.class
|
34
|
+
end
|
35
|
+
|
36
|
+
const.split(/::/).inject(base){ |mod, name| mod.const_get(name) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
25
40
|
end
|
26
41
|
end
|
@@ -3,13 +3,19 @@
|
|
3
3
|
|
4
4
|
require 'pp'
|
5
5
|
|
6
|
-
|
6
|
+
module Ramaze
|
7
|
+
module CoreExtensions
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# Extensions for Kernel
|
10
|
+
|
11
|
+
module Kernel
|
12
|
+
unless defined?(pretty_inspect)
|
13
|
+
# returns a pretty printed object as a string.
|
14
|
+
def pretty_inspect
|
15
|
+
PP.pp(self, '')
|
16
|
+
end
|
17
|
+
end
|
13
18
|
end
|
19
|
+
|
14
20
|
end
|
15
21
|
end
|
@@ -1,25 +1,32 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
['%.1fT', 1 << 40],
|
7
|
-
['%.1fG', 1 << 30],
|
8
|
-
['%.1fM', 1 << 20],
|
9
|
-
['%.1fK', 1 << 10],
|
10
|
-
]
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
7
|
+
# Extensions for Numeric
|
8
|
+
module Numeric
|
9
|
+
FILESIZE_FORMAT = [
|
10
|
+
['%.1fT', 1 << 40],
|
11
|
+
['%.1fG', 1 << 30],
|
12
|
+
['%.1fM', 1 << 20],
|
13
|
+
['%.1fK', 1 << 10],
|
14
|
+
]
|
15
|
+
|
16
|
+
# Output this number as easily readable filesize.
|
17
|
+
# Usage:
|
18
|
+
# 100_000.filesize_format # => "97.7K"
|
19
|
+
# 100_000_000.filesize_format # => "95.4M"
|
20
|
+
# 100_000_000_000.filesize_format # => "93.1G"
|
21
|
+
# 100_000_000_000_000.filesize_format # => "90.9T"
|
22
|
+
def filesize_format
|
23
|
+
FILESIZE_FORMAT.each do |format, size|
|
24
|
+
return format % (self.to_f / size) if self >= size
|
25
|
+
end
|
26
|
+
|
27
|
+
self.to_s
|
28
|
+
end
|
21
29
|
end
|
22
30
|
|
23
|
-
self.to_s
|
24
31
|
end
|
25
32
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
3
|
+
|
4
|
+
# Extensions for Numeric
|
5
|
+
|
6
|
+
module Numeric
|
7
|
+
def seconds
|
8
|
+
self
|
9
|
+
end
|
10
|
+
alias second seconds
|
11
|
+
|
12
|
+
# 60 seconds in a minute
|
13
|
+
def minutes
|
14
|
+
self * 60
|
15
|
+
end
|
16
|
+
alias minute minutes
|
17
|
+
|
18
|
+
# 60 minutes in an hour
|
19
|
+
def hours
|
20
|
+
self * 3600
|
21
|
+
end
|
22
|
+
alias hour hours
|
23
|
+
|
24
|
+
# 24 hours in a day
|
25
|
+
def days
|
26
|
+
self * 86400
|
27
|
+
end
|
28
|
+
alias day days
|
29
|
+
|
30
|
+
# 7 days in a week
|
31
|
+
def weeks
|
32
|
+
self * 604800
|
33
|
+
end
|
34
|
+
alias week weeks
|
35
|
+
|
36
|
+
# 30 days in a month
|
37
|
+
def months
|
38
|
+
self * 2592000
|
39
|
+
end
|
40
|
+
alias month months
|
41
|
+
|
42
|
+
# 365.25 days in a year
|
43
|
+
def years
|
44
|
+
self * 883612800
|
45
|
+
end
|
46
|
+
alias year years
|
47
|
+
|
48
|
+
# Time in the past, i.e. 3.days.ago
|
49
|
+
def ago t = Time.now
|
50
|
+
t - self
|
51
|
+
end
|
52
|
+
alias before ago
|
53
|
+
|
54
|
+
# Time in the future, i.e. 3.days.from_now
|
55
|
+
def from_now t = Time.now
|
56
|
+
t + self
|
57
|
+
end
|
58
|
+
alias since from_now
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for Object
|
8
|
+
|
9
|
+
module Object
|
10
|
+
unless defined?(__DIR__)
|
11
|
+
|
12
|
+
# This is similar to +__FILE__+ and +__LINE__+, and returns a String
|
13
|
+
# representing the directory of the current file is.
|
14
|
+
# Unlike +__FILE__+ the path returned is absolute.
|
15
|
+
#
|
16
|
+
# This method is convenience for the
|
17
|
+
# File.expand_path(File.dirname(__FILE__))
|
18
|
+
# idiom.
|
19
|
+
#
|
20
|
+
|
21
|
+
def __DIR__()
|
22
|
+
filename = caller[0][/^(.*):/, 1]
|
23
|
+
File.expand_path(File.dirname(filename))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for Kernel
|
8
|
+
|
9
|
+
module Object
|
10
|
+
|
11
|
+
# Require all .rb and .so files on the given globs, utilizes Dir::[].
|
12
|
+
#
|
13
|
+
# Examples:
|
14
|
+
# # Given following directory structure:
|
15
|
+
# # src/foo.rb
|
16
|
+
# # src/bar.so
|
17
|
+
# # src/foo.yaml
|
18
|
+
# # src/foobar/baz.rb
|
19
|
+
# # src/foobar/README
|
20
|
+
#
|
21
|
+
# # requires all files in 'src':
|
22
|
+
# acquire 'src/*'
|
23
|
+
#
|
24
|
+
# # requires all files in 'src' recursive:
|
25
|
+
# acquire 'src/**/*'
|
26
|
+
#
|
27
|
+
# # require 'src/foo.rb' and 'src/bar.so' and 'src/foobar/baz.rb'
|
28
|
+
# acquire 'src/*', 'src/foobar/*'
|
29
|
+
|
30
|
+
def acquire *globs
|
31
|
+
globs.flatten.each do |glob|
|
32
|
+
Dir[glob].each do |file|
|
33
|
+
require file if file =~ /\.(rb|so)$/
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -1,8 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
6
|
+
|
7
|
+
# Extensions for Object
|
8
|
+
module Object
|
9
|
+
# Available in 1.8.6 and later.
|
10
|
+
|
11
|
+
unless ::Object.method_defined?(:instance_variable_defined?)
|
12
|
+
def instance_variable_defined?(variable)
|
13
|
+
instance_variables.include?(variable.to_s)
|
14
|
+
end
|
15
|
+
end
|
6
16
|
end
|
17
|
+
|
7
18
|
end
|
8
19
|
end
|
@@ -1,6 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
3
|
+
|
4
|
+
# Extensions for Object
|
5
|
+
module Object
|
6
|
+
|
7
|
+
# Returns the string that #pretty_inspect would yield
|
8
|
+
|
9
|
+
def pretty s = ''
|
10
|
+
PP.pp(self, s)
|
11
|
+
s
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
end
|
6
16
|
end
|
@@ -1,11 +1,18 @@
|
|
1
|
-
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
4
|
+
# Extensions for Object
|
5
|
+
module Object
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
# returns a new clean binding for this object
|
8
|
+
# usage: eval 'self', object.scope #=> returns object
|
9
|
+
#
|
10
|
+
|
11
|
+
def scope
|
12
|
+
lambda{}
|
13
|
+
end
|
10
14
|
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
11
18
|
end
|
@@ -5,6 +5,10 @@ require(File.join(File.dirname(__FILE__), 'blankslate'))
|
|
5
5
|
|
6
6
|
# Basically an Set, but with Order, ain't that obivous?
|
7
7
|
class OrderedSet < BlankSlate
|
8
|
+
def self.[](*args)
|
9
|
+
new(*args)
|
10
|
+
end
|
11
|
+
|
8
12
|
# Create new instances, optionally pass the first set
|
9
13
|
def initialize(*args)
|
10
14
|
if args.size == 1
|
@@ -18,23 +22,30 @@ class OrderedSet < BlankSlate
|
|
18
22
|
@set.uniq!
|
19
23
|
end
|
20
24
|
|
25
|
+
%w[ push unshift << ].each do |meth|
|
26
|
+
class_eval %[
|
27
|
+
def #{meth} *args
|
28
|
+
@set.delete(*args)
|
29
|
+
@set.#{meth}(*args)
|
30
|
+
end
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
34
|
+
def []= *args
|
35
|
+
@set.map! do |e|
|
36
|
+
if ::Array === args.last
|
37
|
+
args.last.include?(e) ? nil : e
|
38
|
+
else
|
39
|
+
args.last == e ? nil : e
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@set.__send__(:[]=, *args)
|
43
|
+
@set.compact!
|
44
|
+
end
|
45
|
+
|
21
46
|
# Delegate everything, but controlled, keep elements unique.
|
22
47
|
# Warning, this is not really atomic.
|
23
48
|
def method_missing(meth, *args, &block)
|
24
|
-
case meth.to_s
|
25
|
-
when /push|unshift|\<\</
|
26
|
-
@set.delete(*args)
|
27
|
-
when '[]='
|
28
|
-
@set.map! do |e|
|
29
|
-
if ::Array === args.last
|
30
|
-
args.last.include?(e) ? nil : e
|
31
|
-
else
|
32
|
-
args.last == e ? nil : e
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
49
|
@set.__send__(meth, *args, &block)
|
37
|
-
ensure
|
38
|
-
@set.compact! if meth == :[]=
|
39
50
|
end
|
40
51
|
end
|
@@ -1,11 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def locals
|
8
|
-
instance_eval('binding').locals
|
9
|
-
end
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
3
|
+
|
4
|
+
# Extensions for Proc
|
5
|
+
|
6
|
+
module Proc
|
10
7
|
|
8
|
+
# returns a hash of localvar/localvar-values from proc, useful for template
|
9
|
+
# engines that do not accept bindings/proc and force passing locals via
|
10
|
+
# hash
|
11
|
+
# usage: x = 42; p Proc.new.locals #=> {'x'=> 42}
|
12
|
+
|
13
|
+
def locals
|
14
|
+
instance_eval('binding').locals
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
11
19
|
end
|
@@ -1,7 +1,20 @@
|
|
1
1
|
module Ramaze
|
2
|
+
DEPRECATED_CONSTANTS = {
|
3
|
+
:ThreadAccessor => :StateAccessor
|
4
|
+
}
|
5
|
+
|
2
6
|
def self.deprecated(from, to = nil)
|
3
7
|
message = "%s is deprecated"
|
4
8
|
message << ", use %s instead" unless to.nil?
|
5
9
|
Log.warn(message % [from, to])
|
6
10
|
end
|
11
|
+
|
12
|
+
def self.const_missing(name)
|
13
|
+
if to = DEPRECATED_CONSTANTS[name]
|
14
|
+
Log.warn "Ramaze::#{name} is deprecated, use #{to} instead"
|
15
|
+
constant(to)
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
7
20
|
end
|