ramaze 2011.07.25 → 2011.10.23

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 (181) hide show
  1. data/.gitignore +3 -0
  2. data/.mailmap +3 -2
  3. data/.travis.yml +17 -0
  4. data/.yardopts +13 -0
  5. data/README.md +95 -352
  6. data/examples/app/blog/app.rb +25 -64
  7. data/examples/app/blog/config.ru +11 -9
  8. data/examples/app/blog/controller/init.rb +29 -86
  9. data/examples/app/blog/controller/posts.rb +232 -0
  10. data/examples/app/blog/controller/users.rb +160 -0
  11. data/examples/app/blog/layout/default.xhtml +61 -0
  12. data/examples/app/blog/migrations/01_create_schema.rb +50 -0
  13. data/examples/app/blog/model/comment.rb +41 -54
  14. data/examples/app/blog/model/init.rb +41 -13
  15. data/examples/app/blog/model/post.rb +35 -0
  16. data/examples/app/blog/model/user.rb +105 -0
  17. data/examples/app/blog/public/.htaccess +24 -0
  18. data/examples/app/blog/public/css/grid.css +107 -0
  19. data/examples/app/blog/public/css/layout.css +203 -0
  20. data/examples/app/blog/public/css/reset.css +123 -0
  21. data/examples/app/blog/public/css/text.css +109 -0
  22. data/examples/app/blog/public/dispatch.fcgi +11 -0
  23. data/examples/app/blog/public/favicon.ico +0 -0
  24. data/examples/app/blog/public/images/bg.png +0 -0
  25. data/examples/app/blog/start.rb +18 -3
  26. data/examples/app/blog/view/feed.xhtml +23 -0
  27. data/examples/app/blog/view/form.xhtml +11 -0
  28. data/examples/app/blog/view/index.xhtml +44 -0
  29. data/examples/app/blog/view/users/form.xhtml +12 -0
  30. data/examples/app/blog/view/users/index.xhtml +30 -0
  31. data/examples/app/blog/view/users/login.xhtml +8 -0
  32. data/examples/app/blog/view/view.xhtml +68 -0
  33. data/{doc → guide}/AUTHORS +5 -3
  34. data/{doc → guide}/CHANGELOG +428 -0
  35. data/{doc/GPL → guide/GPL_LICENSE} +0 -0
  36. data/{doc/COPYING → guide/RUBY_LICENSE} +3 -6
  37. data/guide/_static/logo.png +0 -0
  38. data/guide/_static/logo.svg +49 -0
  39. data/guide/_static/ramaze_console.png +0 -0
  40. data/guide/css/common.css +20 -0
  41. data/guide/general/cache.md +167 -0
  42. data/guide/general/configuration.md +168 -0
  43. data/guide/general/contributing.md +108 -0
  44. data/guide/general/controllers.md +115 -0
  45. data/guide/general/helpers.md +76 -0
  46. data/guide/general/installation.md +58 -0
  47. data/guide/general/logging.md +99 -0
  48. data/guide/general/middlewares.md +100 -0
  49. data/guide/general/models.md +78 -0
  50. data/guide/general/principles.md +53 -0
  51. data/guide/general/ramaze_command.md +155 -0
  52. data/guide/general/routes.md +81 -0
  53. data/guide/general/sessions.md +140 -0
  54. data/guide/general/special_thanks.md +67 -0
  55. data/guide/general/testing.md +61 -0
  56. data/guide/general/views.md +322 -0
  57. data/guide/tutorials/introduction.md +259 -0
  58. data/lib/proto/config.ru +1 -1
  59. data/lib/proto/public/favicon.ico +0 -0
  60. data/lib/proto/view/index.xhtml +7 -7
  61. data/lib/ramaze.rb +4 -4
  62. data/lib/ramaze/app.rb +11 -11
  63. data/lib/ramaze/app_graph.rb +2 -4
  64. data/lib/ramaze/bin/console.rb +3 -3
  65. data/lib/ramaze/bin/create.rb +2 -2
  66. data/lib/ramaze/bin/restart.rb +4 -4
  67. data/lib/ramaze/bin/runner.rb +5 -5
  68. data/lib/ramaze/bin/start.rb +19 -4
  69. data/lib/ramaze/bin/status.rb +3 -3
  70. data/lib/ramaze/bin/stop.rb +3 -3
  71. data/lib/ramaze/cache.rb +1 -0
  72. data/lib/ramaze/cache/lru.rb +8 -4
  73. data/lib/ramaze/cache/memcache.rb +32 -13
  74. data/lib/ramaze/cache/redis.rb +164 -0
  75. data/lib/ramaze/cache/sequel.rb +43 -28
  76. data/lib/ramaze/controller.rb +1 -2
  77. data/lib/ramaze/dependencies.rb +40 -3
  78. data/lib/ramaze/helper/bench.rb +26 -16
  79. data/lib/ramaze/helper/blue_form.rb +46 -73
  80. data/lib/ramaze/helper/cache.rb +10 -6
  81. data/lib/ramaze/helper/csrf.rb +35 -39
  82. data/lib/ramaze/helper/disqus.rb +5 -4
  83. data/lib/ramaze/helper/email.rb +35 -24
  84. data/lib/ramaze/helper/erector.rb +9 -13
  85. data/lib/ramaze/helper/flash.rb +7 -9
  86. data/lib/ramaze/helper/formatting.rb +194 -179
  87. data/lib/ramaze/helper/gravatar.rb +4 -8
  88. data/lib/ramaze/helper/identity.rb +3 -3
  89. data/lib/ramaze/helper/layout.rb +23 -8
  90. data/lib/ramaze/helper/markaby.rb +1 -1
  91. data/lib/ramaze/helper/paginate.rb +46 -39
  92. data/lib/ramaze/helper/request_accessor.rb +3 -1
  93. data/lib/ramaze/helper/simple_captcha.rb +18 -17
  94. data/lib/ramaze/helper/stack.rb +1 -1
  95. data/lib/ramaze/helper/tagz.rb +4 -2
  96. data/lib/ramaze/helper/upload.rb +523 -0
  97. data/lib/ramaze/helper/user.rb +4 -8
  98. data/lib/ramaze/helper/xhtml.rb +11 -15
  99. data/lib/ramaze/log.rb +9 -6
  100. data/lib/ramaze/log/rotatinginformer.rb +62 -27
  101. data/lib/ramaze/log/syslog.rb +20 -15
  102. data/lib/ramaze/log/xosd.rb +2 -1
  103. data/lib/ramaze/reloader.rb +2 -0
  104. data/lib/ramaze/request.rb +11 -10
  105. data/lib/ramaze/setup.rb +23 -6
  106. data/lib/ramaze/snippets/array/put_within.rb +3 -9
  107. data/lib/ramaze/snippets/binding/locals.rb +5 -10
  108. data/lib/ramaze/snippets/fiber.rb +1 -23
  109. data/lib/ramaze/snippets/kernel/pretty_inspect.rb +3 -6
  110. data/lib/ramaze/snippets/numeric/filesize_format.rb +3 -5
  111. data/lib/ramaze/snippets/numeric/time.rb +3 -7
  112. data/lib/ramaze/snippets/object/__dir__.rb +3 -7
  113. data/lib/ramaze/snippets/object/instance_variable_defined.rb +3 -6
  114. data/lib/ramaze/snippets/object/pretty.rb +3 -7
  115. data/lib/ramaze/snippets/object/scope.rb +7 -9
  116. data/lib/ramaze/snippets/proc/locals.rb +12 -12
  117. data/lib/ramaze/snippets/ramaze/acquire.rb +15 -14
  118. data/lib/ramaze/snippets/ramaze/deprecated.rb +1 -1
  119. data/lib/ramaze/snippets/ramaze/fiber.rb +1 -1
  120. data/lib/ramaze/snippets/ramaze/lru_hash.rb +2 -3
  121. data/lib/ramaze/snippets/ramaze/struct.rb +2 -4
  122. data/lib/ramaze/snippets/string/camel_case.rb +8 -10
  123. data/lib/ramaze/snippets/string/color.rb +3 -4
  124. data/lib/ramaze/snippets/string/end_with.rb +3 -6
  125. data/lib/ramaze/snippets/string/esc.rb +3 -8
  126. data/lib/ramaze/snippets/string/ord.rb +3 -8
  127. data/lib/ramaze/snippets/string/snake_case.rb +6 -9
  128. data/lib/ramaze/snippets/string/start_with.rb +3 -8
  129. data/lib/ramaze/snippets/string/unindent.rb +3 -6
  130. data/lib/ramaze/snippets/thread/into.rb +1 -3
  131. data/lib/ramaze/spec.rb +2 -31
  132. data/lib/ramaze/spec/bacon.rb +18 -2
  133. data/lib/ramaze/version.rb +1 -1
  134. data/lib/ramaze/view.rb +1 -1
  135. data/ramaze.gemspec +1 -1
  136. data/spec/helper.rb +2 -1
  137. data/spec/ramaze/bin/start.rb +16 -20
  138. data/spec/ramaze/cache/localmemcache.rb +4 -7
  139. data/spec/ramaze/cache/memcache.rb +3 -1
  140. data/spec/ramaze/cache/redis.rb +62 -0
  141. data/spec/ramaze/helper/blue_form.rb +33 -4
  142. data/spec/ramaze/helper/layout.rb +40 -7
  143. data/spec/ramaze/helper/upload.rb +149 -0
  144. data/spec/ramaze/helper/uploads/text_1.txt +1 -0
  145. data/spec/ramaze/helper/uploads/text_2.txt +1 -0
  146. data/spec/ramaze/log/growl.rb +4 -6
  147. data/spec/ramaze/log/syslog.rb +6 -0
  148. data/spec/ramaze/view/lokar.rb +5 -0
  149. data/spec/ramaze/view/nagoro.rb +5 -0
  150. data/tasks/authors.rake +1 -1
  151. data/tasks/bacon.rake +14 -5
  152. data/tasks/changelog.rake +1 -1
  153. data/tasks/yard.rake +12 -4
  154. metadata +277 -239
  155. data/doc/LEGAL +0 -26
  156. data/examples/app/blog/README +0 -3
  157. data/examples/app/blog/controller/comment.rb +0 -45
  158. data/examples/app/blog/controller/entry.rb +0 -85
  159. data/examples/app/blog/controller/main.rb +0 -20
  160. data/examples/app/blog/controller/tag.rb +0 -9
  161. data/examples/app/blog/layout/default.nag +0 -31
  162. data/examples/app/blog/model/entry.rb +0 -89
  163. data/examples/app/blog/model/tag.rb +0 -36
  164. data/examples/app/blog/public/css/screen.css +0 -273
  165. data/examples/app/blog/spec/blog.rb +0 -87
  166. data/examples/app/blog/view/comment/form.nag +0 -10
  167. data/examples/app/blog/view/comment/show.nag +0 -16
  168. data/examples/app/blog/view/entry/edit.nag +0 -14
  169. data/examples/app/blog/view/entry/feed.atom.nag +0 -8
  170. data/examples/app/blog/view/entry/feed.rss.nag +0 -7
  171. data/examples/app/blog/view/entry/index.nag +0 -7
  172. data/examples/app/blog/view/entry/new.nag +0 -13
  173. data/examples/app/blog/view/entry/show.nag +0 -36
  174. data/examples/app/blog/view/feed.atom.nag +0 -18
  175. data/examples/app/blog/view/feed.rss.nag +0 -25
  176. data/examples/app/blog/view/index.nag +0 -6
  177. data/examples/app/blog/view/tag/index.nag +0 -5
  178. data/lib/proto/public/ramaze.png +0 -0
  179. data/lib/ramaze/rest.rb +0 -36
  180. data/spec/ramaze/rest.rb +0 -28
  181. data/tasks/rcov.rake +0 -22
