ramaze 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +20 -3
- data/bin/ramaze +1 -4
- data/doc/AUTHORS +2 -1
- data/doc/CHANGELOG +539 -32
- data/doc/LEGAL +4 -0
- data/doc/meta/announcement.txt +79 -47
- data/examples/blog/README +2 -2
- data/examples/blog/spec/blog.rb +33 -48
- data/examples/blog/src/controller.rb +15 -13
- data/examples/blog/src/model.rb +28 -10
- data/examples/blog/start.rb +0 -10
- data/examples/blog/template/edit.xhtml +1 -1
- data/examples/blog/template/index.xhtml +2 -2
- data/examples/facebook.rb +152 -0
- data/examples/linking.rb +28 -0
- data/examples/ramaise.rb +4 -11
- data/examples/rammit/spec/rammit.rb +30 -0
- data/examples/rammit/src/controller/main.rb +3 -0
- data/examples/rammit/src/controller/page.rb +16 -0
- data/examples/rammit/src/model.rb +33 -0
- data/examples/rammit/start.rb +7 -0
- data/examples/rammit/template/index.xhtml +14 -0
- data/examples/rammit/template/page/view.xhtml +4 -0
- data/examples/rapaste/Rakefile +28 -0
- data/examples/rapaste/public/css/active4d.css +114 -0
- data/examples/rapaste/public/css/all_hallows_eve.css +72 -0
- data/examples/rapaste/public/css/amy.css +147 -0
- data/examples/rapaste/public/css/blackboard.css +88 -0
- data/examples/rapaste/public/css/brilliance_black.css +605 -0
- data/examples/rapaste/public/css/brilliance_dull.css +599 -0
- data/examples/rapaste/public/css/cobalt.css +149 -0
- data/examples/rapaste/public/css/dawn.css +121 -0
- data/examples/rapaste/public/css/display.css +179 -0
- data/examples/rapaste/public/css/eiffel.css +121 -0
- data/examples/rapaste/public/css/espresso_libre.css +109 -0
- data/examples/rapaste/public/css/idle.css +62 -0
- data/examples/rapaste/public/css/iplastic.css +80 -0
- data/examples/rapaste/public/css/lazy.css +73 -0
- data/examples/rapaste/public/css/mac_classic.css +123 -0
- data/examples/rapaste/public/css/magicwb_amiga.css +104 -0
- data/examples/rapaste/public/css/pastels_on_dark.css +188 -0
- data/examples/rapaste/public/css/slush_poppies.css +85 -0
- data/examples/rapaste/public/css/spacecadet.css +51 -0
- data/examples/rapaste/public/css/sunburst.css +180 -0
- data/examples/rapaste/public/css/twilight.css +137 -0
- data/examples/rapaste/public/css/zenburnesque.css +91 -0
- data/examples/rapaste/public/js/jquery.js +11 -0
- data/examples/rapaste/rapaste.sqlite +0 -0
- data/examples/rapaste/spec/rapaste.rb +49 -0
- data/examples/rapaste/src/controller.rb +69 -0
- data/examples/rapaste/src/model.rb +61 -0
- data/examples/rapaste/start.rb +20 -0
- data/examples/rapaste/template/copy.xhtml +10 -0
- data/examples/rapaste/template/index.xhtml +9 -0
- data/examples/rapaste/template/layout.xhtml +22 -0
- data/examples/rapaste/template/list.xhtml +28 -0
- data/examples/rapaste/template/view.xhtml +37 -0
- data/examples/sourceview/sourceview.rb +3 -3
- data/examples/templates/template_amrita2.rb +1 -3
- data/examples/todolist/spec/todolist.rb +15 -18
- data/examples/whywiki/spec/whywiki.rb +15 -20
- data/examples/whywiki/start.rb +0 -1
- data/examples/wikore/spec/wikore.rb +14 -19
- data/examples/wiktacular/spec/wiktacular.rb +8 -15
- data/lib/proto/{src/controller → controller}/main.rb +4 -4
- data/lib/proto/public/css/ramaze_error.css +39 -3
- data/lib/proto/public/js/jquery.js +2039 -1020
- data/lib/proto/spec/main.rb +27 -0
- data/lib/proto/start.rb +5 -5
- data/lib/proto/view/error.xhtml +62 -0
- data/lib/proto/view/index.xhtml +34 -0
- data/lib/proto/view/page.xhtml +15 -0
- data/lib/ramaze.rb +9 -7
- data/lib/ramaze/action.rb +7 -3
- data/lib/ramaze/action/render.rb +15 -5
- data/lib/ramaze/adapter.rb +5 -5
- data/lib/ramaze/adapter/base.rb +2 -2
- data/lib/ramaze/adapter/cgi.rb +1 -1
- data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
- data/lib/ramaze/adapter/fcgi.rb +2 -2
- data/lib/ramaze/adapter/mongrel.rb +1 -1
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
- data/lib/ramaze/adapter/thin.rb +25 -0
- data/lib/ramaze/adapter/webrick.rb +1 -1
- data/lib/ramaze/cache.rb +3 -2
- data/lib/ramaze/cache/memcached.rb +1 -1
- data/lib/ramaze/cache/memory.rb +1 -1
- data/lib/ramaze/cache/yaml_store.rb +1 -1
- data/lib/ramaze/contrib.rb +1 -1
- data/lib/ramaze/contrib/auto_params.rb +12 -5
- data/lib/ramaze/contrib/auto_params/get_args.rb +1 -0
- data/lib/ramaze/contrib/facebook.rb +23 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +168 -0
- data/lib/ramaze/contrib/gettext.rb +111 -0
- data/lib/ramaze/contrib/gettext/mo.rb +155 -0
- data/lib/ramaze/contrib/gettext/po.rb +109 -0
- data/lib/ramaze/contrib/gzip_filter.rb +1 -1
- data/lib/ramaze/contrib/route.rb +15 -5
- data/lib/ramaze/contrib/sequel/fill.rb +1 -1
- data/lib/ramaze/controller.rb +10 -4
- data/lib/ramaze/controller/error.rb +5 -13
- data/lib/ramaze/controller/main.rb +2 -0
- data/lib/ramaze/controller/resolve.rb +18 -10
- data/lib/ramaze/dispatcher.rb +1 -1
- data/lib/ramaze/dispatcher/action.rb +1 -1
- data/lib/ramaze/dispatcher/directory.rb +3 -2
- data/lib/ramaze/dispatcher/error.rb +5 -5
- data/lib/ramaze/dispatcher/file.rb +13 -2
- data/lib/ramaze/error.rb +1 -1
- data/lib/ramaze/gestalt.rb +2 -2
- data/lib/ramaze/global.rb +5 -5
- data/lib/ramaze/global/dsl.rb +1 -1
- data/lib/ramaze/global/globalstruct.rb +11 -5
- data/lib/ramaze/helper.rb +1 -1
- data/lib/ramaze/helper/aspect.rb +1 -1
- data/lib/ramaze/helper/auth.rb +2 -2
- data/lib/ramaze/helper/cache.rb +1 -1
- data/lib/ramaze/helper/cgi.rb +1 -1
- data/lib/ramaze/helper/file.rb +1 -1
- data/lib/ramaze/helper/flash.rb +1 -1
- data/lib/ramaze/helper/formatting.rb +1 -1
- data/lib/ramaze/helper/identity.rb +1 -1
- data/lib/ramaze/helper/inform.rb +1 -1
- data/lib/ramaze/helper/link.rb +4 -4
- data/lib/ramaze/helper/markaby.rb +1 -1
- data/lib/ramaze/helper/nitroform.rb +1 -1
- data/lib/ramaze/helper/pager.rb +2 -1
- data/lib/ramaze/helper/partial.rb +1 -1
- data/lib/ramaze/helper/redirect.rb +6 -1
- data/lib/ramaze/helper/sequel.rb +54 -0
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/inform.rb +1 -1
- data/lib/ramaze/inform/analogger.rb +1 -1
- data/lib/ramaze/inform/growl.rb +1 -1
- data/lib/ramaze/inform/hub.rb +1 -1
- data/lib/ramaze/inform/informer.rb +1 -1
- data/lib/ramaze/inform/informing.rb +2 -2
- data/lib/ramaze/inform/knotify.rb +1 -1
- data/lib/ramaze/inform/syslog.rb +1 -1
- data/lib/ramaze/inform/xosd.rb +1 -1
- data/lib/ramaze/snippets.rb +1 -1
- data/lib/ramaze/snippets/array/put_within.rb +1 -1
- data/lib/ramaze/snippets/blankslate.rb +7 -0
- data/lib/ramaze/snippets/dictionary.rb +6 -1
- data/lib/ramaze/snippets/divide.rb +1 -1
- data/lib/ramaze/snippets/kernel/__dir__.rb +1 -1
- data/lib/ramaze/snippets/kernel/acquire.rb +39 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -34
- data/lib/ramaze/snippets/kernel/constant.rb +1 -1
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +1 -1
- data/lib/ramaze/snippets/numeric/filesize_format.rb +1 -1
- data/lib/ramaze/snippets/object/traits.rb +1 -1
- data/lib/ramaze/snippets/ordered_set.rb +12 -7
- data/lib/ramaze/snippets/ramaze/caller_info.rb +1 -1
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
- data/lib/ramaze/snippets/string/camel_case.rb +1 -1
- data/lib/ramaze/snippets/string/color.rb +2 -4
- data/lib/ramaze/snippets/string/each.rb +1 -1
- data/lib/ramaze/snippets/string/ord.rb +15 -0
- data/lib/ramaze/snippets/string/snake_case.rb +1 -1
- data/lib/ramaze/snippets/struct/fill.rb +4 -2
- data/lib/ramaze/snippets/struct/values_at.rb +2 -2
- data/lib/ramaze/snippets/symbol/to_proc.rb +15 -8
- data/lib/ramaze/snippets/thread/into.rb +1 -1
- data/lib/ramaze/sourcereload.rb +4 -3
- data/lib/ramaze/spec/helper.rb +85 -32
- data/lib/ramaze/spec/helper/bacon.rb +7 -0
- data/lib/ramaze/spec/helper/browser.rb +1 -2
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +70 -0
- data/lib/ramaze/spec/helper/requester.rb +1 -1
- data/lib/ramaze/spec/helper/simple_http.rb +5 -4
- data/lib/ramaze/spec/helper/snippets.rb +6 -0
- data/lib/ramaze/store/default.rb +1 -1
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/template/amrita2.rb +6 -5
- data/lib/ramaze/template/erubis.rb +1 -1
- data/lib/ramaze/template/ezamar.rb +1 -1
- data/lib/ramaze/template/ezamar/element.rb +1 -1
- data/lib/ramaze/template/ezamar/engine.rb +1 -1
- data/lib/ramaze/template/ezamar/morpher.rb +1 -1
- data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
- data/lib/ramaze/template/haml.rb +1 -1
- data/lib/ramaze/template/liquid.rb +1 -1
- data/lib/ramaze/template/markaby.rb +1 -1
- data/lib/ramaze/template/nagoro.rb +4 -6
- data/lib/ramaze/template/none.rb +1 -1
- data/lib/ramaze/template/remarkably.rb +1 -1
- data/lib/ramaze/template/sass.rb +1 -1
- data/lib/ramaze/tool.rb +1 -1
- data/lib/ramaze/tool/create.rb +7 -1
- data/lib/ramaze/tool/localize.rb +7 -14
- data/lib/ramaze/tool/mime.rb +1 -1
- data/lib/ramaze/tool/record.rb +1 -1
- data/lib/ramaze/trinity.rb +1 -1
- data/lib/ramaze/trinity/request.rb +4 -2
- data/lib/ramaze/trinity/response.rb +1 -1
- data/lib/ramaze/trinity/session.rb +7 -1
- data/lib/ramaze/version.rb +3 -3
- data/lib/vendor/bacon.rb +317 -0
- data/rake_tasks/conf.rake +1 -1
- data/rake_tasks/maintenance.rake +7 -5
- data/rake_tasks/spec.rake +54 -40
- data/spec/contrib/auto_params.rb +21 -4
- data/spec/contrib/route.rb +31 -4
- data/spec/contrib/sequel/fill.rb +3 -4
- data/spec/examples/caching.rb +5 -2
- data/spec/examples/css.rb +5 -2
- data/spec/examples/element.rb +5 -4
- data/spec/examples/hello.rb +1 -0
- data/spec/examples/linking.rb +18 -0
- data/spec/examples/simple.rb +13 -18
- data/spec/examples/templates/template_amrita2.rb +3 -2
- data/spec/examples/templates/template_erubis.rb +3 -2
- data/spec/examples/templates/template_ezamar.rb +2 -1
- data/spec/examples/templates/template_haml.rb +3 -2
- data/spec/examples/templates/template_liquid.rb +3 -2
- data/spec/examples/templates/template_markaby.rb +3 -2
- data/spec/examples/templates/template_remarkably.rb +3 -2
- data/spec/ramaze/action/basics.rb +4 -4
- data/spec/ramaze/action/cache.rb +11 -13
- data/spec/ramaze/action/layout.rb +47 -3
- data/spec/ramaze/action/render.rb +3 -3
- data/spec/ramaze/action/template/instancevars/layout.xhtml +1 -0
- data/spec/ramaze/adapter.rb +7 -7
- data/spec/ramaze/adapter/mongrel.rb +1 -1
- data/spec/ramaze/adapter/record.rb +7 -7
- data/spec/ramaze/adapter/webrick.rb +1 -1
- data/spec/ramaze/cache.rb +6 -8
- data/spec/ramaze/controller.rb +77 -65
- data/spec/ramaze/controller/resolve.rb +2 -1
- data/spec/ramaze/controller/template_resolving.rb +3 -4
- data/spec/ramaze/dispatcher.rb +3 -4
- data/spec/ramaze/dispatcher/directory.rb +35 -35
- data/spec/ramaze/dispatcher/file.rb +8 -5
- data/spec/ramaze/element.rb +4 -4
- data/spec/ramaze/error.rb +13 -11
- data/spec/ramaze/gestalt.rb +1 -1
- data/spec/ramaze/helper/aspect.rb +2 -1
- data/spec/ramaze/helper/auth.rb +4 -2
- data/spec/ramaze/helper/cache.rb +10 -9
- data/spec/ramaze/helper/cgi.rb +2 -2
- data/spec/ramaze/helper/file.rb +1 -0
- data/spec/ramaze/helper/flash.rb +5 -4
- data/spec/ramaze/helper/formatting.rb +1 -1
- data/spec/ramaze/helper/link.rb +3 -3
- data/spec/ramaze/helper/pager.rb +44 -80
- data/spec/ramaze/helper/partial.rb +2 -3
- data/spec/ramaze/helper/redirect.rb +10 -1
- data/spec/ramaze/helper/stack.rb +4 -3
- data/spec/ramaze/helper/template/loop.xhtml +2 -1
- data/spec/ramaze/inform/informer.rb +2 -2
- data/spec/ramaze/inform/syslog.rb +1 -1
- data/spec/ramaze/localize.rb +26 -26
- data/spec/ramaze/morpher.rb +6 -7
- data/spec/ramaze/params.rb +7 -8
- data/spec/ramaze/request.rb +27 -6
- data/spec/ramaze/request/mongrel.rb +1 -1
- data/spec/ramaze/request/thin.rb +9 -0
- data/spec/ramaze/session.rb +2 -1
- data/spec/ramaze/store/default.rb +14 -17
- data/spec/ramaze/template.rb +5 -7
- data/spec/ramaze/template/amrita2.rb +4 -1
- data/spec/ramaze/template/erubis.rb +2 -1
- data/spec/ramaze/template/ezamar.rb +2 -3
- data/spec/ramaze/template/ezamar/other__index.xhtml +1 -0
- data/spec/ramaze/template/haml.rb +2 -1
- data/spec/ramaze/template/liquid.rb +4 -2
- data/spec/ramaze/template/markaby.rb +4 -2
- data/spec/ramaze/template/nagoro.rb +3 -4
- data/spec/ramaze/template/remarkably.rb +4 -2
- data/spec/ramaze/template/sass.rb +3 -2
- data/spec/ramaze/template/xslt.rb +4 -7
- data/spec/ramaze/trinity/request.rb +4 -3
- data/spec/ramaze/trinity/session.rb +6 -4
- data/spec/snippets/array/put_within.rb +3 -2
- data/spec/snippets/divide.rb +1 -4
- data/spec/snippets/kernel/__dir__.rb +1 -1
- data/spec/snippets/kernel/acquire.rb +71 -0
- data/spec/snippets/kernel/constant.rb +4 -8
- data/spec/snippets/numeric/filesize_format.rb +1 -1
- data/spec/snippets/ordered_set.rb +9 -2
- data/spec/snippets/ramaze/caller_info.rb +3 -3
- data/spec/snippets/ramaze/caller_lines.rb +3 -3
- data/spec/snippets/string/camel_case.rb +1 -1
- data/spec/snippets/string/color.rb +2 -2
- data/spec/snippets/string/snake_case.rb +5 -1
- data/spec/snippets/string/unindent.rb +1 -1
- data/spec/snippets/struct/fill.rb +14 -15
- data/spec/snippets/struct/values_at.rb +15 -10
- data/spec/snippets/symbol/to_proc.rb +13 -0
- data/spec/snippets/thread/into.rb +3 -4
- metadata +458 -386
- data/doc/README.html +0 -729
- data/doc/changes.txt +0 -5044
- data/doc/changes.xml +0 -5046
- data/lib/proto/public/error.zmr +0 -61
- data/lib/proto/src/element/page.rb +0 -17
- data/lib/proto/src/model.rb +0 -6
- data/lib/proto/template/index.xhtml +0 -15
- data/lib/ramaze/spec/helper/layout.rb +0 -58
- data/lib/ramaze/spec/helper/minimal.rb +0 -23
- data/lib/ramaze/spec/helper/wrap.rb +0 -198
- data/spec/snippets/kernel/aquire.rb +0 -71
@@ -62,7 +62,6 @@ require 'net/http'
|
|
62
62
|
require 'net/https'
|
63
63
|
require 'uri'
|
64
64
|
require 'cgi'
|
65
|
-
require 'base64'
|
66
65
|
|
67
66
|
|
68
67
|
# Wrapper around ruby's standard net/http classes. Currently, only GET
|
@@ -146,8 +145,10 @@ class SimpleHttp
|
|
146
145
|
# anything other than GET, for that matter.)
|
147
146
|
|
148
147
|
case request
|
149
|
-
when Net::HTTP::Get
|
150
|
-
|
148
|
+
when Net::HTTP::Get
|
149
|
+
sh.get
|
150
|
+
when Net::HTTP::Post
|
151
|
+
sh.post
|
151
152
|
else
|
152
153
|
raise "Not a valid HTTP method for redirection: #{request.class}"
|
153
154
|
end
|
@@ -201,7 +202,7 @@ class SimpleHttp
|
|
201
202
|
#
|
202
203
|
|
203
204
|
def basic_authentication usr, pwd
|
204
|
-
str =
|
205
|
+
str = ["#{usr}:#{pwd}"].pack("*m")
|
205
206
|
str = "Basic #{str}"
|
206
207
|
@request_headers["Authorization"]=str
|
207
208
|
end
|
data/lib/ramaze/store/default.rb
CHANGED
data/lib/ramaze/template.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
# This module serves as a namespace for all templates, it will autoload
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
require 'amrita2/template'
|
@@ -22,13 +22,14 @@ module Ramaze
|
|
22
22
|
# The parameters are set to @params in the controller before expansion.
|
23
23
|
|
24
24
|
def transform action
|
25
|
-
instance,
|
26
|
-
|
27
|
-
|
25
|
+
instance, file = action.instance, action.template
|
26
|
+
|
27
|
+
raise Ramaze::Error::NoAction,
|
28
|
+
"No Amrita2 template found for `#{action.path}' on #{action.controller}" unless file
|
28
29
|
|
29
30
|
template = ::Amrita2::TemplateFile.new(file)
|
30
31
|
out = ''
|
31
|
-
instance.instance_variable_set('@params', params)
|
32
|
+
instance.instance_variable_set('@params', action.params)
|
32
33
|
template.expand(out, instance)
|
33
34
|
out
|
34
35
|
end
|
data/lib/ramaze/template/haml.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
require 'nagoro'
|
@@ -12,9 +12,7 @@ module Ramaze
|
|
12
12
|
|
13
13
|
ENGINES[self] = %w[ xhtml nag ]
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
TEMPLATE = ::Nagoro::Template[LISTENERS]
|
15
|
+
PIPES = ::Nagoro::DEFAULT_PIPES.dup
|
18
16
|
|
19
17
|
class << self
|
20
18
|
|
@@ -23,7 +21,7 @@ module Ramaze
|
|
23
21
|
def transform action
|
24
22
|
nagoro = wrap_compile(action)
|
25
23
|
file = action.template || action.method
|
26
|
-
nagoro.result(action.binding
|
24
|
+
nagoro.result(:file => file, :binding => action.binding)
|
27
25
|
end
|
28
26
|
|
29
27
|
def wrap_compile(action, template = nil)
|
@@ -45,7 +43,7 @@ module Ramaze
|
|
45
43
|
# and returning an instance of ::Nagoro::Template
|
46
44
|
|
47
45
|
def compile(action, template)
|
48
|
-
|
46
|
+
::Nagoro.compile(template)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
data/lib/ramaze/template/none.rb
CHANGED
data/lib/ramaze/template/sass.rb
CHANGED
data/lib/ramaze/tool.rb
CHANGED
data/lib/ramaze/tool/create.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
require 'fileutils'
|
@@ -29,6 +29,11 @@ module Ramaze
|
|
29
29
|
@basedir = ::Ramaze::BASEDIR / 'proto'
|
30
30
|
@destdir = Dir.pwd / project
|
31
31
|
|
32
|
+
if File.directory?(@destdir)
|
33
|
+
puts "Error: #{project}/ already exists. Rename or delete directory and try again."
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
32
37
|
puts "Creating project #{project}"
|
33
38
|
|
34
39
|
FileUtils.mkdir_p(project)
|
@@ -41,6 +46,7 @@ module Ramaze
|
|
41
46
|
create_dirs(*directories)
|
42
47
|
copy_files(*files)
|
43
48
|
|
49
|
+
puts "\nStart your new ramaze app: ruby #{project}/start.rb"
|
44
50
|
end
|
45
51
|
|
46
52
|
# create the directories recursivly
|
data/lib/ramaze/tool/localize.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
$KCODE = 'UTF-8'
|
@@ -74,23 +74,16 @@ class Ramaze::Tool::Localize
|
|
74
74
|
# not available, it falls back to the default language.
|
75
75
|
|
76
76
|
def localize(str, locale)
|
77
|
-
trans = nil
|
78
77
|
default_language = trait[:default_language]
|
79
78
|
dict = dictionary
|
79
|
+
dict[locale] ||= {}
|
80
|
+
dict[default_language] ||= {}
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
dict[locale] ||= {}
|
85
|
-
dict[locale][str] = str
|
86
|
-
else
|
87
|
-
dict[locale] ||= {}
|
88
|
-
dict[default_language] ||= {}
|
89
|
-
dict[locale][str] = str
|
90
|
-
dict[default_language][str] = str
|
91
|
-
end
|
82
|
+
trans = dict[locale].fetch(str, dict[default_language][str])
|
83
|
+
dict[locale][str] ||= trans
|
84
|
+
dict[default_language][str] ||= trans
|
92
85
|
|
93
|
-
trans
|
86
|
+
trans
|
94
87
|
rescue Object => ex
|
95
88
|
Ramaze::Inform.error(ex)
|
96
89
|
str
|
data/lib/ramaze/tool/mime.rb
CHANGED
data/lib/ramaze/tool/record.rb
CHANGED
data/lib/ramaze/trinity.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
require 'cgi'
|
@@ -29,7 +29,7 @@ module Ramaze
|
|
29
29
|
# first it tries to match your method with any of the HTTP parameters
|
30
30
|
# then, in case that fails, it will relay to @request
|
31
31
|
|
32
|
-
def method_missing meth, *args
|
32
|
+
def method_missing meth, *args
|
33
33
|
key = meth.to_s.upcase
|
34
34
|
return env[key] if env.has_key?(key)
|
35
35
|
super
|
@@ -58,6 +58,8 @@ module Ramaze
|
|
58
58
|
address = address.to_s.split(',').first
|
59
59
|
addr = IPAddr.new(address)
|
60
60
|
LOCAL.find{|range| range.include?(addr) }
|
61
|
+
rescue ArgumentError => ex
|
62
|
+
raise ArgumentError, ex unless ex.message == 'invalid address'
|
61
63
|
end
|
62
64
|
|
63
65
|
def [](key, *rest)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
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
|
if RUBY_VERSION >= "1.9.0"
|
@@ -211,6 +211,12 @@ module Ramaze
|
|
211
211
|
combined.inspect
|
212
212
|
end
|
213
213
|
|
214
|
+
# Delete a key
|
215
|
+
|
216
|
+
def delete(key)
|
217
|
+
session[:FLASH].delete(key)
|
218
|
+
end
|
219
|
+
|
214
220
|
private
|
215
221
|
|
216
222
|
# Session.current or {}
|
data/lib/ramaze/version.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# Copyright (c)
|
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 #:nodoc:
|
5
5
|
module Version #:nodoc:
|
6
6
|
MAJOR = 0
|
7
|
-
MINOR =
|
8
|
-
TINY =
|
7
|
+
MINOR = 3
|
8
|
+
TINY = 0
|
9
9
|
|
10
10
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
11
11
|
end
|
data/lib/vendor/bacon.rb
ADDED
@@ -0,0 +1,317 @@
|
|
1
|
+
# Bacon -- small RSpec clone.
|
2
|
+
#
|
3
|
+
# "Truth will sooner come out from error than from confusion." ---Francis Bacon
|
4
|
+
|
5
|
+
# Copyright (C) 2007 Christian Neukirchen <purl.org/net/chneukirchen>
|
6
|
+
#
|
7
|
+
# Bacon is freely distributable under the terms of an MIT-style license.
|
8
|
+
# See COPYING or http://www.opensource.org/licenses/mit-license.php.
|
9
|
+
|
10
|
+
module Bacon
|
11
|
+
VERSION = "0.2"
|
12
|
+
|
13
|
+
Counter = Hash.new(0)
|
14
|
+
ErrorLog = ""
|
15
|
+
Shared = Hash.new { |_, name|
|
16
|
+
raise NameError, "no such context: #{name.inspect}"
|
17
|
+
}
|
18
|
+
|
19
|
+
RestrictName = // unless defined? RestrictName
|
20
|
+
RestrictContext = // unless defined? RestrictContext
|
21
|
+
|
22
|
+
def self.summary_on_exit
|
23
|
+
return if Counter[:installed_summary] > 0
|
24
|
+
at_exit {
|
25
|
+
handle_summary
|
26
|
+
if $!
|
27
|
+
raise $!
|
28
|
+
elsif Counter[:errors] + Counter[:failed] > 0
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
}
|
32
|
+
Counter[:installed_summary] += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
module SpecDoxOutput
|
36
|
+
def handle_specification(name)
|
37
|
+
puts name
|
38
|
+
yield
|
39
|
+
puts
|
40
|
+
end
|
41
|
+
|
42
|
+
def handle_requirement(description)
|
43
|
+
print "- #{description}"
|
44
|
+
error = yield
|
45
|
+
puts error.empty? ? "" : " [#{error}]"
|
46
|
+
end
|
47
|
+
|
48
|
+
def handle_summary
|
49
|
+
print ErrorLog
|
50
|
+
puts "%d specifications (%d requirements), %d failures, %d errors" %
|
51
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module TestUnitOutput
|
56
|
+
def handle_specification(name)
|
57
|
+
yield
|
58
|
+
end
|
59
|
+
|
60
|
+
def handle_requirement(description)
|
61
|
+
error = yield
|
62
|
+
if error.empty?
|
63
|
+
print "."
|
64
|
+
else
|
65
|
+
print error[0..0]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def handle_summary
|
70
|
+
puts "", ErrorLog
|
71
|
+
puts "%d tests, %d assertions, %d failures, %d errors" %
|
72
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
module TapOutput
|
77
|
+
def handle_specification(name)
|
78
|
+
yield
|
79
|
+
end
|
80
|
+
|
81
|
+
def handle_requirement(description)
|
82
|
+
ErrorLog.replace ""
|
83
|
+
error = yield
|
84
|
+
if error.empty?
|
85
|
+
printf "ok %-8d # %s\n" % [Counter[:specifications], description]
|
86
|
+
else
|
87
|
+
printf "not ok %-4d # %s: %s\n" %
|
88
|
+
[Counter[:specifications], description, error]
|
89
|
+
puts ErrorLog.strip.gsub(/^/, '# ')
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def handle_summary
|
94
|
+
puts "1..#{Counter[:specifications]}"
|
95
|
+
puts "# %d tests, %d assertions, %d failures, %d errors" %
|
96
|
+
Counter.values_at(:specifications, :requirements, :failed, :errors)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
extend SpecDoxOutput # default
|
101
|
+
|
102
|
+
class Error < RuntimeError
|
103
|
+
attr_accessor :count_as
|
104
|
+
|
105
|
+
def initialize(count_as, message)
|
106
|
+
@count_as = count_as
|
107
|
+
super message
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class Context
|
112
|
+
def initialize(name, &block)
|
113
|
+
@before = []
|
114
|
+
@after = []
|
115
|
+
@name = name
|
116
|
+
|
117
|
+
return unless name =~ RestrictContext
|
118
|
+
Bacon.handle_specification(name) do
|
119
|
+
instance_eval(&block)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def before(&block); @before << block; end
|
124
|
+
def after(&block); @after << block; end
|
125
|
+
|
126
|
+
def behaves_like(*names)
|
127
|
+
names.each do |name|
|
128
|
+
instance_eval(&Shared[name])
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def it(description, &block)
|
133
|
+
return unless description =~ RestrictName
|
134
|
+
Counter[:specifications] += 1
|
135
|
+
run_requirement description, block
|
136
|
+
end
|
137
|
+
|
138
|
+
def run_requirement(description, spec)
|
139
|
+
Bacon.handle_requirement description do
|
140
|
+
begin
|
141
|
+
Counter[:depth] += 1
|
142
|
+
@before.each { |block| instance_eval(&block) }
|
143
|
+
instance_eval(&spec)
|
144
|
+
@after.each { |block| instance_eval(&block) }
|
145
|
+
rescue Object => e
|
146
|
+
ErrorLog << "#{e.class}: #{e.message}\n"
|
147
|
+
e.backtrace.find_all { |line| line !~ /bin\/bacon|\/bacon\.rb:\d+/ }.
|
148
|
+
each_with_index { |line, i|
|
149
|
+
ErrorLog << "\t#{line}#{i==0 ? ": #@name - #{description}" : ""}\n"
|
150
|
+
}
|
151
|
+
ErrorLog << "\n"
|
152
|
+
|
153
|
+
if e.kind_of? Error
|
154
|
+
Counter[e.count_as] += 1
|
155
|
+
e.count_as.to_s.upcase
|
156
|
+
else
|
157
|
+
Counter[:errors] += 1
|
158
|
+
"ERROR: #{e.class}"
|
159
|
+
end
|
160
|
+
else
|
161
|
+
""
|
162
|
+
ensure
|
163
|
+
Counter[:depth] -= 1
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def raise?(*args, &block); block.raise?(*args); end
|
169
|
+
def throw?(*args, &block); block.throw?(*args); end
|
170
|
+
def change?(*args, &block); block.change?(*args); end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
class Object
|
176
|
+
def true?; false; end
|
177
|
+
def false?; false; end
|
178
|
+
end
|
179
|
+
|
180
|
+
class TrueClass
|
181
|
+
def true?; true; end
|
182
|
+
end
|
183
|
+
|
184
|
+
class FalseClass
|
185
|
+
def false?; true; end
|
186
|
+
end
|
187
|
+
|
188
|
+
class Proc
|
189
|
+
def raise?(*exceptions)
|
190
|
+
exceptions << RuntimeError if exceptions.empty?
|
191
|
+
call
|
192
|
+
|
193
|
+
# Only to work in 1.9.0, rescue with splat doesn't work there right now
|
194
|
+
rescue Object => e
|
195
|
+
case e
|
196
|
+
when *exceptions
|
197
|
+
e
|
198
|
+
else
|
199
|
+
raise e
|
200
|
+
end
|
201
|
+
else
|
202
|
+
false
|
203
|
+
end
|
204
|
+
|
205
|
+
def throw?(sym)
|
206
|
+
catch(sym) {
|
207
|
+
call
|
208
|
+
return false
|
209
|
+
}
|
210
|
+
return true
|
211
|
+
end
|
212
|
+
|
213
|
+
def change?
|
214
|
+
pre_result = yield
|
215
|
+
called = call
|
216
|
+
post_result = yield
|
217
|
+
pre_result != post_result
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
class Numeric
|
222
|
+
def close?(to, delta)
|
223
|
+
(to.to_f - self).abs <= delta.to_f rescue false
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
class Object
|
229
|
+
def should(*args, &block)
|
230
|
+
Should.new(self).be(*args, &block)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
module Kernel
|
235
|
+
private
|
236
|
+
|
237
|
+
def describe(name, &block)
|
238
|
+
Bacon::Context.new(name.to_s, &block)
|
239
|
+
end
|
240
|
+
|
241
|
+
def shared(name, &block)
|
242
|
+
Bacon::Shared[name] = block
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
|
247
|
+
class Should
|
248
|
+
# Kills ==, ===, =~, eql?, equal?, frozen?, instance_of?, is_a?,
|
249
|
+
# kind_of?, nil?, respond_to?, tainted?
|
250
|
+
instance_methods.each { |method|
|
251
|
+
undef_method method if method =~ /\?|^\W+$/
|
252
|
+
}
|
253
|
+
|
254
|
+
def initialize(object)
|
255
|
+
@object = object
|
256
|
+
@negated = false
|
257
|
+
end
|
258
|
+
|
259
|
+
def not(*args, &block)
|
260
|
+
@negated = !@negated
|
261
|
+
|
262
|
+
if args.empty?
|
263
|
+
self
|
264
|
+
else
|
265
|
+
be(*args, &block)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def be(*args, &block)
|
270
|
+
if args.empty?
|
271
|
+
self
|
272
|
+
else
|
273
|
+
block = args.shift unless block_given?
|
274
|
+
satisfy(*args, &block)
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
alias a be
|
279
|
+
alias an be
|
280
|
+
|
281
|
+
def satisfy(*args, &block)
|
282
|
+
if args.size == 1 && String === args.first
|
283
|
+
description = args.shift
|
284
|
+
else
|
285
|
+
description = ""
|
286
|
+
end
|
287
|
+
|
288
|
+
r = yield(@object, *args)
|
289
|
+
if Bacon::Counter[:depth] > 0
|
290
|
+
raise Bacon::Error.new(:failed, description) unless @negated ^ r
|
291
|
+
Bacon::Counter[:requirements] += 1
|
292
|
+
end
|
293
|
+
@negated ^ r ? r : false
|
294
|
+
end
|
295
|
+
|
296
|
+
def method_missing(name, *args, &block)
|
297
|
+
name = "#{name}?" if name.to_s =~ /\w[^?]\z/
|
298
|
+
|
299
|
+
desc = @negated ? "not " : ""
|
300
|
+
desc << @object.inspect << "." << name.to_s
|
301
|
+
desc << "(" << args.map{|x|x.inspect}.join(", ") << ") failed"
|
302
|
+
|
303
|
+
satisfy(desc) { |x|
|
304
|
+
x.__send__(name, *args, &block)
|
305
|
+
}
|
306
|
+
end
|
307
|
+
|
308
|
+
def equal(value); self == value; end
|
309
|
+
def match(value); self =~ value; end
|
310
|
+
|
311
|
+
def identical_to(value); self.equal? value; end
|
312
|
+
alias same_as identical_to
|
313
|
+
|
314
|
+
def flunk(reason="Flunked")
|
315
|
+
raise Bacon::Error.new(:failed, reason)
|
316
|
+
end
|
317
|
+
end
|