ramaze 2008.06 → 2008.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -6
- data/Rakefile +33 -3
- data/bin/ramaze +18 -0
- data/doc/CHANGELOG +960 -0
- data/doc/LEGAL +5 -1
- data/doc/meta/announcement.txt +20 -36
- data/doc/tutorial/todolist.html +421 -313
- data/doc/tutorial/todolist.mkd +33 -16
- data/examples/app/blog/spec/blog.rb +3 -3
- data/examples/app/rapaste/controller/paste.rb +8 -1
- data/examples/app/rapaste/model/paste.rb +3 -0
- data/examples/app/rapaste/spec/rapaste.rb +3 -1
- data/examples/app/rapaste/start.rb +3 -2
- data/examples/app/sourceview/public/sourceview.js +2 -2
- data/examples/app/todolist/spec/todolist.rb +6 -6
- data/examples/app/todolist/template/index.xhtml +1 -1
- data/examples/app/whywiki/spec/whywiki.rb +2 -2
- data/examples/app/wikore/spec/wikore.rb +2 -2
- data/examples/app/wikore/src/model.rb +4 -3
- data/examples/app/wiktacular/spec/wiktacular.rb +7 -7
- data/examples/basic/simple.rb +2 -2
- data/examples/helpers/paginate.rb +71 -0
- data/examples/misc/simple_auth.rb +20 -8
- data/lib/proto/controller/init.rb +10 -0
- data/lib/proto/controller/main.rb +1 -3
- data/lib/proto/model/init.rb +4 -0
- data/lib/proto/public/dispatch.fcgi +1 -1
- data/lib/proto/spec/main.rb +2 -1
- data/lib/proto/start.rb +3 -3
- data/lib/proto/start.ru +1 -1
- data/lib/proto/view/error.xhtml +4 -4
- data/lib/ramaze.rb +8 -3
- data/lib/ramaze/action.rb +6 -6
- data/lib/ramaze/adapter.rb +1 -6
- data/lib/ramaze/adapter/base.rb +30 -27
- data/lib/ramaze/adapter/cgi.rb +1 -0
- data/lib/ramaze/cache.rb +1 -3
- data/lib/ramaze/cache/memcached.rb +3 -5
- data/lib/ramaze/contrib/auto_params.rb +2 -2
- data/lib/ramaze/contrib/auto_params/get_args.rb +2 -1
- data/lib/ramaze/contrib/gems.rb +17 -18
- data/lib/ramaze/contrib/gzip_filter.rb +22 -9
- data/lib/ramaze/contrib/maruku_uv.rb +59 -0
- data/lib/ramaze/contrib/profiling.rb +1 -1
- data/lib/ramaze/contrib/rest.rb +16 -13
- data/lib/ramaze/contrib/sequel/create_join.rb +25 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +129 -0
- data/lib/ramaze/contrib/sequel/image.rb +198 -0
- data/lib/ramaze/contrib/sequel/relation.rb +82 -0
- data/lib/ramaze/controller.rb +33 -34
- data/lib/ramaze/controller/resolve.rb +29 -9
- data/lib/ramaze/current.rb +60 -20
- data/lib/ramaze/current/request.rb +8 -7
- data/lib/ramaze/current/response.rb +15 -3
- data/lib/ramaze/current/session/flash.rb +8 -0
- data/lib/ramaze/dispatcher.rb +17 -9
- data/lib/ramaze/dispatcher/action.rb +4 -5
- data/lib/ramaze/dispatcher/directory.rb +1 -1
- data/lib/ramaze/dispatcher/error.rb +4 -4
- data/lib/ramaze/dispatcher/file.rb +4 -4
- data/lib/ramaze/gestalt.rb +15 -20
- data/lib/ramaze/helper/cgi.rb +7 -15
- data/lib/ramaze/helper/formatting.rb +41 -1
- data/lib/ramaze/helper/httpdigest.rb +20 -7
- data/lib/ramaze/helper/link.rb +4 -6
- data/lib/ramaze/helper/paginate.rb +233 -0
- data/lib/ramaze/helper/redirect.rb +1 -1
- data/lib/ramaze/helper/rest.rb +1 -1
- data/lib/ramaze/helper/thread.rb +17 -0
- data/lib/ramaze/helper/ultraviolet.rb +44 -0
- data/lib/ramaze/helper/user.rb +4 -9
- data/lib/ramaze/log.rb +2 -2
- data/lib/ramaze/log/analogger.rb +21 -23
- data/lib/ramaze/log/growl.rb +21 -23
- data/lib/ramaze/log/hub.rb +1 -1
- data/lib/ramaze/log/informer.rb +97 -99
- data/lib/ramaze/log/knotify.rb +14 -16
- data/lib/ramaze/log/logger.rb +11 -13
- data/lib/ramaze/log/logging.rb +61 -63
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/log/syslog.rb +41 -31
- data/lib/ramaze/log/xosd.rb +70 -72
- data/lib/ramaze/option.rb +9 -6
- data/lib/ramaze/option/holder.rb +5 -27
- data/lib/ramaze/reloader.rb +186 -0
- data/lib/ramaze/setup.rb +1 -1
- data/lib/ramaze/snippets.rb +13 -0
- data/lib/ramaze/snippets/array/put_within.rb +31 -24
- data/lib/ramaze/snippets/binding/locals.rb +23 -11
- data/lib/ramaze/snippets/dictionary.rb +2 -2
- data/lib/ramaze/snippets/fiber.rb +63 -0
- data/lib/ramaze/snippets/kernel/constant.rb +36 -21
- data/lib/ramaze/snippets/kernel/pretty_inspect.rb +12 -6
- data/lib/ramaze/snippets/numeric/filesize_format.rb +24 -17
- data/lib/ramaze/snippets/numeric/time.rb +63 -0
- data/lib/ramaze/snippets/object/__dir__.rb +29 -0
- data/lib/ramaze/snippets/object/acquire.rb +40 -0
- data/lib/ramaze/snippets/object/instance_variable_defined.rb +16 -5
- data/lib/ramaze/snippets/object/pretty.rb +14 -4
- data/lib/ramaze/snippets/object/scope.rb +14 -7
- data/lib/ramaze/snippets/ordered_set.rb +25 -14
- data/lib/ramaze/snippets/proc/locals.rb +17 -9
- data/lib/ramaze/snippets/ramaze/deprecated.rb +13 -0
- data/lib/ramaze/snippets/ramaze/fiber.rb +24 -0
- data/lib/ramaze/snippets/ramaze/state.rb +86 -0
- data/lib/ramaze/snippets/ramaze/struct.rb +45 -0
- data/lib/ramaze/snippets/string/camel_case.rb +13 -8
- data/lib/ramaze/snippets/string/color.rb +24 -20
- data/lib/ramaze/snippets/string/each.rb +14 -3
- data/lib/ramaze/snippets/string/end_with.rb +20 -0
- data/lib/ramaze/snippets/string/esc.rb +26 -21
- data/lib/ramaze/snippets/string/ord.rb +12 -6
- data/lib/ramaze/snippets/string/snake_case.rb +13 -7
- data/lib/ramaze/snippets/string/start_with.rb +16 -5
- data/lib/ramaze/snippets/string/unindent.rb +23 -15
- data/lib/ramaze/snippets/thread/into.rb +3 -3
- data/lib/ramaze/spec/helper/bacon.rb +5 -5
- data/lib/ramaze/spec/helper/mock_http.rb +1 -1
- data/lib/ramaze/spec/helper/pretty_output.rb +2 -2
- data/lib/ramaze/spec/helper/snippets.rb +8 -0
- data/lib/ramaze/template.rb +4 -1
- data/lib/ramaze/template/ezamar/textpow.syntax +34 -0
- data/lib/ramaze/template/maruku.rb +34 -0
- data/lib/ramaze/template/tagz.rb +2 -2
- data/lib/ramaze/template/xslt.rb +2 -2
- data/lib/ramaze/tool/create.rb +27 -53
- data/lib/ramaze/tool/localize.rb +8 -4
- data/lib/ramaze/tool/mime.rb +11 -1
- data/lib/ramaze/tool/project_creator.rb +110 -0
- data/lib/ramaze/trinity.rb +4 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/vendor/bacon.rb +323 -0
- data/rake_tasks/gem.rake +10 -1
- data/rake_tasks/maintenance.rake +40 -2
- data/rake_tasks/metric.rake +24 -0
- data/rake_tasks/release.rake +17 -4
- data/rake_tasks/spec.rake +1 -2
- data/ramaze.gemspec +549 -495
- data/spec/contrib/auto_params.rb +3 -3
- data/spec/contrib/profiling.rb +2 -2
- data/spec/examples/simple_auth.rb +2 -2
- data/spec/examples/templates/template_haml.rb +0 -2
- data/spec/ramaze/action/file_cache.rb +22 -0
- data/spec/ramaze/adapter.rb +2 -2
- data/spec/ramaze/controller/actionless_templates.rb +1 -1
- data/spec/ramaze/controller/subclass.rb +15 -0
- data/spec/ramaze/controller/template_resolving.rb +1 -1
- data/spec/ramaze/controller/view/bar.xhtml +1 -0
- data/spec/ramaze/controller/view/base/another.xhtml +1 -0
- data/spec/ramaze/current/session.rb +1 -1
- data/spec/ramaze/dispatcher/file.rb +2 -2
- data/spec/ramaze/helper/aspect.rb +26 -17
- data/spec/ramaze/helper/formatting.rb +13 -0
- data/spec/ramaze/log/informer.rb +10 -10
- data/spec/ramaze/log/syslog.rb +67 -4
- data/spec/ramaze/rewrite.rb +1 -1
- data/spec/ramaze/route.rb +1 -1
- data/spec/ramaze/struct.rb +47 -0
- data/spec/ramaze/template/markaby.rb +1 -1
- data/spec/ramaze/template/tagz.rb +1 -1
- data/spec/snippets/binding/locals.rb +9 -0
- data/spec/snippets/numeric/time.rb +12 -0
- data/spec/snippets/{kernel → object}/__dir__.rb +0 -0
- data/spec/snippets/{kernel → object}/acquire.rb +0 -0
- metadata +90 -81
- data/cache.yaml +0 -7
- data/examples/app/rammit/spec/rammit.rb +0 -31
- data/examples/app/rammit/src/controller/main.rb +0 -3
- data/examples/app/rammit/src/controller/page.rb +0 -16
- data/examples/app/rammit/src/model.rb +0 -33
- data/examples/app/rammit/start.rb +0 -8
- data/examples/app/rammit/template/index.xhtml +0 -14
- data/examples/app/rammit/template/page/view.xhtml +0 -4
- data/lib/ramaze/snippets/kernel/__dir__.rb +0 -23
- data/lib/ramaze/snippets/kernel/acquire.rb +0 -34
- data/lib/ramaze/snippets/object/thread_accessor.rb +0 -5
- data/lib/ramaze/snippets/ramaze/thread_accessor.rb +0 -58
- data/lib/ramaze/snippets/struct/fill.rb +0 -23
- data/lib/ramaze/snippets/struct/values_at.rb +0 -39
- data/lib/ramaze/snippets/symbol/to_proc.rb +0 -24
- data/lib/ramaze/sourcereload.rb +0 -176
- data/spec/snippets/struct/fill.rb +0 -26
- data/spec/snippets/struct/values_at.rb +0 -52
- data/spec/snippets/symbol/to_proc.rb +0 -13
@@ -0,0 +1,168 @@
|
|
1
|
+
module Ramaze
|
2
|
+
|
3
|
+
module Logger
|
4
|
+
|
5
|
+
# A customized logger (based on Informer) that creates multiple log files based on time
|
6
|
+
|
7
|
+
class RotatingInformer
|
8
|
+
|
9
|
+
include Logging
|
10
|
+
|
11
|
+
attr_accessor :time_format, :log_levels
|
12
|
+
attr_reader :base_dir
|
13
|
+
|
14
|
+
# parameter for Time.now.strftime
|
15
|
+
trait :timestamp => "%Y-%m-%d %H:%M:%S"
|
16
|
+
|
17
|
+
# This is how the final output is arranged.
|
18
|
+
trait :format => "[%time] %prefix %text"
|
19
|
+
|
20
|
+
# Create a new instance of RotatingInformer.
|
21
|
+
#
|
22
|
+
# base_dir is the directory where all log files will be stored
|
23
|
+
#
|
24
|
+
# time_format is the time format used to name the log files.
|
25
|
+
# Possible formats are identical to those
|
26
|
+
# accepted by Time.strftime
|
27
|
+
#
|
28
|
+
# log_levelse is an array describing what kind of messages
|
29
|
+
# that the log receives. The array may contain
|
30
|
+
# any or all of the symbols :debug, :error, :info and/or :warn
|
31
|
+
#
|
32
|
+
# Examples:
|
33
|
+
# RotatingInformer.new('logs')
|
34
|
+
# #=> Creates logs in directory called logs.
|
35
|
+
# The generated filenames will be in the
|
36
|
+
# form YYYY-MM-DD.log
|
37
|
+
# RotatingInformer.new('logs', '%Y-%m.txt')
|
38
|
+
# #=> Creates logs in directory called logs.
|
39
|
+
# The generated filenames will be in the
|
40
|
+
# form YYYY-MM.txt
|
41
|
+
# RotatingInformer.new('logs', '%Y-%m.txt', [:error])
|
42
|
+
# #=> Creates logs in directory called logs.
|
43
|
+
# The generated filenames will be in the
|
44
|
+
# form YYYY-MM.txt. Only errors will be
|
45
|
+
# logged to the files.
|
46
|
+
|
47
|
+
def initialize(base_dir, time_format = '%Y-%m-%d.log', log_levels = [:debug, :error, :info, :warn])
|
48
|
+
# Verify and set base directory
|
49
|
+
send :base_dir=, base_dir, true
|
50
|
+
|
51
|
+
@time_format = time_format
|
52
|
+
@log_levels = log_levels
|
53
|
+
|
54
|
+
# Keep track of log shutdown (to prevent StackErrors due to recursion)
|
55
|
+
@in_shutdown = false
|
56
|
+
end
|
57
|
+
|
58
|
+
# Set the base directory for log files
|
59
|
+
#
|
60
|
+
# If this method is called with the raise_exception
|
61
|
+
# parameter set to true the method will raise an exception
|
62
|
+
# if the specified directory does not exist or is unwritable.
|
63
|
+
#
|
64
|
+
# If raise_exception is set to false, the method will just
|
65
|
+
# silently fail if the specified directory does not exist
|
66
|
+
# or is unwritable
|
67
|
+
|
68
|
+
def base_dir=(directory, raise_exception = false)
|
69
|
+
# Expand directory path
|
70
|
+
base_dir = File.expand_path(directory)
|
71
|
+
# Verify that directory path exists
|
72
|
+
if File.exist?(base_dir)
|
73
|
+
# Verify that directory path is a directory
|
74
|
+
if File.directory?(base_dir)
|
75
|
+
# Verify that directory path is writable
|
76
|
+
if File.writable?(base_dir)
|
77
|
+
@base_dir = base_dir
|
78
|
+
else
|
79
|
+
raise Exception.new("#{base_dir} is not writable") if raise_exception
|
80
|
+
end
|
81
|
+
else
|
82
|
+
raise Exception.new("#{base_dir} is not a directory") if raise_exception
|
83
|
+
end
|
84
|
+
else
|
85
|
+
raise Exception.new("#{base_dir} does not exist.") if raise_exception
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Close the file we log to if it isn't closed already.
|
90
|
+
|
91
|
+
def shutdown
|
92
|
+
if @out.respond_to?(:close)
|
93
|
+
unless @in_shutdown
|
94
|
+
@in_shutdown = true
|
95
|
+
Log.debug("close, #{@out.inspect}")
|
96
|
+
@in_shutdown = false
|
97
|
+
end
|
98
|
+
@out.close
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# Integration to Logging.
|
103
|
+
|
104
|
+
def log tag, *messages
|
105
|
+
|
106
|
+
return unless @log_levels.include?(tag)
|
107
|
+
|
108
|
+
# Update current log
|
109
|
+
update_current_log
|
110
|
+
|
111
|
+
messages.flatten!
|
112
|
+
|
113
|
+
prefix = tag.to_s.upcase.ljust(5)
|
114
|
+
|
115
|
+
messages.each do |message|
|
116
|
+
@out.puts(log_interpolate(prefix, message))
|
117
|
+
end
|
118
|
+
|
119
|
+
@out.flush if @out.respond_to?(:flush)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Takes the prefix (tag), text and timestamp and applies it to
|
123
|
+
# the :format trait.
|
124
|
+
|
125
|
+
def log_interpolate prefix, text, time = timestamp
|
126
|
+
message = class_trait[:format].dup
|
127
|
+
|
128
|
+
vars = { '%time' => time, '%prefix' => prefix, '%text' => text }
|
129
|
+
vars.each{|from, to| message.gsub!(from, to) }
|
130
|
+
|
131
|
+
message
|
132
|
+
end
|
133
|
+
|
134
|
+
# This uses Global.inform_timestamp or a date in the format of
|
135
|
+
# %Y-%m-%d %H:%M:%S
|
136
|
+
# # => "2007-01-19 21:09:32"
|
137
|
+
|
138
|
+
def timestamp
|
139
|
+
mask = class_trait[:timestamp]
|
140
|
+
Time.now.strftime(mask || "%Y-%m-%d %H:%M:%S")
|
141
|
+
end
|
142
|
+
|
143
|
+
# is @out closed?
|
144
|
+
|
145
|
+
def closed?
|
146
|
+
@out.respond_to?(:closed?) && @out.closed?
|
147
|
+
end
|
148
|
+
|
149
|
+
private
|
150
|
+
|
151
|
+
# Checks whether current filename is still valid.
|
152
|
+
# If not, update the current log to point at the new
|
153
|
+
# filename
|
154
|
+
|
155
|
+
def update_current_log
|
156
|
+
out = File.join(@base_dir, Time.now.strftime(@time_format))
|
157
|
+
if @out.nil? || @out.path != out
|
158
|
+
# Close old log if necessary
|
159
|
+
shutdown unless @out.nil? || closed?
|
160
|
+
|
161
|
+
# Start new log
|
162
|
+
@out = File.open(out, 'ab+')
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
end
|
data/lib/ramaze/log/syslog.rb
CHANGED
@@ -1,41 +1,51 @@
|
|
1
1
|
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# Copyright (c) 2008 rob@rebeltechnologies.nl
|
2
3
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
4
|
|
4
5
|
require 'syslog'
|
5
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
|
+
|
6
15
|
module Ramaze
|
7
|
-
module Logging
|
8
16
|
module Logger
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
# Logger class for writing to syslog. It is a *very* thin wrapper
|
18
|
+
# around the Syslog library.
|
19
|
+
class Syslog
|
20
|
+
include Logging
|
21
|
+
|
22
|
+
# Open the syslog library, if it is allready open, we reopen it using the
|
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
|
+
# There are 3 parameters:
|
26
|
+
#
|
27
|
+
# ident: The identification used in the log file, defaults to $0
|
28
|
+
# options: defaults to Syslog::LOG_PID | Syslog::LOG_CONS
|
29
|
+
# facility: defaults to Syslog::LOG_USER
|
30
|
+
#
|
31
|
+
def initialize( *args )
|
32
|
+
::Syslog.close if ::Syslog.opened?
|
33
|
+
::Syslog.open( *args )
|
34
|
+
end
|
35
|
+
|
36
|
+
# just sends all messages received to ::Syslog
|
37
|
+
# We simply return if the log was closed for some reason, this behavior
|
38
|
+
# was copied from Informer. We do not handle levels here. This will
|
39
|
+
# be done by te syslog daemon based on it's configuration.
|
40
|
+
def log(tag, *messages)
|
41
|
+
return if !::Syslog.opened?
|
42
|
+
::Syslog.send(tag, *messages)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Has to call the modules singleton-method.
|
46
|
+
def inspect
|
47
|
+
::Syslog.inspect
|
48
|
+
end
|
19
49
|
end
|
20
|
-
|
21
|
-
# alias for default syslog methods so they match ramaze
|
22
|
-
alias error err
|
23
|
-
alias warn warning
|
24
|
-
alias dev debug
|
25
|
-
|
26
|
-
# just sends all messages received to ::Syslog
|
27
|
-
def inform(tag, *args)
|
28
|
-
self.__send__(tag, *args)
|
29
|
-
end
|
30
|
-
|
31
|
-
public :error, :warn
|
32
|
-
|
33
|
-
# Has to call the modules singleton-method.
|
34
|
-
def inspect
|
35
|
-
::Syslog.inspect
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
50
|
end
|
40
|
-
end
|
41
51
|
end
|
data/lib/ramaze/log/xosd.rb
CHANGED
@@ -6,89 +6,87 @@ require 'xosd'
|
|
6
6
|
require 'thread'
|
7
7
|
|
8
8
|
module Ramaze
|
9
|
-
module
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
9
|
+
module Logger
|
10
|
+
|
11
|
+
# Informer for the XOSD notification system for X11.
|
12
|
+
#
|
13
|
+
# You can install the ruby-bindings with:
|
14
|
+
# gem install xosd.
|
15
|
+
|
16
|
+
class Xosd < ::Xosd
|
17
|
+
attr_accessor :options
|
18
|
+
|
19
|
+
include Logging
|
20
|
+
|
21
|
+
DEFAULT = {
|
22
|
+
:font_size => 20,
|
23
|
+
:font => "-*-*-*-*-*-*-%d-*-*-*-*-*-*-*",
|
24
|
+
:align => 'center',
|
25
|
+
:color => '#FFFFFF',
|
26
|
+
:lines => 3,
|
27
|
+
:valign => 'top',
|
28
|
+
:timeout => 3,
|
29
|
+
:outline_color => "#000000",
|
30
|
+
:outline_width => 1,
|
31
|
+
:vertical_offset => 20,
|
32
|
+
:colors => {
|
33
|
+
:error => "#FF0000",
|
34
|
+
:info => "#00FF00",
|
35
|
+
:warn => "#EAA61E",
|
36
|
+
:debug => "#FFFF00"
|
37
|
+
},
|
38
|
+
}
|
39
|
+
|
40
|
+
# keys to ignore when setting the options to the instance.
|
41
|
+
IGNORE = [:colors, :font_size, :lines]
|
42
|
+
|
43
|
+
# Here new messages are pushed to eventually displaying them.
|
44
|
+
QUEUE = Queue.new
|
45
|
+
|
46
|
+
# Create a new instance, valid options are in DEFAULT.
|
47
|
+
# In the background a new thread will be running that checks the QUEUE
|
48
|
+
# and processes all messages that are being sent to it.
|
49
|
+
# This is done to make output nicer and readable.
|
50
|
+
|
51
|
+
def initialize(options = {})
|
52
|
+
@options = DEFAULT.merge(options)
|
53
|
+
|
54
|
+
super(@options[:lines])
|
55
|
+
|
56
|
+
@options.each do |key, value|
|
57
|
+
next if IGNORE.include?(key)
|
58
|
+
value %= @options[:font_size] if key == :font
|
59
|
+
send("#{key}=", value)
|
60
|
+
end
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
Thread.new(self) do |xosd|
|
63
|
+
loop do
|
64
|
+
items = []
|
65
|
+
lines = xosd.options[:lines]
|
66
|
+
items << QUEUE.shift until QUEUE.empty? or items.size >= lines
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
unless items.empty?
|
69
|
+
# pad up with empty lines to avoid dragging around old messages.
|
70
|
+
items << [:info, ' '] until items.size >= lines
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
72
|
+
items.each_with_index do |(tag, message), i|
|
73
|
+
xosd.color = xosd.options[:colors][tag.to_sym]
|
74
|
+
xosd.display(message, i)
|
77
75
|
end
|
78
|
-
sleep xosd.options[:timeout]
|
79
76
|
end
|
77
|
+
sleep xosd.options[:timeout]
|
80
78
|
end
|
81
79
|
end
|
80
|
+
end
|
82
81
|
|
83
|
-
|
82
|
+
# pushes all messages it gets on the QUEUE for further processing.
|
84
83
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
84
|
+
def log(tag, *messages)
|
85
|
+
messages.each do |message|
|
86
|
+
QUEUE << [tag, message]
|
89
87
|
end
|
90
88
|
end
|
91
|
-
|
92
89
|
end
|
90
|
+
|
93
91
|
end
|
94
92
|
end
|
data/lib/ramaze/option.rb
CHANGED
@@ -12,7 +12,7 @@ module Ramaze
|
|
12
12
|
"fcgi" => "Fcgi",
|
13
13
|
"thin" => "Thin",
|
14
14
|
"ebb" => "Ebb",
|
15
|
-
"cgi" => "
|
15
|
+
"cgi" => "Cgi",
|
16
16
|
"lsws" => "LSWS",
|
17
17
|
"scgi" => "SCGI",
|
18
18
|
"webrick" => "WEBrick",
|
@@ -73,9 +73,9 @@ module Ramaze
|
|
73
73
|
:controllers, Set.new
|
74
74
|
|
75
75
|
o "Instruction for daemonize, only works with bin/ramaze for now",
|
76
|
-
:daemonize, '
|
76
|
+
:daemonize, '', :cli => [:start, :stop]
|
77
77
|
|
78
|
-
o "Turn on customized error pages.",
|
78
|
+
o "Turn on customized error pages. Use Rack::ShowException otherwise.",
|
79
79
|
:error_page, true, :cli => true
|
80
80
|
|
81
81
|
o "Caching actions to the filesystem in Global.public_root",
|
@@ -103,10 +103,10 @@ module Ramaze
|
|
103
103
|
:mapping, {}
|
104
104
|
|
105
105
|
o "Activate middleware",
|
106
|
-
:middleware,
|
106
|
+
:middleware, true
|
107
107
|
|
108
108
|
o "For your own modes to decide on",
|
109
|
-
:mode, :live, :cli => [:live, :dev]
|
109
|
+
:mode, :live, :cli => [:live, :dev, :spec]
|
110
110
|
|
111
111
|
o "The place ramaze was started from, useful mostly for debugging",
|
112
112
|
:origin, :main
|
@@ -117,6 +117,9 @@ module Ramaze
|
|
117
117
|
o "Specify directory to serve static files",
|
118
118
|
:public_root, "public", :cli => "public"
|
119
119
|
|
120
|
+
o "Prefix for incoming and outgoing links",
|
121
|
+
:prefix, '/'
|
122
|
+
|
120
123
|
o "Record all Request objects by assigning a filtering Proc to me.",
|
121
124
|
:record, false
|
122
125
|
|
@@ -141,7 +144,7 @@ module Ramaze
|
|
141
144
|
o "What signal to trap to call Ramaze::shutdown",
|
142
145
|
:shutdown_trap, "SIGINT"
|
143
146
|
|
144
|
-
o "Interval in seconds of the
|
147
|
+
o "Interval in seconds of the Reloader",
|
145
148
|
:sourcereload, 3, :cli => 3
|
146
149
|
|
147
150
|
o "Test before start if adapters will be able to connect",
|