@@ -9,7 +9,6 @@ module Ramaze
9
9
  # request.env, usually this will involve a request to your database.
10
10
  #
11
11
  # @example Basic usage with User::authenticate
12
- #
13
12
  # # We assume that User::[] will make a query and returns the requested
14
13
  # # User instance. This instance will be wrapped and cached.
15
14
  #
@@ -50,7 +49,6 @@ module Ramaze
50
49
  # You can however, add your own caching quite easily.
51
50
  #
52
51
  # @example caching the authentication lookup with memcached
53
- #
54
52
  # # Add the name of the cache you are going to use for the authentication
55
53
  # # and set all caches to use memcached
56
54
  #
@@ -76,7 +74,6 @@ module Ramaze
76
74
  # end
77
75
  #
78
76
  # @example Using a lambda instead of User::authenticate
79
- #
80
77
  # # assumes all your controllers inherit from this one
81
78
  #
82
79
  # class Controller < Ramaze::Controller
@@ -86,7 +83,6 @@ module Ramaze
86
83
  # end
87
84
  #
88
85
  # @example Using a different model instead of User
89
- #
90
86
  # # assumes all your controllers inherit from this one
91
87
  #
92
88
  # class Controller < Ramaze::Controller
@@ -94,7 +90,7 @@ module Ramaze
94
90
  # end
