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.
Files changed (204) hide show
  1. data/Rakefile +5 -20
  2. data/bin/ramaze +0 -4
  3. data/doc/AUTHORS +5 -0
  4. data/doc/meta/announcement.txt +2 -1
  5. data/doc/tutorial/todolist.html +20 -21
  6. data/doc/tutorial/todolist.mkd +10 -9
  7. data/examples/blog/{src/controller.rb → controller/main.rb} +2 -0
  8. data/examples/blog/{src/model.rb → model/entry.rb} +0 -0
  9. data/examples/blog/spec/blog.rb +3 -3
  10. data/examples/blog/start.rb +2 -3
  11. data/examples/blog/view/edit.xhtml +17 -0
  12. data/examples/blog/view/index.xhtml +17 -0
  13. data/examples/blog/view/layout.xhtml +11 -0
  14. data/examples/blog/view/new.xhtml +16 -0
  15. data/examples/facebook.rb +15 -8
  16. data/examples/identity.rb +1 -1
  17. data/examples/memleak_detector.rb +1 -1
  18. data/examples/rammit/src/model.rb +1 -1
  19. data/examples/rapaste/controller/paste.rb +7 -7
  20. data/examples/rapaste/model/paste.rb +1 -3
  21. data/examples/rapaste/public/css/display.css +2 -1
  22. data/examples/rapaste/start.rb +2 -3
  23. data/examples/sourceview/sourceview.rb +1 -1
  24. data/examples/templates/template/external.tenjin +28 -0
  25. data/examples/templates/template_amrita2.rb +0 -3
  26. data/examples/templates/template_tenjin.rb +57 -0
  27. data/examples/todolist/spec/todolist.rb +13 -2
  28. data/examples/todolist/src/controller/main.rb +1 -1
  29. data/examples/todolist/template/index.xhtml +1 -1
  30. data/examples/wiktacular/spec/wiktacular.rb +18 -0
  31. data/examples/wiktacular/src/controller.rb +2 -2
  32. data/examples/wiktacular/src/model.rb +8 -2
  33. data/lib/proto/public/css/ramaze_error.css +4 -0
  34. data/lib/proto/public/dispatch.fcgi +11 -0
  35. data/lib/proto/spec/main.rb +1 -1
  36. data/lib/proto/start.ru +8 -0
  37. data/lib/proto/view/error.xhtml +2 -0
  38. data/lib/ramaze.rb +28 -5
  39. data/lib/ramaze/action.rb +9 -2
  40. data/lib/ramaze/action/render.rb +40 -24
  41. data/lib/ramaze/adapter.rb +10 -17
  42. data/lib/ramaze/adapter/base.rb +8 -12
  43. data/lib/ramaze/adapter/cgi.rb +14 -13
  44. data/lib/ramaze/adapter/ebb.rb +34 -0
  45. data/lib/ramaze/adapter/evented_mongrel.rb +1 -1
  46. data/lib/ramaze/adapter/fcgi.rb +14 -14
  47. data/lib/ramaze/adapter/lsws.rb +15 -11
  48. data/lib/ramaze/adapter/mongrel.rb +2 -1
  49. data/lib/ramaze/adapter/scgi.rb +24 -0
  50. data/lib/ramaze/adapter/swiftiplied_mongrel.rb +1 -1
  51. data/lib/ramaze/adapter/thin.rb +4 -5
  52. data/lib/ramaze/adapter/webrick.rb +5 -5
  53. data/lib/ramaze/cache.rb +1 -1
  54. data/lib/ramaze/cache/memcached.rb +1 -1
  55. data/lib/ramaze/contrib.rb +70 -10
  56. data/lib/ramaze/contrib/auto_params.rb +1 -1
  57. data/lib/ramaze/contrib/email.rb +15 -15
  58. data/lib/ramaze/contrib/facebook.rb +2 -2
  59. data/lib/ramaze/contrib/facebook/facebook.rb +7 -4
  60. data/lib/ramaze/contrib/file_cache.rb +65 -0
  61. data/lib/ramaze/contrib/gettext.rb +56 -55
  62. data/lib/ramaze/contrib/profiling.rb +36 -0
  63. data/lib/ramaze/contrib/sequel_cache.rb +92 -0
  64. data/lib/ramaze/controller.rb +80 -47
  65. data/lib/ramaze/controller/error.rb +10 -5
  66. data/lib/ramaze/controller/resolve.rb +36 -48
  67. data/lib/ramaze/current.rb +70 -0
  68. data/lib/ramaze/{trinity → current}/request.rb +62 -15
  69. data/lib/ramaze/current/response.rb +19 -0
  70. data/lib/ramaze/{trinity → current}/session.rb +32 -110
  71. data/lib/ramaze/current/session/flash.rb +67 -0
  72. data/lib/ramaze/current/session/hash.rb +65 -0
  73. data/lib/ramaze/dispatcher.rb +1 -28
  74. data/lib/ramaze/dispatcher/action.rb +6 -3
  75. data/lib/ramaze/dispatcher/directory.rb +1 -1
  76. data/lib/ramaze/dispatcher/error.rb +26 -5
  77. data/lib/ramaze/dispatcher/file.rb +13 -2
  78. data/lib/ramaze/gestalt.rb +3 -1
  79. data/lib/ramaze/global.rb +6 -3
  80. data/lib/ramaze/global/globalstruct.rb +3 -1
  81. data/lib/ramaze/helper.rb +66 -20
  82. data/lib/ramaze/helper/aspect.rb +25 -17
  83. data/lib/ramaze/helper/auth.rb +4 -3
  84. data/lib/ramaze/helper/cache.rb +5 -4
  85. data/lib/ramaze/helper/cgi.rb +11 -9
  86. data/lib/ramaze/helper/flash.rb +28 -3
  87. data/lib/ramaze/helper/formatting.rb +1 -3
  88. data/lib/ramaze/helper/identity.rb +2 -3
  89. data/lib/ramaze/helper/inform.rb +7 -6
  90. data/lib/ramaze/helper/link.rb +15 -17
  91. data/lib/ramaze/helper/markaby.rb +2 -4
  92. data/lib/ramaze/helper/maruku.rb +1 -1
  93. data/lib/ramaze/helper/nitroform.rb +4 -4
  94. data/lib/ramaze/helper/pager.rb +4 -6
  95. data/lib/ramaze/helper/partial.rb +24 -21
  96. data/lib/ramaze/helper/redirect.rb +8 -5
  97. data/lib/ramaze/helper/{file.rb → sendfile.rb} +1 -3
  98. data/lib/ramaze/helper/sequel.rb +1 -3
  99. data/lib/ramaze/helper/stack.rb +1 -3
  100. data/lib/ramaze/helper/tagz.rb +19 -0
  101. data/lib/ramaze/helper/user.rb +63 -0
  102. data/lib/ramaze/inform.rb +2 -24
  103. data/lib/ramaze/log.rb +28 -0
  104. data/lib/ramaze/{inform → log}/analogger.rb +3 -3
  105. data/lib/ramaze/{inform → log}/growl.rb +2 -2
  106. data/lib/ramaze/{inform → log}/hub.rb +4 -6
  107. data/lib/ramaze/{inform → log}/informer.rb +4 -4
  108. data/lib/ramaze/{inform → log}/knotify.rb +2 -2
  109. data/lib/ramaze/log/logger.rb +22 -0
  110. data/lib/ramaze/{inform/informing.rb → log/logging.rb} +16 -16
  111. data/lib/ramaze/{inform → log}/syslog.rb +0 -0
  112. data/lib/ramaze/{inform → log}/xosd.rb +2 -2
  113. data/lib/ramaze/route.rb +64 -36
  114. data/lib/ramaze/snippets/array/put_within.rb +13 -0
  115. data/lib/ramaze/snippets/binding/locals.rb +13 -0
  116. data/lib/ramaze/snippets/kernel/__dir__.rb +10 -8
  117. data/lib/ramaze/snippets/kernel/aquire.rb +1 -1
  118. data/lib/ramaze/snippets/kernel/constant.rb +1 -1
  119. data/lib/ramaze/snippets/object/pretty.rb +6 -0
  120. data/lib/ramaze/snippets/object/scope.rb +11 -0
  121. data/lib/ramaze/snippets/object/thread_accessor.rb +5 -0
  122. data/lib/ramaze/snippets/ordered_set.rb +1 -1
  123. data/lib/ramaze/snippets/proc/locals.rb +11 -0
  124. data/lib/ramaze/snippets/ramaze/thread_accessor.rb +44 -0
  125. data/lib/ramaze/snippets/string/esc.rb +29 -0
  126. data/lib/ramaze/snippets/string/start_with.rb +7 -0
  127. data/lib/ramaze/snippets/string/unindent.rb +6 -1
  128. data/lib/ramaze/snippets/struct/values_at.rb +1 -5
  129. data/lib/ramaze/sourcereload.rb +16 -14
  130. data/lib/ramaze/spec.rb +1 -0
  131. data/lib/ramaze/spec/helper.rb +11 -3
  132. data/lib/ramaze/spec/helper/browser.rb +25 -1
  133. data/lib/ramaze/spec/helper/pretty_output.rb +11 -11
  134. data/lib/ramaze/template.rb +5 -4
  135. data/lib/ramaze/template/amrita2.rb +2 -3
  136. data/lib/ramaze/template/ezamar/element.rb +2 -3
  137. data/lib/ramaze/template/ezamar/morpher.rb +1 -2
  138. data/lib/ramaze/template/ezamar/render_partial.rb +1 -1
  139. data/lib/ramaze/template/haml.rb +5 -2
  140. data/lib/ramaze/template/markaby.rb +2 -0
  141. data/lib/ramaze/template/tagz.rb +79 -0
  142. data/lib/ramaze/template/tenjin.rb +34 -0
  143. data/lib/ramaze/tool/create.rb +0 -3
  144. data/lib/ramaze/tool/localize.rb +107 -105
  145. data/lib/ramaze/tool/mime.rb +0 -2
  146. data/lib/ramaze/trinity.rb +1 -26
  147. data/lib/ramaze/version.rb +1 -1
  148. data/lib/vendor/bacon.rb +47 -41
  149. data/rake_tasks/conf.rake +18 -0
  150. data/rake_tasks/darcs.rake +5 -0
  151. data/rake_tasks/maintenance.rake +37 -24
  152. data/rake_tasks/spec.rake +1 -1
  153. data/spec/contrib/auto_params.rb +3 -1
  154. data/spec/contrib/profiling.rb +26 -0
  155. data/spec/examples/templates/template_redcloth.rb +1 -1
  156. data/spec/examples/templates/template_tenjin.rb +28 -0
  157. data/spec/helper.rb +0 -1
  158. data/spec/ramaze/action/layout.rb +28 -0
  159. data/spec/ramaze/controller/actionless_templates.rb +32 -0
  160. data/spec/ramaze/controller/template/other_wrapper.xhtml +1 -0
  161. data/spec/ramaze/controller/template_resolving.rb +37 -0
  162. data/spec/ramaze/{trinity → current}/request.rb +12 -2
  163. data/spec/ramaze/current/session.rb +97 -0
  164. data/spec/ramaze/dispatcher/directory.rb +2 -1
  165. data/spec/ramaze/dispatcher/file.rb +8 -3
  166. data/spec/ramaze/dispatcher/public/file name.txt +1 -0
  167. data/spec/ramaze/gestalt.rb +11 -0
  168. data/spec/ramaze/helper/aspect.rb +28 -22
  169. data/spec/ramaze/helper/cgi.rb +2 -2
  170. data/spec/ramaze/helper/flash.rb +33 -15
  171. data/spec/ramaze/helper/formatting.rb +2 -2
  172. data/spec/ramaze/helper/link.rb +46 -18
  173. data/spec/ramaze/helper/pager.rb +8 -5
  174. data/spec/ramaze/helper/partial.rb +8 -1
  175. data/spec/ramaze/helper/template/recursive_local_ivars.xhtml +7 -0
  176. data/spec/ramaze/helper/user.rb +46 -0
  177. data/spec/ramaze/{inform → log}/informer.rb +0 -0
  178. data/spec/ramaze/{inform → log}/syslog.rb +1 -1
  179. data/spec/ramaze/request.rb +14 -10
  180. data/spec/ramaze/route.rb +23 -0
  181. data/spec/ramaze/template.rb +48 -1
  182. data/spec/ramaze/template/haml.rb +6 -16
  183. data/spec/ramaze/template/haml/locals.haml +2 -1
  184. data/spec/ramaze/template/tagz.rb +62 -0
  185. data/spec/ramaze/template/tagz/external.tagz +8 -0
  186. data/spec/ramaze/template/tagz/sum.tagz +1 -0
  187. data/spec/ramaze/template/tenjin.rb +49 -0
  188. data/spec/ramaze/template/tenjin/external.tenjin +1 -0
  189. data/spec/snippets/string/unindent.rb +15 -0
  190. metadata +509 -475
  191. data/doc/README.html +0 -729
  192. data/doc/changes.txt +0 -5757
  193. data/doc/changes.xml +0 -5759
  194. data/examples/blog/src/view.rb +0 -16
  195. data/examples/blog/template/edit.xhtml +0 -19
  196. data/examples/blog/template/index.xhtml +0 -19
  197. data/examples/blog/template/new.xhtml +0 -18
  198. data/examples/wiktacular/mkd/newpagename/current.mkd +0 -1
  199. data/examples/wiktacular/mkd/newpagename/current.mkd.bak +0 -1
  200. data/lib/ramaze/contrib/email.rb-darcs-backup0 +0 -81
  201. data/lib/ramaze/template/bijou.rb +0 -39
  202. data/lib/ramaze/trinity/response.rb +0 -32
  203. data/spec/ramaze/template/bijou.rb +0 -25
  204. data/spec/ramaze/trinity/session.rb +0 -29
