ramaze 0.3.5 → 0.3.9
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/Rakefile +5 -20
- data/bin/ramaze +0 -4
- data/doc/AUTHORS +5 -0
- data/doc/meta/announcement.txt +2 -1
- data/doc/tutorial/todolist.html +20 -21
- data/doc/tutorial/todolist.mkd +10 -9
- data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
- data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
- data/examples/blog/spec/blog.rb +3 -3
- data/examples/blog/start.rb +2 -3
- data/examples/blog/view/edit.xhtml +17 -0
- data/examples/blog/view/index.xhtml +17 -0
- data/examples/blog/view/layout.xhtml +11 -0
- data/examples/blog/view/new.xhtml +16 -0
- data/examples/facebook.rb +15 -8
- data/examples/identity.rb +1 -1
- data/examples/memleak_detector.rb +1 -1
- data/examples/rammit/src/model.rb +1 -1
- data/examples/rapaste/controller/paste.rb +7 -7
- data/examples/rapaste/model/paste.rb +1 -3
- data/examples/rapaste/public/css/display.css +2 -1
- data/examples/rapaste/start.rb +2 -3
- data/examples/sourceview/sourceview.rb +1 -1
- data/examples/templates/template/external.tenjin +28 -0
- data/examples/templates/template_amrita2.rb +0 -3
- data/examples/templates/template_tenjin.rb +57 -0
- data/examples/todolist/spec/todolist.rb +13 -2
- data/examples/todolist/src/controller/main.rb +1 -1
- data/examples/todolist/template/index.xhtml +1 -1
- data/examples/wiktacular/spec/wiktacular.rb +18 -0
- data/examples/wiktacular/src/controller.rb +2 -2
- data/examples/wiktacular/src/model.rb +8 -2
- data/lib/proto/public/css/ramaze_error.css +4 -0
- data/lib/proto/public/dispatch.fcgi +11 -0
- data/lib/proto/spec/main.rb +1 -1
- data/lib/proto/start.ru +8 -0
- data/lib/proto/view/error.xhtml +2 -0
- data/lib/ramaze.rb +28 -5
- data/lib/ramaze/action.rb +9 -2
- data/lib/ramaze/action/render.rb +40 -24
- data/lib/ramaze/adapter.rb +10 -17
- data/lib/ramaze/adapter/base.rb +8 -12
- data/lib/ramaze/adapter/cgi.rb +14 -13
- data/lib/ramaze/adapter/ebb.rb +34 -0
- data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
- data/lib/ramaze/adapter/fcgi.rb +14 -14
- data/lib/ramaze/adapter/lsws.rb +15 -11
- data/lib/ramaze/adapter/mongrel.rb +2 -1
- data/lib/ramaze/adapter/scgi.rb +24 -0
- data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
- data/lib/ramaze/adapter/thin.rb +4 -5
- data/lib/ramaze/adapter/webrick.rb +5 -5
- data/lib/ramaze/cache.rb +1 -1
- data/lib/ramaze/cache/memcached.rb +1 -1
- data/lib/ramaze/contrib.rb +70 -10
- data/lib/ramaze/contrib/auto_params.rb +1 -1
- data/lib/ramaze/contrib/email.rb +15 -15
- data/lib/ramaze/contrib/facebook.rb +2 -2
- data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
- data/lib/ramaze/contrib/file_cache.rb +65 -0
- data/lib/ramaze/contrib/gettext.rb +56 -55
- data/lib/ramaze/contrib/profiling.rb +36 -0
- data/lib/ramaze/contrib/sequel_cache.rb +92 -0
- data/lib/ramaze/controller.rb +80 -47
- data/lib/ramaze/controller/error.rb +10 -5
- data/lib/ramaze/controller/resolve.rb +36 -48
- data/lib/ramaze/current.rb +70 -0
- data/lib/ramaze/{trinity → current}/request.rb +62 -15
- data/lib/ramaze/current/response.rb +19 -0
- data/lib/ramaze/{trinity → current}/session.rb +32 -110
- data/lib/ramaze/current/session/flash.rb +67 -0
- data/lib/ramaze/current/session/hash.rb +65 -0
- data/lib/ramaze/dispatcher.rb +1 -28
- data/lib/ramaze/dispatcher/action.rb +6 -3
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +26 -5
- data/lib/ramaze/dispatcher/file.rb +13 -2
- data/lib/ramaze/gestalt.rb +3 -1
- data/lib/ramaze/global.rb +6 -3
- data/lib/ramaze/global/globalstruct.rb +3 -1
- data/lib/ramaze/helper.rb +66 -20
- data/lib/ramaze/helper/aspect.rb +25 -17
- data/lib/ramaze/helper/auth.rb +4 -3
- data/lib/ramaze/helper/cache.rb +5 -4
- data/lib/ramaze/helper/cgi.rb +11 -9
- data/lib/ramaze/helper/flash.rb +28 -3
- data/lib/ramaze/helper/formatting.rb +1 -3
- data/lib/ramaze/helper/identity.rb +2 -3
- data/lib/ramaze/helper/inform.rb +7 -6
- data/lib/ramaze/helper/link.rb +15 -17
- data/lib/ramaze/helper/markaby.rb +2 -4
- data/lib/ramaze/helper/maruku.rb +1 -1
- data/lib/ramaze/helper/nitroform.rb +4 -4
- data/lib/ramaze/helper/pager.rb +4 -6
- data/lib/ramaze/helper/partial.rb +24 -21
- data/lib/ramaze/helper/redirect.rb +8 -5
- data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
- data/lib/ramaze/helper/sequel.rb +1 -3
- data/lib/ramaze/helper/stack.rb +1 -3
- data/lib/ramaze/helper/tagz.rb +19 -0
- data/lib/ramaze/helper/user.rb +63 -0
- data/lib/ramaze/inform.rb +2 -24
- data/lib/ramaze/log.rb +28 -0
- data/lib/ramaze/{inform → log}/analogger.rb +3 -3
- data/lib/ramaze/{inform → log}/growl.rb +2 -2
- data/lib/ramaze/{inform → log}/hub.rb +4 -6
- data/lib/ramaze/{inform → log}/informer.rb +4 -4
- data/lib/ramaze/{inform → log}/knotify.rb +2 -2
- data/lib/ramaze/log/logger.rb +22 -0
- data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
- data/lib/ramaze/{inform → log}/syslog.rb +0 -0
- data/lib/ramaze/{inform → log}/xosd.rb +2 -2
- data/lib/ramaze/route.rb +64 -36
- data/lib/ramaze/snippets/array/put_within.rb +13 -0
- data/lib/ramaze/snippets/binding/locals.rb +13 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
- data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
- data/lib/ramaze/snippets/kernel/constant.rb +1 -1
- data/lib/ramaze/snippets/object/pretty.rb +6 -0
- data/lib/ramaze/snippets/object/scope.rb +11 -0
- data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
- data/lib/ramaze/snippets/ordered_set.rb +1 -1
- data/lib/ramaze/snippets/proc/locals.rb +11 -0
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
- data/lib/ramaze/snippets/string/esc.rb +29 -0
- data/lib/ramaze/snippets/string/start_with.rb +7 -0
- data/lib/ramaze/snippets/string/unindent.rb +6 -1
- data/lib/ramaze/snippets/struct/values_at.rb +1 -5
- data/lib/ramaze/sourcereload.rb +16 -14
- data/lib/ramaze/spec.rb +1 -0
- data/lib/ramaze/spec/helper.rb +11 -3
- data/lib/ramaze/spec/helper/browser.rb +25 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
- data/lib/ramaze/template.rb +5 -4
- data/lib/ramaze/template/amrita2.rb +2 -3
- data/lib/ramaze/template/ezamar/element.rb +2 -3
- data/lib/ramaze/template/ezamar/morpher.rb +1 -2
- data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
- data/lib/ramaze/template/haml.rb +5 -2
- data/lib/ramaze/template/markaby.rb +2 -0
- data/lib/ramaze/template/tagz.rb +79 -0
- data/lib/ramaze/template/tenjin.rb +34 -0
- data/lib/ramaze/tool/create.rb +0 -3
- data/lib/ramaze/tool/localize.rb +107 -105
- data/lib/ramaze/tool/mime.rb +0 -2
- data/lib/ramaze/trinity.rb +1 -26
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +47 -41
- data/rake_tasks/conf.rake +18 -0
- data/rake_tasks/darcs.rake +5 -0
- data/rake_tasks/maintenance.rake +37 -24
- data/rake_tasks/spec.rake +1 -1
- data/spec/contrib/auto_params.rb +3 -1
- data/spec/contrib/profiling.rb +26 -0
- data/spec/examples/templates/template_redcloth.rb +1 -1
- data/spec/examples/templates/template_tenjin.rb +28 -0
- data/spec/helper.rb +0 -1
- data/spec/ramaze/action/layout.rb +28 -0
- data/spec/ramaze/controller/actionless_templates.rb +32 -0
- data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +37 -0
- data/spec/ramaze/{trinity → current}/request.rb +12 -2
- data/spec/ramaze/current/session.rb +97 -0
- data/spec/ramaze/dispatcher/directory.rb +2 -1
- data/spec/ramaze/dispatcher/file.rb +8 -3
- data/spec/ramaze/dispatcher/public/file name.txt +1 -0
- data/spec/ramaze/gestalt.rb +11 -0
- data/spec/ramaze/helper/aspect.rb +28 -22
- data/spec/ramaze/helper/cgi.rb +2 -2
- data/spec/ramaze/helper/flash.rb +33 -15
- data/spec/ramaze/helper/formatting.rb +2 -2
- data/spec/ramaze/helper/link.rb +46 -18
- data/spec/ramaze/helper/pager.rb +8 -5
- data/spec/ramaze/helper/partial.rb +8 -1
- data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
- data/spec/ramaze/helper/user.rb +46 -0
- data/spec/ramaze/{inform → log}/informer.rb +0 -0
- data/spec/ramaze/{inform → log}/syslog.rb +1 -1
- data/spec/ramaze/request.rb +14 -10
- data/spec/ramaze/route.rb +23 -0
- data/spec/ramaze/template.rb +48 -1
- data/spec/ramaze/template/haml.rb +6 -16
- data/spec/ramaze/template/haml/locals.haml +2 -1
- data/spec/ramaze/template/tagz.rb +62 -0
- data/spec/ramaze/template/tagz/external.tagz +8 -0
- data/spec/ramaze/template/tagz/sum.tagz +1 -0
- data/spec/ramaze/template/tenjin.rb +49 -0
- data/spec/ramaze/template/tenjin/external.tenjin +1 -0
- data/spec/snippets/string/unindent.rb +15 -0
- metadata +509 -475
- data/doc/README.html +0 -729
- data/doc/changes.txt +0 -5757
- data/doc/changes.xml +0 -5759
- data/examples/blog/src/view.rb +0 -16
- data/examples/blog/template/edit.xhtml +0 -19
- data/examples/blog/template/index.xhtml +0 -19
- data/examples/blog/template/new.xhtml +0 -18
- data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
- data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
- data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
- data/lib/ramaze/template/bijou.rb +0 -39
- data/lib/ramaze/trinity/response.rb +0 -32
- data/spec/ramaze/template/bijou.rb +0 -25
- data/spec/ramaze/trinity/session.rb +0 -29
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
module Ramaze
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# Helper::Redirect actually takes advantage of Helper::Link.link_raw to build the links
|
|
7
7
|
# it redirects to.
|
|
8
8
|
# It doesn't do much else than this:
|
|
9
9
|
# setting a status-code of 303 and a response['Location'] = link
|
|
@@ -20,9 +20,7 @@ module Ramaze
|
|
|
20
20
|
# - maybe some more options, like a delay
|
|
21
21
|
#
|
|
22
22
|
|
|
23
|
-
module
|
|
24
|
-
|
|
25
|
-
private
|
|
23
|
+
module Helper::Redirect
|
|
26
24
|
|
|
27
25
|
# render to the browser directly, ignoring any templates
|
|
28
26
|
def respond *args
|
|
@@ -56,10 +54,15 @@ module Ramaze
|
|
|
56
54
|
status = opts[:status] || STATUS_CODE["See Other"]
|
|
57
55
|
body = %{You are being redirected, please follow <a href="#{target}">this link to: #{target}</a>!}
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
Log.info("Redirect to '#{target}'")
|
|
58
|
+
request[:redirected] = true
|
|
60
59
|
throw(:redirect, [body, status, header])
|
|
61
60
|
end
|
|
62
61
|
|
|
62
|
+
def redirected?
|
|
63
|
+
request[:redirected]
|
|
64
|
+
end
|
|
65
|
+
|
|
63
66
|
# redirect to the location the browser says it's coming from.
|
|
64
67
|
|
|
65
68
|
def redirect_referer
|
|
@@ -5,9 +5,7 @@ module Ramaze
|
|
|
5
5
|
|
|
6
6
|
# Helper for quickly push out files with the proper mimetype.
|
|
7
7
|
|
|
8
|
-
module
|
|
9
|
-
private
|
|
10
|
-
|
|
8
|
+
module Helper::SendFile
|
|
11
9
|
# Sets Content-Type to the mimetype of the file and opens the file you pass
|
|
12
10
|
# it, then throws :respond to finish off the request.
|
|
13
11
|
|
data/lib/ramaze/helper/sequel.rb
CHANGED
data/lib/ramaze/helper/stack.rb
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
require 'tagz'
|
|
5
|
+
|
|
6
|
+
module Ramaze
|
|
7
|
+
|
|
8
|
+
# Allows you to use some shortcuts for Tagz in your Controller.
|
|
9
|
+
|
|
10
|
+
# use this inside your controller to directly build Tagz
|
|
11
|
+
# Refer to the Tagz-documentation and testsuite for more examples.
|
|
12
|
+
# Usage:
|
|
13
|
+
# tagz { h1_{ "Apples & Oranges" } } #=> "<h1>Apples & Oranges</h1>"
|
|
14
|
+
# tagz { h1_(:class => 'fruits&floots'){ 'Apples' } } #=> "<h1 class=\"fruits&floots\">Apples</h1>"
|
|
15
|
+
|
|
16
|
+
module Helper
|
|
17
|
+
Tagz = ::Tagz
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Ramaze
|
|
2
|
+
module Helper
|
|
3
|
+
module User
|
|
4
|
+
def self.inherited(klass)
|
|
5
|
+
klass.trait :user_model => ::User
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def user
|
|
9
|
+
if instance_variable_defined?('@user_helper')
|
|
10
|
+
@user_helper
|
|
11
|
+
else
|
|
12
|
+
@user_helper = Wrapper.new ancestral_trait[:user_model]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Wrapper
|
|
17
|
+
thread_accessor :session
|
|
18
|
+
attr_accessor :user
|
|
19
|
+
|
|
20
|
+
def initialize(model)
|
|
21
|
+
raise ArgumentError, "No model defined for Helper::User" unless model
|
|
22
|
+
@model = model
|
|
23
|
+
@user = nil
|
|
24
|
+
login(persist)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def logged_in?
|
|
28
|
+
!!@user
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def login?(hash)
|
|
32
|
+
credentials = {}
|
|
33
|
+
hash.each{|k,v| credentials[k.to_sym] = v.to_s }
|
|
34
|
+
@model[credentials]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def persist
|
|
38
|
+
session[:USER] ||= {}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def persist=(hash)
|
|
42
|
+
session[:USER] = hash
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def login(hash = Request.current.params)
|
|
46
|
+
return if hash.empty?
|
|
47
|
+
if found = login?(hash)
|
|
48
|
+
@user = found
|
|
49
|
+
self.persist = hash
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def logout
|
|
54
|
+
persist.clear
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def method_missing(meth, *args, &block)
|
|
58
|
+
@user.send(meth, *args, &block)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/ramaze/inform.rb
CHANGED
|
@@ -1,26 +1,4 @@
|
|
|
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
|
-
require 'ramaze/inform/informing'
|
|
5
|
-
require 'ramaze/inform/hub'
|
|
6
|
-
require 'ramaze/inform/informer'
|
|
7
|
-
|
|
8
|
-
begin
|
|
9
|
-
require 'win32console' if RUBY_PLATFORM =~ /win32/i
|
|
10
|
-
rescue LoadError => ex
|
|
11
|
-
puts ex
|
|
12
|
-
puts "For nice colors on windows, please `gem install win32console`"
|
|
13
|
-
Ramaze::Informer.trait[:colorize] = false
|
|
14
|
-
end
|
|
15
|
-
|
|
16
1
|
module Ramaze
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
autoload :Syslog, "ramaze/inform/syslog.rb"
|
|
20
|
-
autoload :Growl, "ramaze/inform/growl.rb"
|
|
21
|
-
autoload :Xosd, "ramaze/inform/xosd.rb"
|
|
22
|
-
|
|
23
|
-
unless defined?(Inform)
|
|
24
|
-
Inform = LogHub.new(Informer)
|
|
25
|
-
end
|
|
2
|
+
Log.warn "Ramaze::Inform is being deprecated, use Ramaze::Log instead"
|
|
3
|
+
Inform = Log
|
|
26
4
|
end
|
data/lib/ramaze/log.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
require 'ramaze/log/logging'
|
|
5
|
+
require 'ramaze/log/hub'
|
|
6
|
+
require 'ramaze/log/informer'
|
|
7
|
+
|
|
8
|
+
begin
|
|
9
|
+
require 'win32console' if RUBY_PLATFORM =~ /win32/i
|
|
10
|
+
rescue LoadError => ex
|
|
11
|
+
puts ex
|
|
12
|
+
puts "For nice colors on windows, please `gem install win32console`"
|
|
13
|
+
Ramaze::Informer.trait[:colorize] = false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module Ramaze
|
|
17
|
+
autoload :Analogger, "ramaze/log/analogger.rb"
|
|
18
|
+
autoload :Knotify, "ramaze/log/knotify.rb"
|
|
19
|
+
autoload :Syslog, "ramaze/log/syslog.rb"
|
|
20
|
+
autoload :Growl, "ramaze/log/growl.rb"
|
|
21
|
+
autoload :Xosd, "ramaze/log/xosd.rb"
|
|
22
|
+
autoload :Logger, "ramaze/log/logger.rb"
|
|
23
|
+
autoload :Inform, "ramaze/inform"
|
|
24
|
+
|
|
25
|
+
unless defined?(Log)
|
|
26
|
+
Log = LogHub.new(Informer)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -11,7 +11,7 @@ module Ramaze
|
|
|
11
11
|
# gem install analogger
|
|
12
12
|
|
|
13
13
|
class Analogger < ::Swiftcore::Analogger::Client
|
|
14
|
-
include
|
|
14
|
+
include Logging
|
|
15
15
|
|
|
16
16
|
# identifier for your application
|
|
17
17
|
trait :name => 'walrus'
|
|
@@ -28,9 +28,9 @@ module Ramaze
|
|
|
28
28
|
super
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
# integration to
|
|
31
|
+
# integration to Logging
|
|
32
32
|
|
|
33
|
-
def
|
|
33
|
+
def log(tag, *args)
|
|
34
34
|
log(tag, args.join("\n"))
|
|
35
35
|
end
|
|
36
36
|
end
|
|
@@ -24,9 +24,9 @@ module Ramaze
|
|
|
24
24
|
super(*options)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
# integration to
|
|
27
|
+
# integration to Logging
|
|
28
28
|
|
|
29
|
-
def
|
|
29
|
+
def log(tag, *args)
|
|
30
30
|
notify(tag.to_s, Time.now.strftime("%X"), args.join("\n")[0..100])
|
|
31
31
|
rescue Errno::EMSGSIZE
|
|
32
32
|
# Send size was to big (not really), ignore
|
|
@@ -1,15 +1,13 @@
|
|
|
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
|
-
require 'set'
|
|
5
|
-
|
|
6
4
|
module Ramaze
|
|
7
5
|
|
|
8
6
|
# Bundles different informer instances and sends incoming messages to each.
|
|
9
7
|
# This is the default with Informer as only member.
|
|
10
8
|
|
|
11
9
|
class LogHub
|
|
12
|
-
include
|
|
10
|
+
include Logging
|
|
13
11
|
|
|
14
12
|
attr_accessor :loggers
|
|
15
13
|
attr_accessor :ignored_tags
|
|
@@ -28,12 +26,12 @@ module Ramaze
|
|
|
28
26
|
@loggers.compact!
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
# integration to
|
|
29
|
+
# integration to Logging
|
|
32
30
|
|
|
33
|
-
def
|
|
31
|
+
def log(tag, *args)
|
|
34
32
|
return if @ignored_tags.include?(tag)
|
|
35
33
|
@loggers.each do |logger|
|
|
36
|
-
logger.
|
|
34
|
+
logger.log(tag, *args)
|
|
37
35
|
end
|
|
38
36
|
end
|
|
39
37
|
end
|
|
@@ -7,7 +7,7 @@ module Ramaze
|
|
|
7
7
|
# customization.
|
|
8
8
|
|
|
9
9
|
class Informer
|
|
10
|
-
include
|
|
10
|
+
include Logging
|
|
11
11
|
|
|
12
12
|
attr_accessor :out, :colorize, :log_levels
|
|
13
13
|
|
|
@@ -70,14 +70,14 @@ module Ramaze
|
|
|
70
70
|
|
|
71
71
|
def shutdown
|
|
72
72
|
if @out.respond_to?(:close)
|
|
73
|
-
|
|
73
|
+
Log.debug("close, #{@out.inspect}")
|
|
74
74
|
@out.close
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
# Integration to
|
|
78
|
+
# Integration to Logging.
|
|
79
79
|
|
|
80
|
-
def
|
|
80
|
+
def log tag, *messages
|
|
81
81
|
return if closed? || !@log_levels.include?(tag)
|
|
82
82
|
messages.flatten!
|
|
83
83
|
|
|
@@ -7,14 +7,14 @@ module Ramaze
|
|
|
7
7
|
# Doesn't need any special libraries.
|
|
8
8
|
|
|
9
9
|
class Knotify
|
|
10
|
-
include
|
|
10
|
+
include Logging
|
|
11
11
|
|
|
12
12
|
trait :present => 16
|
|
13
13
|
|
|
14
14
|
# Please see for more information on the API used here:
|
|
15
15
|
# http://lukeplant.me.uk/articles.php?id=3
|
|
16
16
|
|
|
17
|
-
def
|
|
17
|
+
def log(tag, *messages)
|
|
18
18
|
present = class_trait[:present]
|
|
19
19
|
tag = tag.to_s.capitalize
|
|
20
20
|
messages.flatten.each do |message|
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
require 'logger'
|
|
5
|
+
|
|
6
|
+
module Ramaze
|
|
7
|
+
|
|
8
|
+
# Informer for the Stdlib Logger
|
|
9
|
+
|
|
10
|
+
class Logger < ::Logger
|
|
11
|
+
|
|
12
|
+
# integration to Logging
|
|
13
|
+
|
|
14
|
+
def log(tag, *args)
|
|
15
|
+
__send__(tag, args.join("\n"))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def dev(*args)
|
|
19
|
+
debug(*args)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -7,71 +7,71 @@ module Ramaze
|
|
|
7
7
|
# The minimal usage is like this:
|
|
8
8
|
#
|
|
9
9
|
# class MyLogger
|
|
10
|
-
# include
|
|
10
|
+
# include Logging
|
|
11
11
|
#
|
|
12
|
-
# def
|
|
12
|
+
# def log(tag, *args)
|
|
13
13
|
# p tag => args
|
|
14
14
|
# end
|
|
15
15
|
# end
|
|
16
16
|
|
|
17
|
-
module
|
|
17
|
+
module Logging
|
|
18
18
|
|
|
19
19
|
# Takes the tag (:warn|:debug|:error|:info) and the name of a method to be
|
|
20
20
|
# called upon elements of msgs that don't respond to :to_str
|
|
21
|
-
# Goes on and sends the tag and transformed messages each to the #
|
|
22
|
-
# If you include this module you have to define #
|
|
21
|
+
# Goes on and sends the tag and transformed messages each to the #log method.
|
|
22
|
+
# If you include this module you have to define #log or it will raise.
|
|
23
23
|
|
|
24
|
-
def
|
|
24
|
+
def tag_log(tag, meth, *msgs)
|
|
25
25
|
msgs.each do |msg|
|
|
26
26
|
string = (msg.respond_to?(:to_str) ? msg : msg.send(meth))
|
|
27
|
-
|
|
27
|
+
log(tag, string)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# Converts everything given to strings and passes them on with :info
|
|
32
32
|
|
|
33
33
|
def info(*objects)
|
|
34
|
-
|
|
34
|
+
tag_log(:info, :to_s, *objects)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# Converts everything given to strings and passes them on with :warn
|
|
38
38
|
|
|
39
39
|
def warn(*objects)
|
|
40
|
-
|
|
40
|
+
tag_log(:warn, :to_s, *objects)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
# inspects objects if they are no strings. Tag is :debug
|
|
44
44
|
|
|
45
45
|
def debug(*objects)
|
|
46
|
-
|
|
46
|
+
tag_log(:debug, :inspect, *objects)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# inspects objects if they are no strings. Tag is :dev
|
|
50
50
|
|
|
51
51
|
def dev(*objects)
|
|
52
|
-
|
|
52
|
+
tag_log(:dev, :inspect, *objects)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
alias << debug
|
|
56
56
|
|
|
57
57
|
# Takes either an Exception or just a String, formats backtraces to be a bit
|
|
58
|
-
# more readable and passes all of this on to
|
|
58
|
+
# more readable and passes all of this on to tag_log :error
|
|
59
59
|
|
|
60
60
|
def error(ex)
|
|
61
61
|
if ex.respond_to?(:exception)
|
|
62
|
-
message = ex.backtrace[0..Global.backtrace_size]
|
|
62
|
+
message = (ex.backtrace || [])[0..Global.backtrace_size]
|
|
63
63
|
message.map{|m| m.gsub!(/^#{Regexp.escape(Dir.pwd)}/, '.') }
|
|
64
64
|
message.unshift(ex.inspect)
|
|
65
65
|
else
|
|
66
66
|
message = ex.to_s
|
|
67
67
|
end
|
|
68
|
-
|
|
68
|
+
tag_log(:error, :to_s, *message)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
# raises
|
|
72
72
|
|
|
73
|
-
def
|
|
74
|
-
raise "#
|
|
73
|
+
def log(*args)
|
|
74
|
+
raise "#log should be implemented by an instance including this module (#{self})"
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# nothing
|
|
File without changes
|
|
@@ -14,7 +14,7 @@ module Ramaze
|
|
|
14
14
|
class Xosd < ::Xosd
|
|
15
15
|
attr_accessor :options
|
|
16
16
|
|
|
17
|
-
include
|
|
17
|
+
include Logging
|
|
18
18
|
|
|
19
19
|
DEFAULT = {
|
|
20
20
|
:font_size => 20,
|
|
@@ -79,7 +79,7 @@ module Ramaze
|
|
|
79
79
|
|
|
80
80
|
# pushes all messages it gets on the QUEUE for further processing.
|
|
81
81
|
|
|
82
|
-
def
|
|
82
|
+
def log(tag, *messages)
|
|
83
83
|
messages.each do |message|
|
|
84
84
|
QUEUE << [tag, message]
|
|
85
85
|
end
|