95
91
  #
96
92
  # @author manveru
97
- # TODO: convert the examples into real examples with specs
93
+ #
98
94
  module UserHelper
99
95
  # Using this as key in request.env
100
96
  RAMAZE_HELPER_USER = 'ramaze.helper.user'.freeze
@@ -103,7 +99,7 @@ module Ramaze
103
99
  # Use this method in your application, but do not use it in conditionals
104
100
  # as it will never be nil or false.
105
101
  #
106
- # @return [Ramaze::Helper::User::Wrapper] wrapped return value from
102
+ # @return [Ramaze::Helper::User::Wrapper] wrapped return value from
107
103
  # model or callback
108
104
  #
109
105
  # @api external
@@ -122,7 +118,7 @@ module Ramaze
122
118
  ##
123
119
  # shortcut for user._login but default argument are request.params
124
120
  #
125
- # @param [Hash] creds the credentials that will be passed to callback or
121
+ # @param [Hash] creds the credentials that will be passed to callback or
126
122
  # model
127
123
  # @return [nil Hash] the given creds are returned on successful login
128
124
  #
@@ -178,7 +174,7 @@ module Ramaze
178
174
  end
179
175
 
180
176
  ##
181
- # @param [Hash] creds this hash will be stored in the session on
177
+ # @param [Hash] creds this hash will be stored in the session on
182
178
  # successful login