@@ -3,7 +3,7 @@
3
3
 
4
4
  module Ramaze
5
5
 
6
- # RedirectHelper actually takes advantage of LinkHelper.link_raw to build the links
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 RedirectHelper
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
- Inform.info("Redirect to '#{target}'")
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 FileHelper
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
 
@@ -2,9 +2,7 @@
2
2
  # All files in this distribution are subject to the terms of the Ruby license.
3
3
 
4
4
  module Ramaze
5
- module SequelHelper
6
- private
7
-
5
+ module Helper::Sequel
8
6
  def paginator(paginated, target)
9
7
  page_count = paginated.page_count
10
8
  prev_page = paginated.prev_page
@@ -39,9 +39,7 @@ module Ramaze
39
39
  # end
40
40
  # end
41
41
 
42
- module StackHelper
43
- private
44
-
42
+ module Helper::Stack
45
43
  # redirect to another location and pushing the current location
46
44
  # on the session[:STACK]
47
45
 
@@ -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 &amp; Oranges</h1>"
14
+ # tagz { h1_(:class => 'fruits&floots'){ 'Apples' } } #=> "<h1 class=\"fruits&amp;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
@@ -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
- autoload :Analogger, "ramaze/inform/analogger.rb"
18
- autoload :Knotify, "ramaze/inform/knotify.rb"
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
@@ -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 Informing
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 Informing
31
+ # integration to Logging
32
32
 
