manveru-ramaze 2008.08 → 2008.09
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/ramaze +1 -0
- data/doc/CHANGELOG +966 -0
- data/doc/tutorial/todolist.html +421 -313
- data/doc/tutorial/todolist.mkd +26 -9
- 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/spec/main.rb +2 -1
- data/lib/proto/start.rb +3 -3
- data/lib/ramaze.rb +6 -1
- data/lib/ramaze/action.rb +2 -2
- data/lib/ramaze/adapter.rb +0 -5
- data/lib/ramaze/adapter/base.rb +24 -7
- 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/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/resolve.rb +1 -1
- data/lib/ramaze/current.rb +60 -20
- data/lib/ramaze/current/response.rb +15 -3
- data/lib/ramaze/dispatcher.rb +9 -3
- data/lib/ramaze/dispatcher/action.rb +2 -3
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +1 -1
- data/lib/ramaze/dispatcher/file.rb +1 -1
- data/lib/ramaze/helper/formatting.rb +33 -0
- data/lib/ramaze/helper/paginate.rb +234 -0
- data/lib/ramaze/option.rb +2 -2
- data/lib/ramaze/reloader.rb +2 -2
- 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/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 -56
- 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 +4 -0
- data/lib/ramaze/snippets/proc/locals.rb +17 -9
- 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 +17 -6
- data/lib/ramaze/snippets/string/esc.rb +26 -18
- 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 -6
- data/lib/ramaze/snippets/string/unindent.rb +23 -15
- data/lib/ramaze/snippets/thread/into.rb +3 -3
- data/lib/ramaze/spec/helper/snippets.rb +8 -0
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/tool/create.rb +27 -53
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/version.rb +1 -1
- data/rake_tasks/gem.rake +2 -1
- data/rake_tasks/maintenance.rake +38 -0
- data/rake_tasks/release.rake +6 -2
- data/rake_tasks/spec.rake +1 -2
- data/ramaze.gemspec +69 -78
- data/spec/examples/simple_auth.rb +2 -2
- data/spec/examples/templates/template_haml.rb +0 -2
- data/spec/ramaze/current/session.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +2 -2
- data/spec/ramaze/helper/formatting.rb +13 -0
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/snippets/{kernel → object}/__dir__.rb +0 -0
- data/spec/snippets/{kernel → object}/acquire.rb +0 -0
- metadata +69 -78
- 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/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 -183
- 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
data/lib/ramaze/option.rb
CHANGED
@@ -73,7 +73,7 @@ module Ramaze
|
|
73
73
|
:controllers, Set.new
|
74
74
|
|
75
75
|
o "Instruction for daemonize, only works with bin/ramaze for now",
|
76
|
-
:daemonize, '
|
76
|
+
:daemonize, '', :cli => [:start, :stop]
|
77
77
|
|
78
78
|
o "Turn on customized error pages. Use Rack::ShowException otherwise.",
|
79
79
|
:error_page, true, :cli => true
|
@@ -106,7 +106,7 @@ module Ramaze
|
|
106
106
|
:middleware, true
|
107
107
|
|
108
108
|
o "For your own modes to decide on",
|
109
|
-
:mode, :live, :cli => [:live, :dev]
|
109
|
+
:mode, :live, :cli => [:live, :dev, :spec]
|
110
110
|
|
111
111
|
o "The place ramaze was started from, useful mostly for debugging",
|
112
112
|
:origin, :main
|
data/lib/ramaze/reloader.rb
CHANGED
@@ -106,7 +106,7 @@ module Ramaze
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def rotation
|
109
|
-
files = [$0, *$LOADED_FEATURES].uniq
|
109
|
+
files = [$0, __FILE__, *$LOADED_FEATURES].uniq
|
110
110
|
paths = ['./', *$LOAD_PATH].uniq
|
111
111
|
|
112
112
|
files.each do |file|
|
@@ -117,7 +117,7 @@ module Ramaze
|
|
117
117
|
@cache[file] = path
|
118
118
|
yield(path, stat)
|
119
119
|
else
|
120
|
-
|
120
|
+
# Quite harmless, we just couldn't figure out path for #{file}
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
data/lib/ramaze/snippets.rb
CHANGED
@@ -7,3 +7,16 @@ glob = File.join(dir, '**', '*.rb')
|
|
7
7
|
Dir[glob].each do |snippet|
|
8
8
|
require(snippet)
|
9
9
|
end
|
10
|
+
|
11
|
+
Ramaze::CoreExtensions.constants.each do |const|
|
12
|
+
ext = Ramaze::CoreExtensions.const_get(const)
|
13
|
+
into = Module.const_get(const)
|
14
|
+
|
15
|
+
collisions = ext.instance_methods & into.instance_methods
|
16
|
+
|
17
|
+
if collisions.empty?
|
18
|
+
into.__send__(:include, ext)
|
19
|
+
else
|
20
|
+
warn "Won't include %p with %p, %p exists" % [into, ext, collisions]
|
21
|
+
end
|
22
|
+
end
|
@@ -1,37 +1,44 @@
|
|
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
|
-
|
4
|
+
module Ramaze
|
5
|
+
module CoreExtensions
|
5
6
|
|
6
|
-
|
7
|
-
# a.put_within(4, :after => 2, :before => 3)
|
8
|
-
# a # => [1, 2, 4, 3]
|
7
|
+
# Extensions for Array
|
9
8
|
|
10
|
-
|
11
|
-
pre, post = constrain.values_at(:after, :before)
|
9
|
+
module Array
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
# a = [1, 2, 3]
|
12
|
+
# a.put_within(4, :after => 2, :before => 3)
|
13
|
+
# a # => [1, 2, 4, 3]
|
16
14
|
|
17
|
-
|
18
|
-
|
15
|
+
def put_within(object, constrain)
|
16
|
+
pre, post = constrain.values_at(:after, :before)
|
19
17
|
|
20
|
-
|
21
|
-
# a.put_after(2, 4)
|
22
|
-
# a # => [1, 2, 4, 3]
|
18
|
+
return put_after(pre, object) if rindex(post) - index(pre) == 1
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
raise ArgumentError, "Too many elements within constrain"
|
21
|
+
end
|
22
|
+
|
23
|
+
# a = [1, 2, 3]
|
24
|
+
# a.put_after(2, 4)
|
25
|
+
# a # => [1, 2, 4, 3]
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
# a # => [1, 4, 2, 3]
|
27
|
+
def put_after(element, object)
|
28
|
+
return self[index(element) + 1, 0] = object if include?(element)
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
raise ArgumentError, "The given element doesn't exist"
|
31
|
+
end
|
32
|
+
|
33
|
+
# a = [1, 2, 3]
|
34
|
+
# a.put_before(2, 4)
|
35
|
+
# a # => [1, 4, 2, 3]
|
36
|
+
|
37
|
+
def put_before(element, object)
|
38
|
+
return self[rindex(element), 0] = object if include?(element)
|
39
|
+
|
40
|
+
raise ArgumentError, "The given element doesn't exist"
|
41
|
+
end
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
@@ -1,13 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def locals
|
8
|
-
Kernel::eval '
|
9
|
-
local_variables.inject({}){|h,v| k = v.to_s; h.merge!(k => eval(k)) }
|
10
|
-
', self
|
11
|
-
end
|
1
|
+
module Ramaze
|
2
|
+
module CoreExtensions
|
3
|
+
|
4
|
+
# Extensions for Binding
|
5
|
+
|
6
|
+
module Binding
|
12
7
|
|
8
|
+
# Returns a hash of localvar/localvar-values from binding, useful for
|
9
|
+
# template engines that do not accept bindings and force passing locals
|
10
|
+
# via hash
|
11
|
+
#
|
12
|
+
# Usage:
|
13
|
+
# x = 42; p binding.locals #=> {'x'=> 42}
|
14
|
+
|
15
|
+
def locals
|
16
|
+
::Kernel::eval '
|
17
|
+
local_variables.inject({}){|h,v|
|
18
|
+
k = v.to_s
|
19
|
+
h.merge!(k => eval(k))
|
20
|
+
}', self
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
@@ -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
|
@@ -1,56 +1,63 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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
|