183
179
  # @return [Ramaze::Helper::User::Wrapper] wrapped return value from
184
180
  # model or callback
@@ -6,7 +6,7 @@ module Ramaze
6
6
  # The XHTML helper can be used for generating CSS and Javascript tags.
7
7
  # Generating a CSS tag can be done by calling the css() method:
8
8
  #
9
- # css 'reset', 'screen', :only => 'ie'
9
+ # css 'reset', 'screen', :only => 'ie'
10
10
  #
11
11
  # This would result in a stylesheet named "reset.css" being loaded only when
12
12
  # the user is using Internet Explorer.
@@ -24,10 +24,9 @@ module Ramaze
24
24
  # @param [String] name The name of the CSS file to load.
25
25
  # @param [String] media The media type for which the stylesheet should be
26
26
  # loaded.
27
- # @param [Hash] options A hash containing additional options for the
27
+ # @param [Hash] options A hash containing additional options for the
28
28
  # stylesheet tag.
29
29
  # @example
30
- #
31
30
  # # A very basic example.
32
31
  # css 'reset'
33
32
  #
@@ -50,7 +49,7 @@ module Ramaze
50
49
  else
51
50
  prefix = options[:prefix] || 'css'
52
51
  LINK_TAG % [
53
- "#{Ramaze.options.prefix.chomp("/")}/#{prefix}/#{name}.css",
52
+ "#{Ramaze.options.prefix.chomp("/")}/#{prefix}/#{name}.css",
54
53
  media
55
54
  ]
56
55
  end
