ramaze 2011.01.30 → 2011.07.25
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.mailmap +2 -0
- data/.rvmrc +1 -0
- data/README.md +119 -197
- data/Rakefile +14 -97
- data/bin/ramaze +6 -14
- data/doc/AUTHORS +8 -4
- data/doc/CHANGELOG +3784 -3339
- data/examples/app/chat/start.rb +2 -2
- data/lib/proto/app.rb +2 -3
- data/lib/proto/config.ru +4 -5
- data/lib/proto/controller/init.rb +11 -4
- data/lib/proto/controller/main.rb +12 -7
- data/lib/proto/layout/default.xhtml +56 -23
- data/lib/proto/model/init.rb +3 -1
- data/lib/proto/public/css/grid.css +107 -0
- data/lib/proto/public/css/layout.css +81 -0
- data/lib/proto/public/css/reset.css +123 -0
- data/lib/proto/public/css/text.css +109 -0
- data/lib/proto/public/images/bg.png +0 -0
- data/lib/proto/spec/main.rb +2 -2
- data/lib/proto/start.rb +11 -1
- data/lib/proto/view/index.xhtml +27 -23
- data/lib/ramaze.rb +0 -1
- data/lib/ramaze/app.rb +85 -12
- data/lib/ramaze/app_graph.rb +107 -0
- data/lib/ramaze/bin/console.rb +87 -0
- data/lib/ramaze/bin/create.rb +94 -0
- data/lib/ramaze/bin/helper.rb +107 -0
- data/lib/ramaze/bin/restart.rb +95 -0
- data/lib/ramaze/bin/runner.rb +141 -0
- data/lib/ramaze/bin/start.rb +206 -0
- data/lib/ramaze/bin/status.rb +152 -0
- data/lib/ramaze/bin/stop.rb +112 -0
- data/lib/ramaze/cache.rb +9 -4
- data/lib/ramaze/cache/localmemcache.rb +10 -13
- data/lib/ramaze/cache/lru.rb +49 -7
- data/lib/ramaze/cache/memcache.rb +170 -92
- data/lib/ramaze/cache/sequel.rb +301 -118
- data/lib/ramaze/controller.rb +108 -9
- data/lib/ramaze/controller/default.rb +15 -2
- data/lib/ramaze/current.rb +14 -2
- data/lib/ramaze/dependencies.rb +46 -0
- data/lib/ramaze/files.rb +38 -3
- data/lib/ramaze/gestalt.rb +12 -12
- data/lib/ramaze/helper.rb +0 -2
- data/lib/ramaze/helper/auth.rb +30 -23
- data/lib/ramaze/helper/blue_form.rb +175 -126
- data/lib/ramaze/helper/csrf.rb +76 -91
- data/lib/ramaze/helper/email.rb +105 -0
- data/lib/ramaze/helper/erector.rb +16 -15
- data/lib/ramaze/helper/gestalt.rb +2 -2
- data/lib/ramaze/helper/layout.rb +89 -73
- data/lib/ramaze/helper/link.rb +7 -6
- data/lib/ramaze/helper/localize.rb +6 -5
- data/lib/ramaze/helper/markaby.rb +25 -23
- data/lib/ramaze/helper/maruku.rb +3 -3
- data/lib/ramaze/helper/paginate.rb +19 -27
- data/lib/ramaze/helper/remarkably.rb +3 -3
- data/lib/ramaze/helper/request_accessor.rb +3 -3
- data/lib/ramaze/helper/send_file.rb +12 -8
- data/lib/ramaze/helper/simple_captcha.rb +5 -6
- data/lib/ramaze/helper/stack.rb +7 -4
- data/lib/ramaze/helper/tagz.rb +10 -11
- data/lib/ramaze/helper/thread.rb +19 -16
- data/lib/ramaze/helper/ultraviolet.rb +7 -4
- data/lib/ramaze/helper/user.rb +40 -21
- data/lib/ramaze/helper/xhtml.rb +29 -20
- data/lib/ramaze/log.rb +3 -11
- data/lib/ramaze/log/analogger.rb +5 -4
- data/lib/ramaze/log/growl.rb +9 -7
- data/lib/ramaze/log/hub.rb +3 -5
- data/lib/ramaze/log/informer.rb +15 -12
- data/lib/ramaze/log/knotify.rb +3 -5
- data/lib/ramaze/log/logger.rb +3 -5
- data/lib/ramaze/log/logging.rb +6 -8
- data/lib/ramaze/log/rotatinginformer.rb +27 -17
- data/lib/ramaze/log/syslog.rb +7 -7
- data/lib/ramaze/log/xosd.rb +3 -5
- data/lib/ramaze/middleware_compiler.rb +27 -4
- data/lib/ramaze/reloader.rb +50 -12
- data/lib/ramaze/reloader/watch_inotify.rb +4 -5
- data/lib/ramaze/reloader/watch_stat.rb +3 -3
- data/lib/ramaze/request.rb +18 -8
- data/lib/ramaze/response.rb +38 -7
- data/lib/ramaze/rest.rb +36 -0
- data/lib/ramaze/setup.rb +101 -31
- data/lib/ramaze/spec.rb +1 -1
- data/lib/ramaze/spec/bacon.rb +6 -3
- data/lib/ramaze/spec/helper/bacon.rb +0 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +2 -11
- data/lib/ramaze/view/erector.rb +46 -31
- data/lib/ramaze/view/erubis.rb +7 -3
- data/lib/ramaze/view/ezamar.rb +7 -3
- data/lib/ramaze/view/gestalt.rb +9 -3
- data/lib/ramaze/view/haml.rb +7 -3
- data/lib/ramaze/view/liquid.rb +3 -3
- data/lib/ramaze/view/lokar.rb +7 -3
- data/lib/ramaze/view/mustache.rb +11 -5
- data/lib/ramaze/view/nagoro.rb +3 -3
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/slippers.rb +40 -13
- data/lib/ramaze/view/tagz.rb +9 -5
- data/ramaze.gemspec +23 -128
- data/spec/helper.rb +5 -0
- data/spec/ramaze/bin/app/config.ru +11 -0
- data/spec/ramaze/bin/create.rb +28 -0
- data/spec/ramaze/bin/runner.rb +30 -0
- data/spec/ramaze/bin/start.rb +38 -0
- data/spec/ramaze/cache/memcache.rb +10 -3
- data/spec/ramaze/cache/sequel.rb +7 -0
- data/spec/ramaze/controller/provide_inheritance.rb +0 -10
- data/spec/ramaze/dispatcher/file.rb +19 -15
- data/spec/ramaze/helper/auth.rb +10 -9
- data/spec/ramaze/helper/blue_form.rb +121 -68
- data/spec/ramaze/helper/email.rb +69 -0
- data/spec/ramaze/helper/layout.rb +12 -15
- data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
- data/spec/ramaze/helper/user.rb +2 -0
- data/spec/ramaze/log/growl.rb +14 -1
- data/spec/{contrib → ramaze}/rest.rb +1 -1
- data/spec/ramaze/session/memcache.rb +2 -2
- data/spec/ramaze/view/sass.rb +1 -1
- data/tasks/bacon.rake +3 -3
- data/tasks/gem.rake +17 -18
- data/tasks/rcov.rake +2 -3
- data/tasks/release.rake +8 -65
- data/tasks/setup.rake +10 -8
- data/tasks/todo.rake +9 -5
- data/tasks/yard.rake +3 -2
- metadata +105 -397
- data/MANIFEST +0 -532
- data/TODO.md +0 -19
- data/benchmark/bench_templates/bench.rb +0 -67
- data/benchmark/bench_templates/view/large.erb +0 -79
- data/benchmark/bench_templates/view/large.haml +0 -41
- data/benchmark/bench_templates/view/large.lok +0 -79
- data/benchmark/bench_templates/view/large.xhtml +0 -79
- data/benchmark/bench_templates/view/small.erb +0 -21
- data/benchmark/bench_templates/view/small.haml +0 -12
- data/benchmark/bench_templates/view/small.lok +0 -21
- data/benchmark/bench_templates/view/small.xhtml +0 -21
- data/benchmark/results.txt +0 -131
- data/benchmark/run.rb +0 -355
- data/benchmark/suite/minimal.rb +0 -11
- data/benchmark/suite/no_informer.rb +0 -7
- data/benchmark/suite/no_sessions.rb +0 -9
- data/benchmark/suite/no_template.rb +0 -7
- data/benchmark/suite/simple.rb +0 -5
- data/benchmark/suite/template_erubis.rb +0 -8
- data/benchmark/suite/template_etanni.rb +0 -8
- data/benchmark/suite/template_ezamar.rb +0 -8
- data/benchmark/suite/template_haml.rb +0 -13
- data/benchmark/suite/template_liquid.rb +0 -11
- data/benchmark/suite/template_markaby.rb +0 -9
- data/benchmark/suite/template_nagoro.rb +0 -8
- data/benchmark/suite/template_redcloth.rb +0 -13
- data/benchmark/suite/template_tenjin.rb +0 -8
- data/benchmark/test.rb +0 -35
- data/doc/FAQ +0 -92
- data/doc/INSTALL +0 -92
- data/doc/TODO +0 -29
- data/doc/meta/announcement.txt +0 -119
- data/doc/meta/configuration.txt +0 -163
- data/doc/meta/internals.txt +0 -278
- data/doc/meta/users.kml +0 -64
- data/doc/tutorial/todolist.html +0 -1512
- data/doc/tutorial/todolist.txt +0 -920
- data/examples/app/sourceview/public/coderay.css +0 -104
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +0 -11
- data/examples/app/sourceview/public/jquery.treeview.css +0 -48
- data/examples/app/sourceview/public/jquery.treeview.js +0 -223
- data/examples/app/sourceview/public/sourceview.js +0 -52
- data/examples/app/sourceview/start.rb +0 -79
- data/examples/app/sourceview/view/index.haml +0 -59
- data/examples/helpers/httpdigest.rb +0 -107
- data/lib/proto/public/css/screen.css +0 -30
- data/lib/proto/public/js/jquery.js +0 -7179
- data/lib/ramaze/contrib/addressable_route.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/contrib/email.rb +0 -88
- data/lib/ramaze/contrib/facebook.rb +0 -23
- data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
- data/lib/ramaze/contrib/gettext.rb +0 -113
- data/lib/ramaze/contrib/gettext/mo.rb +0 -155
- data/lib/ramaze/contrib/gettext/parser.rb +0 -46
- data/lib/ramaze/contrib/gettext/po.rb +0 -109
- data/lib/ramaze/contrib/gzip_filter.rb +0 -1
- data/lib/ramaze/contrib/maruku_uv.rb +0 -59
- data/lib/ramaze/contrib/profiling.rb +0 -36
- data/lib/ramaze/contrib/rest.rb +0 -23
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
- data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
- data/lib/ramaze/contrib/sequel/image.rb +0 -196
- data/lib/ramaze/contrib/sequel/relation.rb +0 -98
- data/lib/ramaze/helper/httpdigest.rb +0 -96
- data/lib/ramaze/tool/bin.rb +0 -340
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -120
- data/lib/ramaze/view/less.rb +0 -12
- data/lib/ramaze/view/maruku.rb +0 -15
- data/lib/ramaze/view/redcloth.rb +0 -21
- data/spec/contrib/addressable_route.rb +0 -30
- data/spec/examples/helpers/httpdigest.rb +0 -64
- data/spec/examples/templates/template_redcloth.rb +0 -13
- data/spec/ramaze/bin/ramaze.rb +0 -96
- data/spec/ramaze/helper/httpdigest.rb +0 -176
- data/spec/ramaze/view/less.rb +0 -60
- data/spec/ramaze/view/less/file.css.less +0 -8
- data/spec/ramaze/view/redcloth.rb +0 -66
- data/spec/ramaze/view/redcloth/external.redcloth +0 -8
- data/tasks/copyright.rake +0 -21
- data/tasks/gem_setup.rake +0 -112
- data/tasks/git.rake +0 -46
- data/tasks/grancher.rake +0 -12
- data/tasks/jquery.rake +0 -15
- data/tasks/manifest.rake +0 -4
- data/tasks/metric_changes.rake +0 -24
- data/tasks/reversion.rake +0 -8
- data/tasks/traits.rake +0 -21
data/lib/ramaze/log.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
-
|
4
3
|
require 'ramaze/log/logging'
|
5
4
|
require 'ramaze/log/informer'
|
6
5
|
|
@@ -16,17 +15,10 @@ module Ramaze
|
|
16
15
|
Log = Innate::Log
|
17
16
|
|
18
17
|
##
|
19
|
-
#
|
20
|
-
# Ramaze ships with the following logging helpers:
|
18
|
+
# Module used as the base namespace for all loggers that ship with Ramaze.
|
21
19
|
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# * Syslog
|
25
|
-
# * Growl
|
26
|
-
# * Xosd
|
27
|
-
# * Logger
|
28
|
-
# * Informer
|
29
|
-
# * RotatingInformer
|
20
|
+
# @author Michael Fellinger
|
21
|
+
# @since 11-08-2009
|
30
22
|
#
|
31
23
|
module Logger
|
32
24
|
autoload :Analogger, 'ramaze/log/analogger'
|
data/lib/ramaze/log/analogger.rb
CHANGED
@@ -31,7 +31,8 @@ module Ramaze
|
|
31
31
|
# @param [String] host The IP/hostname on which the logging system is running.
|
32
32
|
# @param [Integer] port The port of the logging system.
|
33
33
|
#
|
34
|
-
def initialize(name = class_trait[:name], host = class_trait[:host],
|
34
|
+
def initialize(name = class_trait[:name], host = class_trait[:host],
|
35
|
+
port = class_trait[:port])
|
35
36
|
super
|
36
37
|
end
|
37
38
|
|
@@ -44,6 +45,6 @@ module Ramaze
|
|
44
45
|
def log(tag, *args)
|
45
46
|
super(tag, args.join("\n"))
|
46
47
|
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
48
|
+
end # Analogger
|
49
|
+
end # Log
|
50
|
+
end # Ramaze
|
data/lib/ramaze/log/growl.rb
CHANGED
@@ -5,7 +5,6 @@ require 'ruby-growl'
|
|
5
5
|
|
6
6
|
module Ramaze
|
7
7
|
module Logger
|
8
|
-
|
9
8
|
##
|
10
9
|
# Informer for the Growl notification system
|
11
10
|
# Growl lets Mac OS X applications unintrusively tell you when things happen.
|
@@ -27,10 +26,14 @@ module Ramaze
|
|
27
26
|
##
|
28
27
|
# Takes the options from the default trait for merging.
|
29
28
|
#
|
30
|
-
# @param [Hash] options A hash containing extra options to use when
|
29
|
+
# @param [Hash] options A hash containing extra options to use when
|
30
|
+
# initializing the Growl logger.
|
31
31
|
#
|
32
32
|
def initialize(options = {})
|
33
|
-
options = class_trait[:defaults].merge(options).values_at(
|
33
|
+
options = class_trait[:defaults].merge(options).values_at(
|
34
|
+
:host, :name, :all_notifies, :default_notifies, :password
|
35
|
+
)
|
36
|
+
|
34
37
|
super(*options)
|
35
38
|
end
|
36
39
|
|
@@ -47,7 +50,6 @@ module Ramaze
|
|
47
50
|
# Send size was to big (not really), ignore
|
48
51
|
end
|
49
52
|
end
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
end
|
53
|
+
end # Growl
|
54
|
+
end # Logger
|
55
|
+
end # Ramaze
|
data/lib/ramaze/log/hub.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module Logger
|
6
|
-
|
7
6
|
##
|
8
7
|
# Bundles different informer instances and sends incoming messages to each.
|
9
8
|
# This is the default with Informer as only member.
|
@@ -43,7 +42,6 @@ module Ramaze
|
|
43
42
|
logger.log(tag, *args)
|
44
43
|
end
|
45
44
|
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
end
|
45
|
+
end # Hub
|
46
|
+
end # log
|
47
|
+
end # Ramaze
|
data/lib/ramaze/log/informer.rb
CHANGED
@@ -37,15 +37,19 @@ module Ramaze
|
|
37
37
|
#
|
38
38
|
# @example
|
39
39
|
#
|
40
|
-
# Informer.new
|
41
|
-
#
|
42
|
-
# Informer.new($stderr) #=> same, but to stderr
|
43
|
-
# Informer.new("foo.log") #=> same, but logs to the file foo.log
|
44
|
-
# (or creates it if it doesn't exist yet)
|
45
|
-
# Informer.new($stdout, [:info]) #=> show only #info messages to stdout.
|
40
|
+
# Informer.new # => logs to stdout with all levels being shown.
|
41
|
+
# Informer.new($stderr) # => same, but to stderr
|
46
42
|
#
|
47
|
-
#
|
48
|
-
#
|
43
|
+
# # same, but logs to the file foo.log (or creates it if it doesn't
|
44
|
+
# # exist yet)
|
45
|
+
# Informer.new("foo.log")
|
46
|
+
#
|
47
|
+
# Informer.new($stdout, [:info]) #=> show only #info messages to stdout.
|
48
|
+
#
|
49
|
+
# @param [String] out Specifies where the output should go. By default
|
50
|
+
# this is set to STDOUT.
|
51
|
+
# @param [Array] log_leves Array containing the levels that should be
|
52
|
+
# logged.
|
49
53
|
#
|
50
54
|
def initialize(out = $stdout, log_levels = [:debug, :error, :info, :warn])
|
51
55
|
@colorize = false
|
@@ -140,7 +144,6 @@ module Ramaze
|
|
140
144
|
def closed?
|
141
145
|
@out.respond_to?(:closed?) and @out.closed?
|
142
146
|
end
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
+
end # Informer
|
148
|
+
end # Log
|
149
|
+
end # Ramaze
|
data/lib/ramaze/log/knotify.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
module Ramaze
|
5
5
|
module Logger
|
6
|
-
|
7
6
|
##
|
8
7
|
# Informer for the Knotify notfication system used on KDE.
|
9
8
|
# Doesn't need any special libraries.
|
@@ -27,7 +26,6 @@ module Ramaze
|
|
27
26
|
system(%{dcop knotify default notify Ramaze "#{tag}" "#{message}" '' '' #{present} 0})
|
28
27
|
end
|
29
28
|
end
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
end
|
29
|
+
end # Knotify
|
30
|
+
end # Logger
|
31
|
+
end # Ramaze
|
data/lib/ramaze/log/logger.rb
CHANGED
data/lib/ramaze/log/logging.rb
CHANGED
@@ -2,12 +2,10 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
|
-
|
6
5
|
##
|
7
6
|
# This module provides a basic skeleton for your own loggers to be compatible.
|
8
7
|
#
|
9
8
|
# @example
|
10
|
-
#
|
11
9
|
# class MyLogger
|
12
10
|
# include Logging
|
13
11
|
#
|
@@ -17,7 +15,6 @@ module Ramaze
|
|
17
15
|
# end
|
18
16
|
#
|
19
17
|
module Logging
|
20
|
-
|
21
18
|
##
|
22
19
|
# Takes the tag (:warn|:debug|:error|:info) and the name of a method to be
|
23
20
|
# called upon elements of msgs that don't respond to :to_str
|
@@ -38,7 +35,8 @@ module Ramaze
|
|
38
35
|
##
|
39
36
|
# Converts everything given to strings and passes them on with :info
|
40
37
|
#
|
41
|
-
# @param [Array] objects An array of objects that need to be converted to
|
38
|
+
# @param [Array] objects An array of objects that need to be converted to
|
39
|
+
# strings.
|
42
40
|
#
|
43
41
|
def info(*objects)
|
44
42
|
tag_log(:info, :to_s, *objects)
|
@@ -47,7 +45,8 @@ module Ramaze
|
|
47
45
|
##
|
48
46
|
# Converts everything given to strings and passes them on with :warn
|
49
47
|
#
|
50
|
-
# @param [Array] objects An array of objects that need to be converted to
|
48
|
+
# @param [Array] objects An array of objects that need to be converted to
|
49
|
+
# strings.
|
51
50
|
#
|
52
51
|
def warn(*objects)
|
53
52
|
tag_log(:warn, :to_s, *objects)
|
@@ -104,6 +103,5 @@ module Ramaze
|
|
104
103
|
def debug?
|
105
104
|
false
|
106
105
|
end
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
106
|
+
end # Logging
|
107
|
+
end # Ramaze
|
@@ -3,9 +3,8 @@ module Ramaze
|
|
3
3
|
module Logger
|
4
4
|
|
5
5
|
##
|
6
|
-
# A customized logger (based on Informer) that creates multiple log files
|
7
|
-
#
|
8
|
-
# TODO: This class isn't fully documented and could use a few improvements.
|
6
|
+
# A customized logger (based on Informer) that creates multiple log files
|
7
|
+
# based on current date.
|
9
8
|
#
|
10
9
|
class RotatingInformer
|
11
10
|
include Innate::Traited
|
@@ -19,7 +18,7 @@ module Ramaze
|
|
19
18
|
|
20
19
|
# This is how the final output is arranged.
|
21
20
|
trait :format => "[%time] %prefix %text"
|
22
|
-
|
21
|
+
|
23
22
|
##
|
24
23
|
# Create a new instance of RotatingInformer.
|
25
24
|
#
|
@@ -34,16 +33,17 @@ module Ramaze
|
|
34
33
|
# any or all of the symbols :debug, :error, :info and/or :warn
|
35
34
|
#
|
36
35
|
# @example
|
37
|
-
#
|
38
|
-
# # Creates logs in directory called logs. The generated filenames
|
36
|
+
#
|
37
|
+
# # Creates logs in directory called logs. The generated filenames
|
38
|
+
# # will be in the form YYYY-MM-DD.log
|
39
39
|
# RotatingInformer.new('logs')
|
40
40
|
#
|
41
|
-
#
|
42
|
-
# #
|
41
|
+
# # Creates logs in directory called logs. The generated filenames
|
42
|
+
# # will be in the form YYYY-MM.txt
|
43
43
|
# RotatingInformer.new('logs', '%Y-%m.txt')
|
44
|
-
#
|
45
44
|
#
|
46
|
-
# # Creates logs in directory called logs. The generated filenames
|
45
|
+
# # Creates logs in directory called logs. The generated filenames
|
46
|
+
# # will be in the form YYYY-MM.txt.
|
47
47
|
# # Only errors will be logged to the files.
|
48
48
|
# RotatingInformer.new('logs', '%Y-%m.txt', [:error])
|
49
49
|
#
|
@@ -51,7 +51,8 @@ module Ramaze
|
|
51
51
|
# @param [String] time_format The time format for all log files.
|
52
52
|
# @param [Array] log_levels Array containing the type of messages to log.
|
53
53
|
#
|
54
|
-
def initialize(base_dir, time_format = '%Y-%m-%d.log',
|
54
|
+
def initialize(base_dir, time_format = '%Y-%m-%d.log',
|
55
|
+
log_levels = [:debug, :error, :info, :warn])
|
55
56
|
# Verify and set base directory
|
56
57
|
send :base_dir=, base_dir, true
|
57
58
|
|
@@ -74,7 +75,8 @@ module Ramaze
|
|
74
75
|
# or is unwritable.
|
75
76
|
#
|
76
77
|
# @param [String] directory The base directory specified by the developer.
|
77
|
-
# @param [Bool] raise_exception Boolean that indicates if an exception
|
78
|
+
# @param [Bool] raise_exception Boolean that indicates if an exception
|
79
|
+
# should be raised if the base directory doesn't exist.
|
78
80
|
#
|
79
81
|
def base_dir=(directory, raise_exception = false)
|
80
82
|
# Expand directory path
|
@@ -118,7 +120,6 @@ module Ramaze
|
|
118
120
|
# @param [Array] messages An array of messages to log.
|
119
121
|
#
|
120
122
|
def log tag, *messages
|
121
|
-
|
122
123
|
return unless @log_levels.include?(tag)
|
123
124
|
|
124
125
|
# Update current log
|
@@ -169,6 +170,16 @@ module Ramaze
|
|
169
170
|
@out.respond_to?(:closed?) && @out.closed?
|
170
171
|
end
|
171
172
|
|
173
|
+
##
|
174
|
+
# Method that is called by Rack::CommonLogger when logging data to a file.
|
175
|
+
#
|
176
|
+
# @author Yorick Peterse
|
177
|
+
# @param [String] message The data that has to be logged.
|
178
|
+
#
|
179
|
+
def write message
|
180
|
+
log(:info, message)
|
181
|
+
end
|
182
|
+
|
172
183
|
private
|
173
184
|
|
174
185
|
##
|
@@ -186,7 +197,6 @@ module Ramaze
|
|
186
197
|
@out = File.open(out, 'ab+')
|
187
198
|
end
|
188
199
|
end
|
189
|
-
end
|
190
|
-
|
191
|
-
|
192
|
-
end
|
200
|
+
end # RotatingInformer
|
201
|
+
end # Log
|
202
|
+
end # Ramaze
|
data/lib/ramaze/log/syslog.rb
CHANGED
@@ -6,10 +6,10 @@ require 'syslog'
|
|
6
6
|
|
7
7
|
# Add aliases for the levelnames used by Ramaze logging
|
8
8
|
module Syslog
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
alias dev debug
|
10
|
+
alias warn warning
|
11
|
+
alias error err
|
12
|
+
module_function :dev, :warn, :error
|
13
13
|
end
|
14
14
|
|
15
15
|
module Ramaze
|
@@ -52,6 +52,6 @@ module Ramaze
|
|
52
52
|
def inspect
|
53
53
|
::Syslog.inspect
|
54
54
|
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
55
|
+
end # Syslog
|
56
|
+
end # Logger
|
57
|
+
end # Ramaze
|
data/lib/ramaze/log/xosd.rb
CHANGED
@@ -7,7 +7,6 @@ require 'thread'
|
|
7
7
|
|
8
8
|
module Ramaze
|
9
9
|
module Logger
|
10
|
-
|
11
10
|
##
|
12
11
|
# Informer for the XOSD notification system for X11.
|
13
12
|
#
|
@@ -89,7 +88,6 @@ module Ramaze
|
|
89
88
|
QUEUE << [tag, message]
|
90
89
|
end
|
91
90
|
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
end
|
91
|
+
end # Xosd
|
92
|
+
end # Logger
|
93
|
+
end # Ramaze
|
@@ -1,13 +1,36 @@
|
|
1
1
|
module Ramaze
|
2
|
+
##
|
3
|
+
# @author Michael Fellinger
|
4
|
+
# @since 14-03-2009
|
5
|
+
# @see Innate::MiddelwareCompiler
|
6
|
+
#
|
2
7
|
class MiddlewareCompiler < Innate::MiddlewareCompiler
|
8
|
+
##
|
9
|
+
# Adds the path as a static file.
|
10
|
+
#
|
11
|
+
# @author Michael Fellinger
|
12
|
+
# @since 26-03-2009
|
13
|
+
# @param [String] path The path to the static file to add.
|
14
|
+
#
|
3
15
|
def static(path)
|
4
16
|
require 'rack/contrib'
|
5
|
-
Rack::ETag.new(
|
17
|
+
Rack::ETag.new(
|
18
|
+
Rack::ConditionalGet.new(Rack::File.new(path)), 'public'
|
19
|
+
)
|
6
20
|
end
|
7
21
|
|
22
|
+
##
|
23
|
+
# Adds the path as a directory.
|
24
|
+
#
|
25
|
+
# @author Michael Fellinger
|
26
|
+
# @since 26-03-2009
|
27
|
+
# @param [String] path The path to the directory to add.
|
28
|
+
#
|
8
29
|
def directory(path)
|
9
30
|
require 'rack/contrib'
|
10
|
-
Rack::ETag.new(
|
31
|
+
Rack::ETag.new(
|
32
|
+
Rack::ConditionalGet.new(Rack::Directory.new(path)), 'public'
|
33
|
+
)
|
11
34
|
end
|
12
|
-
end
|
13
|
-
end
|
35
|
+
end # MiddlewareCompiler
|
36
|
+
end # Ramaze
|
data/lib/ramaze/reloader.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
|
-
|
6
5
|
# High performant source reloader
|
7
6
|
#
|
8
7
|
# This class acts as Rack middleware.
|
@@ -25,7 +24,6 @@ module Ramaze
|
|
25
24
|
#
|
26
25
|
# A number of hooks will be executed during the reload cycle, see
|
27
26
|
# Ramaze::ReloaderHooks for more information.
|
28
|
-
|
29
27
|
class Reloader
|
30
28
|
OPTIONS = {
|
31
29
|
# At most check every n seconds
|
@@ -60,6 +58,14 @@ module Ramaze
|
|
60
58
|
Watcher = WatchStat
|
61
59
|
end
|
62
60
|
|
61
|
+
##
|
62
|
+
# Creates a new instance of the class and saves the application it has to
|
63
|
+
# watch.
|
64
|
+
#
|
65
|
+
# @author Michael Fellinger
|
66
|
+
# @since 09-08-2008
|
67
|
+
# @param [Ramaze::App] app The application to monitor.
|
68
|
+
#
|
63
69
|
def initialize(app)
|
64
70
|
@app = app
|
65
71
|
@files = {}
|
@@ -67,11 +73,25 @@ module Ramaze
|
|
67
73
|
options_reload
|
68
74
|
end
|
69
75
|
|
76
|
+
##
|
77
|
+
# Returns all the options for this class.
|
78
|
+
#
|
79
|
+
# @author Michael Fellinger
|
80
|
+
# @since 09-08-2008
|
81
|
+
# @return [Array]
|
82
|
+
#
|
70
83
|
def options_reload
|
71
84
|
@cooldown, @ignore, @control, @thread =
|
72
85
|
OPTIONS.values_at(:cooldown, :ignore, :control, :thread)
|
73
86
|
end
|
74
87
|
|
88
|
+
##
|
89
|
+
# Allows this class to be called as a Rack middleware.
|
90
|
+
#
|
91
|
+
# @author Michael Fellinger
|
92
|
+
# @since 09-08-2008
|
93
|
+
# @param [Hash] env A hash containing all environment details.
|
94
|
+
#
|
75
95
|
def call(env)
|
76
96
|
options_reload
|
77
97
|
|
@@ -88,6 +108,12 @@ module Ramaze
|
|
88
108
|
@app.call(env)
|
89
109
|
end
|
90
110
|
|
111
|
+
##
|
112
|
+
# Loops through all the files and reloads all changes files.
|
113
|
+
#
|
114
|
+
# @author Michael Fellinger
|
115
|
+
# @since 09-08-2008
|
116
|
+
#
|
91
117
|
def cycle
|
92
118
|
before_cycle
|
93
119
|
|
@@ -97,7 +123,13 @@ module Ramaze
|
|
97
123
|
after_cycle
|
98
124
|
end
|
99
125
|
|
126
|
+
##
|
100
127
|
# A safe Kernel::load, issuing the hooks depending on the results
|
128
|
+
#
|
129
|
+
# @author Michael Fellinger
|
130
|
+
# @since 09-08-2008
|
131
|
+
# @param [String] file Path to the file to safely load.
|
132
|
+
#
|
101
133
|
def safe_load(file)
|
102
134
|
before_safe_load(file)
|
103
135
|
load(file)
|
@@ -120,6 +152,15 @@ module Ramaze
|
|
120
152
|
end
|
121
153
|
end
|
122
154
|
|
155
|
+
##
|
156
|
+
# Tries to find a given file in an array of file paths.
|
157
|
+
#
|
158
|
+
# @author Michael Fellinger
|
159
|
+
# @since 09-08-2008
|
160
|
+
# @param [String] file The name of the file to look for.
|
161
|
+
# @param [Array] paths An array of paths to search.
|
162
|
+
# @return [String]
|
163
|
+
#
|
123
164
|
def figure_path(file, paths)
|
124
165
|
if Pathname.new(file).absolute?
|
125
166
|
return File.exist?(file) ? file : nil
|
@@ -132,16 +173,13 @@ module Ramaze
|
|
132
173
|
nil
|
133
174
|
end
|
134
175
|
|
135
|
-
|
136
176
|
# Holds hooks that are called before and after #cycle and #safe_load
|
137
177
|
module Hooks
|
138
178
|
# Overwrite to add actions before the reload rotation is started.
|
139
|
-
def before_cycle
|
140
|
-
end
|
179
|
+
def before_cycle; end
|
141
180
|
|
142
181
|
# Overwrite to add actions after the reload rotation has ended.
|
143
|
-
def after_cycle
|
144
|
-
end
|
182
|
+
def after_cycle; end
|
145
183
|
|
146
184
|
# Overwrite to add actions before a file is Kernel::load-ed
|
147
185
|
def before_safe_load(file)
|
@@ -149,7 +187,8 @@ module Ramaze
|
|
149
187
|
end
|
150
188
|
|
151
189
|
# Overwrite to add actions after a file is Kernel::load-ed successfully,
|
152
|
-
# by default we clean the Cache for compiled templates and resolved
|
190
|
+
# by default we clean the Cache for compiled templates and resolved
|
191
|
+
# actions.
|
153
192
|
def after_safe_load_succeed(file)
|
154
193
|
Cache.clear_after_reload
|
155
194
|
after_safe_load(file)
|
@@ -164,9 +203,8 @@ module Ramaze
|
|
164
203
|
def after_safe_load_failed(file, error)
|
165
204
|
Log.error(error)
|
166
205
|
end
|
167
|
-
end
|
206
|
+
end # Hooks
|
168
207
|
|
169
208
|
include Hooks
|
170
|
-
|
171
|
-
|
172
|
-
end
|
209
|
+
end # Reloader
|
210
|
+
end # Ramaze
|