33
- def inform(tag, *args)
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 Informing
27
+ # integration to Logging
28
28
 
29
- def inform(tag, *args)
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 Informing
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 Informing
29
+ # integration to Logging
32
30
 
33
- def inform(tag, *args)
31
+ def log(tag, *args)
34
32
  return if @ignored_tags.include?(tag)
35
33
  @loggers.each do |logger|
36
- logger.inform(tag, *args)
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 Informing
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
- Inform.debug("close, #{@out.inspect}")
73
+ Log.debug("close, #{@out.inspect}")
74
74
  @out.close
75
75
  end
76
76
  end
77
77
 
78
- # Integration to Informing.
78
+ # Integration to Logging.
79
79
 
80
- def inform tag, *messages
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 Informing
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 inform(tag, *messages)
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 Informing
10
+ # include Logging
11
11
  #
12
- # def inform(tag, *args)
12
+ # def log(tag, *args)
13
13
  # p tag => args
14
14
  # end
15
15
  # end
16
16
 
17
- module Informing
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 #inform method.
22
- # If you include this module you have to define #inform or it will raise.
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 tag_inform(tag, meth, *msgs)
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
- inform(tag, string)
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
- tag_inform(:info, :to_s, *objects)
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
- tag_inform(:warn, :to_s, *objects)
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
- tag_inform(:debug, :inspect, *objects)
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
- tag_inform(:dev, :inspect, *objects)
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 tag_inform :error
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
- tag_inform(:error, :to_s, *message)
68
+ tag_log(:error, :to_s, *message)
69
69
  end
70
70
 
71
71
  # raises
72
72
 
73
- def inform(*args)
74
- raise "#inform should be implemented by an instance including this module (#{self})"
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 Informing
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 inform(tag, *messages)
82
+ def log(tag, *messages)
83
83
  messages.each do |message|
84
84
  QUEUE << [tag, message]
85
85
  end