@@ -63,7 +62,6 @@ module Ramaze
63
62
  # again.
64
63
  #
65
64
  # @example
66
- #
67
65
  # # This is pretty basic
68
66
  # css_for 'reset', '960', 'style'
69
67
  #
@@ -71,8 +69,8 @@ module Ramaze
71
69
  # css_for ['reset', 'print'], ['960', 'print']
72
70
  #
73
71
  # @see css()
74
- # @param [Array] args An array containing either the names of all
75
- # stylesheets to load or a collection of arrays of which each array
72
+ # @param [Array] args An array containing either the names of all
73
+ # stylesheets to load or a collection of arrays of which each array
76
74
  # defines the name, media and additional parameters.
77
75
  # @return [String]
78
76
  #
@@ -81,24 +79,23 @@ module Ramaze
81
79
  end
82
80
 
83
81
  ##
84
- # Generates a Javascript tag that loads an external Javascript file. This
82
+ # Generates a Javascript tag that loads an external Javascript file. This
85
83
  # tag can't be used for loading inline Javascript files.
86
84
  #
87
85
  # @example
88
- #
89
86
  # # Simple isn't it?
90
87
  # js 'jquery'
91
88
  #
92
89
  # # Let's change the directory to "some_other_directory"
93
90
  # js 'jquery', :prefix => 'some_other_directory'
94
91
  #
95
- # @param [String] name The name of the Javascript file that should be
92
+ # @param [String] name The name of the Javascript file that should be
96
93
  # loaded.
97
94
  # @param [Hash] options Hash that can contain a :prefix key that defines
98
95
  # the directory in which the JS file is located. By default this key is
99
96
  # set to "js".
100
97
  # @return [String]
101
- #
98
+ #
102
99
  def js(name, options={})
103
100
  if name =~ /^http/ # consider it external full url
104
101
  SCRIPT_TAG % name
@@ -106,21 +103,20 @@ module Ramaze
106
103
  SCRIPT_TAG % "#{Ramaze.options.prefix.chomp("/")}/#{options[:prefix] || 'js'}/#{name}.js"
107
104
  end
108
105
  end
109
-
106
+
110
107
  ##
111
108
  # Generate multiple Javascript tags using the js() method.
112
109
  #
113
110
  # @example
114
- #
115
111
  # # Pretty simple isn't it?
116
112
  # js_for 'jquery', 'application', 'jquery.gritter'
117
113
  #
118
114
  # @param [Array] args Array containing the Javascript files to load.
119
115
  # @return [String]
120
- #
116
+ #
121
117
  def js_for(*args)
122
118
  args.map{|arg| js(*arg) }.join("\n")
123
119
  end
124
120
  end # XHTML
125
- end # Helper
121
+ end # Helper
126
122
  end # Ramaze
@@ -21,11 +21,14 @@ module Ramaze
21
21
  # @since 11-08-2009
22
22
  #
23
23
  module Logger
24
- autoload :Analogger, 'ramaze/log/analogger'
25
- autoload :Knotify, "ramaze/log/knotify"
26
- autoload :Syslog, "ramaze/log/syslog"
27
- autoload :Growl, "ramaze/log/growl"
28
- autoload :Xosd, "ramaze/log/xosd"
29
- autoload :Logger, "ramaze/log/logger"
24
+ autoload :Analogger , 'ramaze/log/analogger'
25
+ autoload :Growl , 'ramaze/log/growl'
26
+ autoload :LogHub , 'ramaze/log/hub'
27
+ autoload :Knotify , 'ramaze/log/knotify'
28
+ autoload :RotatingInformer, 'ramaze/log/rotatinginformer'
29
+ autoload :Syslog , 'ramaze/log/syslog'
30
+ autoload :Growl , 'ramaze/log/growl'
31
+ autoload :Xosd , 'ramaze/log/xosd'
32
+ autoload :Logger , 'ramaze/log/logger'
30
33
  end
31
34
  end
@@ -1,10 +1,45 @@
1
1
  module Ramaze
2
-
3
2
  module Logger
4
-
5
3
  ##
