ramaze 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ramaze +58 -26
- data/doc/AUTHORS +2 -0
- data/doc/CHANGELOG +401 -0
- data/doc/README +14 -9
- data/doc/README.html +737 -0
- data/doc/TODO +14 -14
- data/doc/changes.txt +401 -0
- data/doc/changes.xml +401 -0
- data/doc/meta/announcement.txt +28 -15
- data/doc/meta/configuration.txt +3 -3
- data/doc/meta/internals.txt +2 -2
- data/doc/meta/users.kml +62 -0
- data/doc/readme_chunks/examples.txt +1 -1
- data/doc/readme_chunks/features.txt +13 -8
- data/doc/tutorial/todolist.html +2 -2
- data/doc/tutorial/todolist.mkd +2 -2
- data/examples/blog/README +3 -0
- data/examples/blog/spec/blog.rb +101 -0
- data/examples/blog/{main.rb → start.rb} +0 -0
- data/examples/caching.rb +16 -5
- data/examples/layout.rb +41 -0
- data/examples/templates/template_amrita2.rb +1 -1
- data/examples/templates/template_erubis.rb +1 -1
- data/examples/templates/template_ezamar.rb +1 -1
- data/examples/templates/template_haml.rb +1 -1
- data/examples/templates/template_liquid.rb +1 -1
- data/examples/templates/template_markaby.rb +1 -1
- data/examples/templates/template_remarkably.rb +1 -1
- data/examples/todolist/README +1 -0
- data/{spec/examples → examples/todolist/spec}/todolist.rb +3 -3
- data/examples/todolist/{main.rb → start.rb} +0 -0
- data/examples/whywiki/{main.rb → start.rb} +0 -0
- data/examples/wiktacular/README +2 -0
- data/examples/wiktacular/spec/wiktacular.rb +146 -0
- data/examples/wiktacular/src/controller.rb +11 -0
- data/examples/wiktacular/src/model.rb +5 -1
- data/examples/wiktacular/{main.rb → start.rb} +0 -1
- data/examples/wiktacular/template/edit.xhtml +1 -2
- data/examples/wiktacular/template/html_layout.xhtml +27 -0
- data/examples/wiktacular/template/index.xhtml +8 -10
- data/examples/wiktacular/template/new.xhtml +1 -2
- data/lib/proto/{main.rb → start.rb} +0 -0
- data/lib/proto/template/index.xhtml +1 -1
- data/lib/ramaze/action/render.rb +58 -4
- data/lib/ramaze/action.rb +20 -0
- data/lib/ramaze/adapter/cgi.rb +7 -4
- data/lib/ramaze/adapter/fcgi.rb +6 -4
- data/lib/ramaze/adapter/mongrel.rb +4 -0
- data/lib/ramaze/adapter/webrick.rb +20 -9
- data/lib/ramaze/adapter.rb +3 -1
- data/lib/ramaze/cache/memcached.rb +2 -26
- data/lib/ramaze/cache.rb +8 -4
- data/lib/ramaze/controller/resolve.rb +26 -8
- data/lib/ramaze/controller.rb +44 -7
- data/lib/ramaze/dispatcher/action.rb +5 -1
- data/lib/ramaze/dispatcher/directory.rb +115 -0
- data/lib/ramaze/dispatcher/error.rb +19 -5
- data/lib/ramaze/dispatcher/file.rb +2 -2
- data/lib/ramaze/dispatcher.rb +52 -39
- data/lib/ramaze/global/dsl.rb +3 -2
- data/lib/ramaze/global/globalstruct.rb +26 -4
- data/lib/ramaze/global.rb +20 -11
- data/lib/ramaze/helper/aspect.rb +29 -11
- data/lib/ramaze/helper/auth.rb +2 -2
- data/lib/ramaze/helper/cache.rb +2 -0
- data/lib/ramaze/helper/identity.rb +21 -6
- data/lib/ramaze/helper/link.rb +1 -1
- data/lib/ramaze/helper/pager.rb +158 -100
- data/lib/ramaze/helper/partial.rb +22 -0
- data/lib/ramaze/helper/redirect.rb +1 -2
- data/lib/ramaze/helper/stack.rb +1 -1
- data/lib/ramaze/inform/informer.rb +20 -0
- data/lib/ramaze/inform/syslog.rb +5 -0
- data/lib/ramaze/snippets/kernel/__dir__.rb +21 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -12
- data/lib/ramaze/snippets/numeric/human_readable_filesize_format.rb +33 -0
- data/lib/ramaze/snippets/ramaze/caller_lines.rb +1 -1
- data/lib/ramaze/snippets/struct/values_at.rb +11 -4
- data/lib/ramaze/sourcereload.rb +29 -1
- data/{spec → lib/ramaze/spec}/helper/context.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/layout.rb +1 -1
- data/{spec → lib/ramaze/spec}/helper/minimal.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/mock_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/requester.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/simple_http.rb +0 -0
- data/{spec → lib/ramaze/spec}/helper/wrap.rb +0 -0
- data/lib/ramaze/spec/helper.rb +60 -0
- data/lib/ramaze/store/default.rb +3 -0
- data/lib/ramaze/template/ezamar/render_partial.rb +3 -0
- data/lib/ramaze/template/sass.rb +45 -0
- data/lib/ramaze/template.rb +1 -1
- data/lib/ramaze/tool/create.rb +5 -5
- data/lib/ramaze/tool/localize.rb +26 -5
- data/lib/ramaze/tool/mime.rb +7 -0
- data/lib/ramaze/trinity/response.rb +15 -0
- data/lib/ramaze/trinity/session.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze.rb +5 -0
- data/rake_tasks/conf.rake +4 -4
- data/rake_tasks/maintaince.rake +12 -7
- data/rake_tasks/spec.rake +7 -4
- data/spec/examples/caching.rb +6 -8
- data/spec/helper.rb +3 -60
- data/spec/ramaze/action/basics.rb +17 -0
- data/spec/ramaze/action/cache.rb +28 -0
- data/spec/ramaze/action/layout.rb +110 -0
- data/spec/ramaze/action/render.rb +14 -0
- data/spec/ramaze/action/template/bar.xhtml +1 -0
- data/spec/ramaze/action/template/other_wrapper.xhtml +1 -0
- data/spec/ramaze/action/template/single_wrapper.xhtml +1 -0
- data/spec/ramaze/controller/template/edit/content.xhtml +1 -0
- data/spec/ramaze/controller/template/edit.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +2 -2
- data/spec/ramaze/dispatcher/directory.rb +53 -0
- data/spec/ramaze/dispatcher/file.rb +0 -3
- data/spec/ramaze/error.rb +17 -2
- data/spec/ramaze/helper/aspect.rb +14 -20
- data/spec/ramaze/helper/pager.rb +83 -1
- data/spec/ramaze/helper/partial.rb +1 -1
- data/spec/ramaze/helper/template/test_template.xhtml +1 -0
- data/spec/ramaze/inform/informer.rb +37 -5
- data/spec/ramaze/localize.rb +1 -1
- data/spec/ramaze/template/haml.rb +5 -5
- data/spec/ramaze/template/sass/file.css.sass +5 -0
- data/spec/ramaze/template/sass.rb +46 -0
- data/spec/ramaze/template.rb +1 -1
- data/spec/ramaze/trinity/session.rb +27 -0
- data/spec/snippets/kernel/__dir__.rb +8 -0
- data/spec/snippets/kernel/aquire.rb +71 -0
- data/spec/snippets/kernel/constant.rb +27 -0
- data/spec/snippets/numeric/human_readable_filesize_format.rb +11 -0
- data/spec/snippets/ramaze/caller_info.rb +39 -0
- data/spec/snippets/ramaze/caller_lines.rb +27 -0
- data/spec/snippets/string/DIVIDE.rb +18 -0
- data/spec/snippets/string/camel_case.rb +25 -0
- data/spec/snippets/string/color.rb +11 -0
- data/spec/snippets/string/snake_case.rb +17 -0
- data/spec/snippets/struct/fill.rb +27 -0
- data/spec/snippets/struct/values_at.rb +39 -0
- metadata +71 -31
- data/examples/todolist/todolist.db +0 -5
- data/examples/wiktacular/src/page.rb +0 -66
- data/lib/ramaze/helper/feed.rb +0 -135
- data/lib/ramaze/helper/form.rb +0 -204
- data/lib/ramaze/snippets/openstruct/temp.rb +0 -13
- data/lib/ramaze/store/yaml.rb +0 -170
- data/spec/ramaze/helper/feed.rb +0 -127
- data/spec/ramaze/helper/form.rb +0 -146
- data/spec/ramaze/store/yaml.rb +0 -76
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
3
|
|
|
4
4
|
module Ramaze
|
|
5
|
+
|
|
6
|
+
# = PartialHelper
|
|
7
|
+
#
|
|
8
|
+
# === Example Usage
|
|
9
|
+
#
|
|
10
|
+
# class MyController
|
|
11
|
+
# def index
|
|
12
|
+
# end
|
|
13
|
+
# def list
|
|
14
|
+
# plain = request['plain']
|
|
15
|
+
# "Hello World from List! Plain List == #{plain}"
|
|
16
|
+
# end
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
#
|
|
20
|
+
# <html>
|
|
21
|
+
# <head><title>Partial Render Index</title></head>
|
|
22
|
+
# <body>
|
|
23
|
+
# #{render_partial(Rs(:list), 'plain' => true)}
|
|
24
|
+
# </body>
|
|
25
|
+
# </html>
|
|
26
|
+
|
|
5
27
|
module PartialHelper
|
|
6
28
|
|
|
7
29
|
private
|
|
@@ -36,8 +36,7 @@ module Ramaze
|
|
|
36
36
|
|
|
37
37
|
status = opts[:status] || STATUS_CODE["See Other"]
|
|
38
38
|
|
|
39
|
-
body = %{
|
|
40
|
-
|
|
39
|
+
body = %{You are being redirected, please follow <a href="#{target}">this link to: #{target}</a>!}
|
|
41
40
|
|
|
42
41
|
throw(:redirect, :body => body, :status => status, :head => head)
|
|
43
42
|
end
|
data/lib/ramaze/helper/stack.rb
CHANGED
|
@@ -28,6 +28,17 @@ module Ramaze
|
|
|
28
28
|
:error => :red,
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
# Create a new instance of Informer.
|
|
32
|
+
# You can spcify
|
|
33
|
+
#
|
|
34
|
+
# Examples:
|
|
35
|
+
# Informer.new #=> logs to stdout with all levels being
|
|
36
|
+
# shown.
|
|
37
|
+
# Informer.new($stderr) #=> same, but to stderr
|
|
38
|
+
# Informer.new("foo.log") #=> same, but logs to the file foo.log
|
|
39
|
+
# (or creates it if it doesn't exist yet)
|
|
40
|
+
# Informer.new($stdout, [:info]) #=> show only #info messages to stdout.
|
|
41
|
+
|
|
31
42
|
def initialize(out = $stdout, log_levels = [:debug, :error, :info, :warn])
|
|
32
43
|
@colorize = false
|
|
33
44
|
|
|
@@ -54,6 +65,8 @@ module Ramaze
|
|
|
54
65
|
@log_levels = log_levels
|
|
55
66
|
end
|
|
56
67
|
|
|
68
|
+
# Close the file we log to if it isn't closed already.
|
|
69
|
+
|
|
57
70
|
def shutdown
|
|
58
71
|
if @out.respond_to?(:close)
|
|
59
72
|
Inform.debug("close, #{@out.inspect}")
|
|
@@ -61,6 +74,8 @@ module Ramaze
|
|
|
61
74
|
end
|
|
62
75
|
end
|
|
63
76
|
|
|
77
|
+
# Integration to Informing.
|
|
78
|
+
|
|
64
79
|
def inform tag, *messages
|
|
65
80
|
return if closed? || !@log_levels.include?(tag)
|
|
66
81
|
messages.flatten!
|
|
@@ -79,6 +94,9 @@ module Ramaze
|
|
|
79
94
|
@out.flush if @out.respond_to?(:flush)
|
|
80
95
|
end
|
|
81
96
|
|
|
97
|
+
# Takes the prefix (tag), text and timestamp and applies it to
|
|
98
|
+
# the :format trait.
|
|
99
|
+
|
|
82
100
|
def log_interpolate prefix, text, time = timestamp
|
|
83
101
|
message = class_trait[:format].dup
|
|
84
102
|
|
|
@@ -97,6 +115,8 @@ module Ramaze
|
|
|
97
115
|
Time.now.strftime(mask || "%Y-%m-%d %H:%M:%S")
|
|
98
116
|
end
|
|
99
117
|
|
|
118
|
+
# is @out closed?
|
|
119
|
+
|
|
100
120
|
def closed?
|
|
101
121
|
@out.respond_to?(:closed?) and @out.closed?
|
|
102
122
|
end
|
data/lib/ramaze/inform/syslog.rb
CHANGED
|
@@ -10,19 +10,24 @@ module Ramaze
|
|
|
10
10
|
class Syslog
|
|
11
11
|
include ::Syslog
|
|
12
12
|
|
|
13
|
+
# opens syslog
|
|
14
|
+
|
|
13
15
|
def initialize
|
|
14
16
|
open unless ::Syslog.opened?
|
|
15
17
|
end
|
|
16
18
|
|
|
19
|
+
# alias for default syslog methods so they match ramaze
|
|
17
20
|
alias error err
|
|
18
21
|
alias warn warning
|
|
19
22
|
|
|
23
|
+
# just sends all messages received to ::Syslog
|
|
20
24
|
def inform(tag, *args)
|
|
21
25
|
self.__send__(tag, *args)
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
public :error, :warn
|
|
25
29
|
|
|
30
|
+
# Has to call the modules singleton-method.
|
|
26
31
|
def inspect
|
|
27
32
|
::Syslog.inspect
|
|
28
33
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
# Extensions for Kernel
|
|
5
|
+
|
|
6
|
+
module Kernel
|
|
7
|
+
# This is similar to +__FILE__+ and +__LINE__+, and returns a String
|
|
8
|
+
# representing the directory of the current file is.
|
|
9
|
+
# Unlike +__FILE__+ the path returned is absolute.
|
|
10
|
+
#
|
|
11
|
+
# This method is convenience for the
|
|
12
|
+
# File.expand_path(File.dirname(__FILE__))
|
|
13
|
+
# idiom.
|
|
14
|
+
#
|
|
15
|
+
unless defined?__DIR__
|
|
16
|
+
def __DIR__()
|
|
17
|
+
filename = caller[0][/(.*?):/, 1]
|
|
18
|
+
File.expand_path(File.dirname(filename))
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -5,19 +5,29 @@
|
|
|
5
5
|
|
|
6
6
|
module Kernel
|
|
7
7
|
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
8
|
+
# Require all .rb and .so files on the given globs, utilizes Dir::[].
|
|
9
|
+
#
|
|
10
|
+
# Examples:
|
|
11
|
+
# # Given following directory structure:
|
|
12
|
+
# # src/foo.rb
|
|
13
|
+
# # src/bar.so
|
|
14
|
+
# # src/foo.yaml
|
|
15
|
+
# # src/foobar/baz.rb
|
|
16
|
+
# # src/foobar/README
|
|
17
|
+
#
|
|
18
|
+
# # requires all files in 'src':
|
|
19
|
+
# aquire 'src/*'
|
|
20
|
+
#
|
|
21
|
+
# # requires all files in 'src' recursive:
|
|
22
|
+
# aquire 'src/**/*'
|
|
23
|
+
#
|
|
24
|
+
# # require 'src/foo.rb' and 'src/bar.so' and 'src/foobar/baz.rb'
|
|
25
|
+
# aquire 'src/*', 'src/foobar/*'
|
|
13
26
|
|
|
14
|
-
def aquire *
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Dir[File.join(dir, file, '*.rb')].each do |path|
|
|
19
|
-
require path unless path == File.expand_path(__FILE__)
|
|
20
|
-
end
|
|
27
|
+
def aquire *globs
|
|
28
|
+
globs.flatten.each do |glob|
|
|
29
|
+
Dir[glob].each do |file|
|
|
30
|
+
require file if file =~ /\.(rb|so)$/
|
|
21
31
|
end
|
|
22
32
|
end
|
|
23
33
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
+
|
|
4
|
+
class Numeric
|
|
5
|
+
HUMAN_READBLE_FILESIZE_FORMAT = [
|
|
6
|
+
['%.1fT', 1 << 40],
|
|
7
|
+
['%.1fG', 1 << 30],
|
|
8
|
+
['%.1fM', 1 << 20],
|
|
9
|
+
['%.1fK', 1 << 10],
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
def human_readable_filesize_format
|
|
13
|
+
HUMAN_READBLE_FILESIZE_FORMAT.each do |format, size|
|
|
14
|
+
return format % (self.to_f / size) if self >= size
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
self.to_s
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
=begin
|
|
22
|
+
$microtest_verbose = true
|
|
23
|
+
$microtest_run = true
|
|
24
|
+
|
|
25
|
+
require 'micro/test'
|
|
26
|
+
|
|
27
|
+
{ :description => 'format_human_filesize',
|
|
28
|
+
1 << 0 => '1',
|
|
29
|
+
1 << 10 => '1.0K',
|
|
30
|
+
1 << 20 => '1.0M',
|
|
31
|
+
1 << 30 => '1.0G',
|
|
32
|
+
}.test :human_readable_filesize_format
|
|
33
|
+
=end
|
|
@@ -17,7 +17,7 @@ module Ramaze
|
|
|
17
17
|
# ...
|
|
18
18
|
# ]
|
|
19
19
|
# Example:
|
|
20
|
-
#
|
|
20
|
+
# caller_lines('/usr/lib/ruby/1.8/debug.rb', 122, 2) # ->
|
|
21
21
|
# [
|
|
22
22
|
# [ 120, " def check_suspend", false ],
|
|
23
23
|
# [ 121, " return if Thread.critical", false ],
|
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
# Extensions for Struct
|
|
5
5
|
|
|
6
|
+
class Symbol
|
|
7
|
+
undef_method :to_int
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
class Struct
|
|
7
11
|
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
+
# Example:
|
|
13
|
+
# Point = Struct.new(:x, :y)
|
|
14
|
+
# point = Point.new(15, 10)
|
|
15
|
+
# point.values_at(:y, :x)
|
|
16
|
+
# # => [10, 15]
|
|
17
|
+
# point.values_at(0, 1)
|
|
18
|
+
# # => [15, 10]
|
|
12
19
|
|
|
13
20
|
def values_at(*keys)
|
|
14
21
|
keys.map{|k| self[k.to_sym] }
|
data/lib/ramaze/sourcereload.rb
CHANGED
|
@@ -4,20 +4,29 @@
|
|
|
4
4
|
require 'set'
|
|
5
5
|
|
|
6
6
|
module Ramaze
|
|
7
|
+
|
|
8
|
+
# SourceReload provides a way to reload changed files automatically during
|
|
9
|
+
# runtime. Its default behaviour in Ramaze is to check periodically for
|
|
10
|
+
# files with newer mtime and then attempts to load them in a controlled
|
|
11
|
+
# manner.
|
|
12
|
+
|
|
7
13
|
class SourceReload
|
|
8
14
|
attr_accessor :thread, :interval, :reload_glob, :map
|
|
9
15
|
|
|
16
|
+
# Take interval and a regular expression for files that are going to be reloaded.
|
|
10
17
|
def initialize interval = 1, reload_glob = %r{(^\./)|#{Dir.pwd}|ramaze}
|
|
11
18
|
@interval, @reload_glob = interval, reload_glob
|
|
12
19
|
@map, @files, @paths = [], [], []
|
|
13
20
|
@mtimes = {}
|
|
14
21
|
end
|
|
15
22
|
|
|
23
|
+
# start reloader-thread and assign it to this instance.
|
|
16
24
|
def start
|
|
17
25
|
Inform.debug("initialize automatic source reload every #{interval} seconds")
|
|
18
26
|
@thread = reloader
|
|
19
27
|
end
|
|
20
28
|
|
|
29
|
+
# Takes value of Global.sourcereload and unless it's false calls #start
|
|
21
30
|
def self.startup options = {}
|
|
22
31
|
interval = Global.sourcereload
|
|
23
32
|
instance = new(interval)
|
|
@@ -26,6 +35,7 @@ module Ramaze
|
|
|
26
35
|
instance.start if interval
|
|
27
36
|
end
|
|
28
37
|
|
|
38
|
+
# Start reload loop in separate Thread
|
|
29
39
|
def reloader
|
|
30
40
|
Thread.new do
|
|
31
41
|
loop do
|
|
@@ -35,6 +45,8 @@ module Ramaze
|
|
|
35
45
|
end
|
|
36
46
|
end
|
|
37
47
|
|
|
48
|
+
# One iteration of reload will look for files that changed since the last iteration
|
|
49
|
+
# and will try to #safe_load it.
|
|
38
50
|
# This method is quite handy if you want direct control over when your code is reloaded
|
|
39
51
|
#
|
|
40
52
|
# Usage example:
|
|
@@ -58,6 +70,8 @@ module Ramaze
|
|
|
58
70
|
SourceReloadHooks.after_reload
|
|
59
71
|
end
|
|
60
72
|
|
|
73
|
+
# Scans loaded features and paths for file-paths, filters them in the end
|
|
74
|
+
# according to the @reload_glob
|
|
61
75
|
def all_reload_files
|
|
62
76
|
files, paths = $LOADED_FEATURES, Array['', './', *$LOAD_PATH]
|
|
63
77
|
|
|
@@ -75,19 +89,20 @@ module Ramaze
|
|
|
75
89
|
m = @map.grep(@reload_glob)
|
|
76
90
|
end
|
|
77
91
|
|
|
92
|
+
# Safe mtime
|
|
78
93
|
def mtime(file)
|
|
79
94
|
File.mtime(file)
|
|
80
95
|
rescue Errno::ENOENT
|
|
81
96
|
false
|
|
82
97
|
end
|
|
83
98
|
|
|
99
|
+
# A safe Kernel::load, issuing the SourceReloadHooks dependin on the result.
|
|
84
100
|
def safe_load(file)
|
|
85
101
|
SourceReloadHooks.before_safe_load(file)
|
|
86
102
|
load(file)
|
|
87
103
|
SourceReloadHooks.after_safe_load_succeed(file)
|
|
88
104
|
true
|
|
89
105
|
rescue Object => ex
|
|
90
|
-
Inform.error(ex)
|
|
91
106
|
SourceReloadHooks.after_safe_load_failed(file, ex)
|
|
92
107
|
false
|
|
93
108
|
end
|
|
@@ -98,21 +113,34 @@ module Ramaze
|
|
|
98
113
|
module SourceReloadHooks
|
|
99
114
|
module_function
|
|
100
115
|
|
|
116
|
+
# Overwrite to add actions before the reload cycle is started.
|
|
117
|
+
|
|
101
118
|
def before_reload
|
|
102
119
|
end
|
|
103
120
|
|
|
121
|
+
# Overwrite to add actions after the reload cycle has ended.
|
|
122
|
+
|
|
104
123
|
def after_reload
|
|
105
124
|
end
|
|
106
125
|
|
|
126
|
+
# Overwrite to add actions before a file is Kernel::load-ed
|
|
127
|
+
|
|
107
128
|
def before_safe_load(file)
|
|
108
129
|
end
|
|
109
130
|
|
|
131
|
+
# Overwrite to add actions after a file is Kernel::load-ed successfully,
|
|
132
|
+
# by default we clean the Cache for compiled templates and resolved actions.
|
|
133
|
+
|
|
110
134
|
def after_safe_load_succeed(file)
|
|
111
135
|
Cache.compiled.clear
|
|
112
136
|
Cache.resolved.clear
|
|
113
137
|
end
|
|
114
138
|
|
|
139
|
+
# Overwrite to add actions after a file is Kernel::load-ed unsuccessfully,
|
|
140
|
+
# by default we output an error-message with the exception.
|
|
141
|
+
|
|
115
142
|
def after_safe_load_failed(file, error)
|
|
143
|
+
Inform.error(error)
|
|
116
144
|
end
|
|
117
145
|
end
|
|
118
146
|
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Copyright (c) 2006 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/spec/helper/minimal'
|
|
5
|
+
require 'ramaze/spec/helper/mock_http'
|
|
6
|
+
require 'ramaze/spec/helper/simple_http'
|
|
7
|
+
require 'ramaze/spec/helper/requester'
|
|
8
|
+
require 'ramaze/spec/helper/context'
|
|
9
|
+
|
|
10
|
+
Spec::Runner.configure do |config|
|
|
11
|
+
config.include MockHTTP
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
if defined?(::Spec)
|
|
16
|
+
exclude = Ramaze::Controller.class_trait[:exclude_action_modules]
|
|
17
|
+
exclude += [Base64::Deprecated, Base64, Spec::Expectations::ObjectExpectations]
|
|
18
|
+
exclude << Spec::Mocks::Methods if defined?(Spec::Mock::Methods)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# start up ramaze with a given hash of options
|
|
22
|
+
# that will be merged with the default-options.
|
|
23
|
+
|
|
24
|
+
def ramaze_start hash = {}
|
|
25
|
+
options = {
|
|
26
|
+
:adapter => false,
|
|
27
|
+
:run_loose => true,
|
|
28
|
+
:error_page => false,
|
|
29
|
+
:port => 7007,
|
|
30
|
+
:host => '127.0.0.1',
|
|
31
|
+
:force => true,
|
|
32
|
+
:origin => :spec,
|
|
33
|
+
}.merge(hash)
|
|
34
|
+
|
|
35
|
+
Ramaze.start(options)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
alias ramaze ramaze_start
|
|
39
|
+
|
|
40
|
+
# shutdown ramaze, this is not implemeted yet
|
|
41
|
+
# (and might never be due to limited possibilites)
|
|
42
|
+
|
|
43
|
+
def browser(*args, &block)
|
|
44
|
+
Browser.new(*args, &block)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# require each of the following and rescue LoadError, telling you why it failed.
|
|
49
|
+
|
|
50
|
+
def testcase_requires(*following)
|
|
51
|
+
following.each do |file|
|
|
52
|
+
require(file.to_s)
|
|
53
|
+
end
|
|
54
|
+
rescue LoadError => ex
|
|
55
|
+
puts ex
|
|
56
|
+
puts "Can't run #{$0}: #{ex}"
|
|
57
|
+
puts "Usually you should not worry about this failure, just install the"
|
|
58
|
+
puts "library and try again (if you want to use that feature later on)"
|
|
59
|
+
exit
|
|
60
|
+
end
|