6
- # A customized logger (based on Informer) that creates multiple log files
7
- # based on current date.
4
+ # A logger that rotates log files based on the current date. Log files are
5
+ # named after the date on which they were created. If the date changes a new
6
+ # log file is used.
7
+ #
8
+ # In order to use this logger you'll have to specify a base directory for
9
+ # all log files. This directory will not be created for you so make sure it
10
+ # exists. Loading the class can be done as following:
11
+ #
12
+ # logger = Ramaze::Logger::RotatingInformer.new('./log')
13
+ #
14
+ # This creates a new instance that uses the directory ``./log`` for all it's
15
+ # log files.
16
+ #
17
+ # The default log format is ``%Y-%m-%d.log``. If you want to change this you
18
+ # can specify an alternative format (including the extension) as the
19
+ # secondary parameter of the ``.new()`` method:
20
+ #
21
+ # logger = Ramaze::Logger::RotatingInformer.new('./log', '%d-%m-%Y.log')
22
+ #
23
+ # In this case the instance will use the date format ``dd-mm-yyyy`` along
24
+ # with the ``.log`` extension.
25
+ #
26
+ # Besides the date format you can also customize the timestamp format as
27
+ # well as the format of each logged messages. Both these are set in a trait.
28
+ # The timestamp format is located in the trait ``:timestamp`` while the
29
+ # message format is stored in the ``:format`` trait. These can be set as
30
+ # following:
31
+ #
32
+ # logger = Ramaze::Logger::RotatingInformer.new('./log')
33
+ #
34
+ # logger.trait[:timestamp] = '...'
35
+ # logger.trait[:format] = '...'
36
+ #
37
+ # When setting the ``:format`` trait you can use 3 tags that will be
38
+ # replaced by their corresponding values. These are the following tags:
39
+ #
40
+ # * ``%time``: will be replaced by the current time.
41
+ # * ``%prefix``: the log level such as "ERROR" or "INFO".
42
+ # * ``%text``: the actual log message.
8
43
  #
9
44
  class RotatingInformer
10
45
  include Innate::Traited
@@ -24,16 +59,14 @@ module Ramaze
24
59
  #
25
60
  # base_dir is the directory where all log files will be stored
26
61
  #
27
- # time_format is the time format used to name the log files.
28
- # Possible formats are identical to those
29
- # accepted by Time.strftime
62
+ # time_format is the time format used to name the log files. Possible
63
+ # formats are identical to those accepted by Time.strftime
30
64
  #
31
- # log_levelse is an array describing what kind of messages
32
- # that the log receives. The array may contain
33
- # any or all of the symbols :debug, :error, :info and/or :warn
65
+ # log_levelse is an array describing what kind of messages that the log
66
+ # receives. The array may contain any or all of the symbols :debug,
67
+ # :error, :info and/or :warn
34
68
  #
35
69
  # @example
36
- #
37
70
  # # Creates logs in directory called logs. The generated filenames
38
71
  # # will be in the form YYYY-MM-DD.log
39
72
  # RotatingInformer.new('logs')
@@ -57,7 +90,7 @@ module Ramaze
57
90
  send :base_dir=, base_dir, true
58
91
 
59
92
  @time_format = time_format
60
- @log_levels = log_levels
93
+ @log_levels = log_levels
61
94
 
62
95
  # Keep track of log shutdown (to prevent StackErrors due to recursion)
63
96
  @in_shutdown = false
@@ -66,13 +99,12 @@ module Ramaze
66
99
  ##
67
100
  # Set the base directory for log files
68
101
  #
69
- # If this method is called with the raise_exception
70
- # parameter set to true the method will raise an exception
71
- # if the specified directory does not exist or is unwritable.
102
+ # If this method is called with the raise_exception parameter set to true
103
+ # the method will raise an exception if the specified directory does not
104
+ # exist or is unwritable.
72
105
  #
73
- # If raise_exception is set to false, the method will just
74
- # silently fail if the specified directory does not exist
75
- # or is unwritable.
106
+ # If raise_exception is set to false, the method will just silently fail
107
+ # if the specified directory does not exist or is unwritable.
76
108
  #
77
109
  # @param [String] directory The base directory specified by the developer.
78
110
  # @param [Bool] raise_exception Boolean that indicates if an exception
@@ -119,7 +151,7 @@ module Ramaze
119
151
  # @param [String] tag The type of message we're logging.
120
152
  # @param [Array] messages An array of messages to log.
121
153
  #
122
- def log tag, *messages
154
+ def log(tag, *messages)
123
155
  return unless @log_levels.include?(tag)
124
156
 
125
157
  # Update current log
@@ -144,7 +176,7 @@ module Ramaze
144
176
  # @param [String] text
145
177
  # @param [Integer] time
146
178
  #
147
- def log_interpolate prefix, text, time = timestamp
179
+ def log_interpolate(prefix, text, time = timestamp)
148
180
  message = class_trait[:format].dup
149
181
 
150
182
  vars = { '%time' => time, '%prefix' => prefix, '%text' => text }
@@ -155,8 +187,9 @@ module Ramaze
155
187
 
156
188
  ##
157
189
  # This uses timestamp trait or a date in the format of
158
- # %Y-%m-%d %H:%M:%S
159
- # # => "2007-01-19 21:09:32"
190
+ # ``%Y-%m-%d %H:%M:%S``
191
+ #
192
+ # @return [String]
160
193
  #
161
194
  def timestamp
162
195
  mask = class_trait[:timestamp]
@@ -164,7 +197,9 @@ module Ramaze
164
197
  end
165
198
 
166
199
  ##
167
- # Is @out closed?
200
+ # Is ``@out`` closed?
201
+ #
202
+ # @return [TrueClass|FalseClass]
168
203
  #
169
204
  def closed?
170
205
  @out.respond_to?(:closed?) && @out.closed?
@@ -176,19 +211,19 @@ module Ramaze
176
211
  # @author Yorick Peterse
177
212
  # @param [String] message The data that has to be logged.
178
213
  #
179
- def write message
214
+ def write(message)
180
215
  log(:info, message)
181
216
  end
182
217
 
183
218
  private
184
219
 
185
220
  ##
186
- # Checks whether current filename is still valid.
187
- # If not, update the current log to point at the new
188
- # filename
221
+ # Checks whether current filename is still valid. If not, update the
222
+ # current log to point at the new filename.
189
223
  #
190
224
  def update_current_log
191
225
  out = File.join(@base_dir, Time.now.strftime(@time_format))
226
+
192
227
  if @out.nil? || @out.path != out
193
228
  # Close old log if necessary
194
229
  shutdown unless @out.nil? || closed?
@@ -4,14 +4,6 @@
4
4
 
5
5
  require 'syslog'
6
6
 
7
- # Add aliases for the levelnames used by Ramaze logging
8
- module Syslog
9
- alias dev debug
10
- alias warn warning
11
- alias error err
12
- module_function :dev, :warn, :error
13
- end
14
-
15
7
  module Ramaze
16
8
  module Logger
17
9
  ##
@@ -21,19 +13,25 @@ module Ramaze
21
13
  class Syslog
22
14
  include Logging
23
15
 
16
+ # Hash containing various method aliases. Rbx and Jruby don't seem to like
17
+ # the combination of alias() and module_function() so this works around
18
+ # that.
19
+ ALIASES = {:dev => :debug, :warn => :warning, :error => :err}
20
+
24
21
  ##
25
22
  # Open the syslog library, if it is allready open, we reopen it using the
26
- # new argument list. The argument list is passed on to the Syslog library
27
- # so please check that, and man syslog for detailed information.
23
+ # new argument list. The argument list is passed on to the Syslog library
24
+ # so please check that, and man syslog for detailed information.
25
+ #
28
26
  # There are 3 parameters:
29
27
  #
30
- # ident: The identification used in the log file, defaults to $0
31
- # options: defaults to Syslog::LOG_PID | Syslog::LOG_CONS
32
- # facility: defaults to Syslog::LOG_USER
28
+ # * ident: The identification used in the log file, defaults to $0
29
+ # * options: defaults to Syslog::LOG_PID | Syslog::LOG_CONS
30
+ # * facility: defaults to Syslog::LOG_USER
33
31
  #
34
- def initialize( *args )
32
+ def initialize(*args)
35
33
  ::Syslog.close if ::Syslog.opened?
36
- ::Syslog.open( *args )
34
+ ::Syslog.open(*args)
37
35
  end
38
36
 
39
37
  ##
@@ -41,8 +39,15 @@ module Ramaze
41
39
  # We simply return if the log was closed for some reason, this behavior
42
40
  # was copied from Informer. We do not handle levels here. This will
43
41
  # be done by te syslog daemon based on it's configuration.
42
+ #
44
43
  def log(tag, *messages)
45
44
  return if !::Syslog.opened?
45
+ tag = tag.to_sym
46
+
47
+ if ALIASES.key?(tag)
48
+ tag = ALIASES[tag]
49
+ end
50
+
46
51
  ::Syslog.send(tag, *messages)
47
52
  end
48
53
 
@@ -11,7 +11,8 @@ module Ramaze
11
11
  # Informer for the XOSD notification system for X11.
12
12
  #
13
13
  # You can install the ruby-bindings with:
14
- # gem install xosd.
14
+ #
15
+ # gem install xosd.
15
16
  #
16
17
  class Xosd < ::Xosd
17
18
  attr_accessor :options
@@ -2,6 +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
+ ##
5
6
  # High performant source reloader
6
7
  #
7
8
  # This class acts as Rack middleware.
@@ -24,6 +25,7 @@ module Ramaze
24
25
  #
25
26
  # A number of hooks will be executed during the reload cycle, see
26
27
  # Ramaze::ReloaderHooks for more information.
28
+ #
27
29
  class Reloader
28
30
  OPTIONS = {
29
31
  # At most check every n seconds
@@ -19,11 +19,13 @@ module Ramaze
19
19
  # Sets any arguments passed as @instance_variables for the current action.
20
20
  #
21
21
  # Usage:
22
- # request.params # => {'name' => 'manveru', 'q' => 'google', 'lang' => 'de'}
23
- # request.to_ivs(:name, :q)
24
- # @q # => 'google'
25
- # @name # => 'manveru'
26
- # @lang # => nil
22
+ #
23
+ # request.params # => {'name' => 'manveru', 'q' => 'google', 'lang' => 'de'}
24
+ # request.to_ivs(:name, :q)
25
+ #
26
+ # @q # => 'google'
27
+ # @name # => 'manveru'
28
+ # @lang # => nil
27
29
  #
28
30
  def to_instance_variables(*args)
29
31
  instance = Current.action.instance
@@ -49,8 +51,7 @@ module Ramaze
49
51
  #
50
52
  # Usage:
51
53
  #
52
- # request.accept_language
53
- # # => ['en-us', 'en', 'de-at', 'de']
54
+ # request.accept_language # => ['en-us', 'en', 'de-at', 'de']
54
55
  #
55
56
  # @param [String #to_s] string the value of HTTP_ACCEPT_LANGUAGE
56
57
  # @return [Array] list of locales
@@ -67,14 +68,14 @@ module Ramaze
67
68
  ##
68
69
  # Transform the HTTP_ACCEPT_LANGUAGE header into an Array with:
69
70
  #
70
- # [[lang, weight], [lang, weight], ...]
71
+ # [[lang, weight], [lang, weight], ...]
71
72
  #
72
73
  # This algorithm was taken and improved from the locales library.
73
74
  #
74
75
  # Usage:
75
76
  #
76
- # request.accept_language_with_weight
77
- # # => [["en-us", 1.0], ["en", 0.8], ["de-at", 0.5], ["de", 0.3]]
77
+ # request.accept_language_with_weight
78
+ # # => [["en-us", 1.0], ["en", 0.8], ["de-at", 0.5], ["de", 0.3]]
78
79
  #
79
80
  # @param [String #to_s] string the value of HTTP_ACCEPT_LANGUAGE
80
81
  # @return [Array] array of [lang, weight] arrays