vcs 0.1 → 0.2.148
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +17 -3
- data/bin/vcs +57 -34
- data/doc/jamis.rb +564 -0
- data/ruby_ex/abstract.rb +254 -0
- data/ruby_ex/abstract_node.rb +85 -0
- data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
- data/ruby_ex/array_each_pair.rb +18 -0
- data/ruby_ex/ask.rb +101 -0
- data/ruby_ex/attributed_class.rb +302 -0
- data/ruby_ex/cache.rb +373 -0
- data/ruby_ex/checkout.rb +12 -0
- data/ruby_ex/choose.rb +271 -0
- data/ruby_ex/commands.rb +18 -0
- data/ruby_ex/commands/command.rb +401 -0
- data/ruby_ex/commands/datas.rb +16 -0
- data/ruby_ex/commands/datas/data.rb +33 -0
- data/ruby_ex/commands/datas/factory.rb +66 -0
- data/ruby_ex/commands/factory.rb +66 -0
- data/ruby_ex/commands/helpers.rb +67 -0
- data/ruby_ex/commands/pipe.rb +64 -0
- data/ruby_ex/commands/runners.rb +17 -0
- data/ruby_ex/commands/runners/exec.rb +49 -0
- data/ruby_ex/commands/runners/fork.rb +97 -0
- data/ruby_ex/commands/runners/runner.rb +107 -0
- data/ruby_ex/commands/seq.rb +27 -0
- data/ruby_ex/config_file.rb +96 -0
- data/ruby_ex/const_regexp.rb +59 -0
- data/ruby_ex/daemon.rb +134 -0
- data/ruby_ex/diff.rb +667 -0
- data/ruby_ex/dlogger.rb +62 -0
- data/ruby_ex/drb/dispatcher.rb +252 -0
- data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
- data/ruby_ex/drb/drb_observable.rb +97 -0
- data/ruby_ex/drb/drb_observable_pool.rb +27 -0
- data/ruby_ex/drb/drb_service.rb +43 -0
- data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
- data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
- data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
- data/ruby_ex/drb/session_client_test.rb +40 -0
- data/ruby_ex/drb/session_manager.rb +246 -0
- data/ruby_ex/drb/session_server.rb +53 -0
- data/ruby_ex/dtime.rb +143 -0
- data/ruby_ex/dumpable_proc.rb +63 -0
- data/ruby_ex/exception.rb +32 -0
- data/ruby_ex/filetype.rb +229 -0
- data/ruby_ex/fileutils_ex.rb +44 -0
- data/ruby_ex/fold.rb +58 -0
- data/ruby_ex/generate_id.rb +44 -0
- data/ruby_ex/hookable.rb +262 -0
- data/ruby_ex/hooker.rb +54 -0
- data/ruby_ex/inactive_timeout.rb +137 -0
- data/ruby_ex/indexed_node.rb +66 -0
- data/ruby_ex/io_marshal.rb +100 -0
- data/ruby_ex/ioo.rb +194 -0
- data/ruby_ex/labeled_node.rb +63 -0
- data/ruby_ex/logger_observer.rb +23 -0
- data/ruby_ex/md5sum.rb +66 -0
- data/ruby_ex/mktemp.rb +208 -0
- data/ruby_ex/module/attr_once.rb +36 -0
- data/ruby_ex/module/autoload_tree.rb +75 -0
- data/ruby_ex/module/hierarchy.rb +335 -0
- data/ruby_ex/module/instance_method_visibility.rb +73 -0
- data/ruby_ex/module_ex.rb +11 -0
- data/ruby_ex/node.rb +80 -0
- data/ruby_ex/object_monitor.rb +145 -0
- data/ruby_ex/object_monitor_activity.rb +33 -0
- data/ruby_ex/observable.rb +140 -0
- data/ruby_ex/observable_pool.rb +293 -0
- data/ruby_ex/orderedhash.rb +252 -0
- data/ruby_ex/pathname_ex.rb +152 -0
- data/ruby_ex/pp_hierarchy.rb +29 -0
- data/ruby_ex/pseudo_cache.rb +190 -0
- data/ruby_ex/queue.rb +56 -0
- data/ruby_ex/random_generators.rb +25 -0
- data/ruby_ex/random_generators/random_generator.rb +31 -0
- data/ruby_ex/random_generators/ruby.rb +23 -0
- data/ruby_ex/safe_eval.rb +348 -0
- data/ruby_ex/sendmail.rb +215 -0
- data/ruby_ex/service_manager.rb +121 -0
- data/ruby_ex/session/administrable.rb +120 -0
- data/ruby_ex/session/client.rb +153 -0
- data/ruby_ex/session/const.rb +18 -0
- data/ruby_ex/session/dispatcher.rb +184 -0
- data/ruby_ex/session/error.rb +21 -0
- data/ruby_ex/session/fetchable.rb +57 -0
- data/ruby_ex/session/fetcher.rb +62 -0
- data/ruby_ex/session/hookable.rb +26 -0
- data/ruby_ex/session/profile.rb +110 -0
- data/ruby_ex/session/server.rb +582 -0
- data/ruby_ex/session/test/administrable_test.rb +337 -0
- data/ruby_ex/session/test/basic_test.rb +523 -0
- data/ruby_ex/session/test/dispatcher_test.rb +409 -0
- data/ruby_ex/session/test/fetchable_test.rb +119 -0
- data/ruby_ex/session/test/sub_server_test.rb +188 -0
- data/ruby_ex/shuffle.rb +30 -0
- data/ruby_ex/spring.rb +136 -0
- data/ruby_ex/spring_set.rb +137 -0
- data/ruby_ex/string_ex.rb +28 -0
- data/ruby_ex/symtbl.rb +106 -0
- data/ruby_ex/synflow.rb +474 -0
- data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
- data/ruby_ex/thread_mutex.rb +10 -0
- data/ruby_ex/timeout_ex.rb +81 -0
- data/ruby_ex/top_down.rb +73 -0
- data/ruby_ex/trace.rb +26 -0
- data/ruby_ex/uri/druby.rb +81 -0
- data/ruby_ex/uri/file.rb +65 -0
- data/ruby_ex/uri/ftp_ex.rb +37 -0
- data/ruby_ex/uri/http_ex.rb +43 -0
- data/ruby_ex/uri/ssh.rb +92 -0
- data/ruby_ex/uri/svn.rb +118 -0
- data/ruby_ex/uri_ex.rb +45 -0
- data/ruby_ex/verbose_object.rb +30 -0
- data/ruby_ex/version.rb +66 -0
- data/ruby_ex/yaml/basenode_ext.rb +63 -0
- data/ruby_ex/yaml/chop_header.rb +23 -0
- data/ruby_ex/yaml/transform.rb +449 -0
- data/ruby_ex/yaml/yregexpath.rb +76 -0
- data/src/changelog.rb +28 -18
- data/src/conflict.rb +20 -0
- data/src/diff.rb +18 -0
- data/src/diffstat.rb +9 -3
- data/src/last_changed_date.rb +18 -0
- data/src/mail.rb +33 -65
- data/src/message.rb +15 -9
- data/src/mycommit.rb +29 -14
- data/src/news.rb +24 -3
- data/src/status.rb +17 -0
- data/src/svn.rb +2 -2
- data/src/vcs.rb +24 -3
- metadata +124 -5
- data/lrdetools.rb +0 -12
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License: Gnu General Public License.
|
4
|
+
|
5
|
+
# $LastChangedBy: polrop $
|
6
|
+
# $Id: fileutils_ex.rb 159 2005-02-18 12:07:23Z polrop $
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
module FileUtils
|
11
|
+
|
12
|
+
alias remove_dir_without_chmod remove_dir
|
13
|
+
|
14
|
+
def remove_dir (dir, force = false) #:nodoc:
|
15
|
+
dir = dir.sub(%r</\z>, '')
|
16
|
+
first_time_p = true
|
17
|
+
begin
|
18
|
+
Dir.foreach(dir) do |file|
|
19
|
+
next if /\A\.\.?\z/ =~ file
|
20
|
+
path = "#{dir}/#{file.untaint}"
|
21
|
+
if File.symlink?(path)
|
22
|
+
remove_file path, force
|
23
|
+
elsif File.directory?(path)
|
24
|
+
remove_dir path, force
|
25
|
+
else
|
26
|
+
remove_file path, force
|
27
|
+
end
|
28
|
+
end
|
29
|
+
begin
|
30
|
+
Dir.rmdir dir
|
31
|
+
rescue Errno::ENOENT
|
32
|
+
raise unless force
|
33
|
+
end
|
34
|
+
rescue
|
35
|
+
if first_time_p
|
36
|
+
first_time_p = false
|
37
|
+
File.chmod 0777, dir
|
38
|
+
retry
|
39
|
+
end
|
40
|
+
raise
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/ruby_ex/fold.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright: Copyright (c) 2004 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License: Gnu General Public License.
|
4
|
+
|
5
|
+
# $LastChangedBy: ertai $
|
6
|
+
# $Id: fold.rb 186 2005-04-03 00:07:45Z ertai $
|
7
|
+
|
8
|
+
|
9
|
+
class Object
|
10
|
+
|
11
|
+
def rec_fold
|
12
|
+
if respond_to?(:fold)
|
13
|
+
return fold({}) do |k1, v1, acc1|
|
14
|
+
yield(k1, v1.rec_fold { |k2, v2, acc2| yield(k2, v2, acc2) }, acc1)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
return self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end # class Object
|
22
|
+
|
23
|
+
|
24
|
+
class Hash
|
25
|
+
|
26
|
+
def fold(init, &block)
|
27
|
+
acc = init
|
28
|
+
self.each do |k,v|
|
29
|
+
acc = block[k, v, acc]
|
30
|
+
end
|
31
|
+
acc
|
32
|
+
end
|
33
|
+
|
34
|
+
end # class Hash
|
35
|
+
|
36
|
+
|
37
|
+
class Array
|
38
|
+
|
39
|
+
def fold(init, &block)
|
40
|
+
acc = init
|
41
|
+
self.each do |elt|
|
42
|
+
acc = block[elt, self[elt], acc]
|
43
|
+
end
|
44
|
+
acc
|
45
|
+
end
|
46
|
+
|
47
|
+
def reverse_fold(init, &block)
|
48
|
+
acc = init
|
49
|
+
self.reverse_each do |elt|
|
50
|
+
acc = block[elt, self[elt], acc]
|
51
|
+
end
|
52
|
+
acc
|
53
|
+
end
|
54
|
+
|
55
|
+
end # class Array
|
56
|
+
|
57
|
+
|
58
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
2
|
+
# Author:: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: generate_id.rb 214 2005-05-06 13:12:41Z ertai $
|
5
|
+
|
6
|
+
|
7
|
+
require 'md5'
|
8
|
+
|
9
|
+
module Kernel
|
10
|
+
|
11
|
+
def generate_id(&already_exist)
|
12
|
+
md5 = Digest::MD5::new
|
13
|
+
id = ''
|
14
|
+
begin
|
15
|
+
md5.update(id)
|
16
|
+
md5.update(Time.now.to_s)
|
17
|
+
md5.update(rand.to_s)
|
18
|
+
md5.update($$.to_s)
|
19
|
+
md5.update($0)
|
20
|
+
id = md5.hexdigest[0,16]
|
21
|
+
end while block_given? and already_exist[id]
|
22
|
+
id
|
23
|
+
end
|
24
|
+
|
25
|
+
end # module Kernel
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
if $0 == __FILE__
|
30
|
+
require 'test/unit'
|
31
|
+
class GenerateIdTest < Test::Unit::TestCase
|
32
|
+
def test_simple
|
33
|
+
tab = []
|
34
|
+
100.times { tab << generate_id }
|
35
|
+
assert_equal(tab.size, tab.uniq.size)
|
36
|
+
end
|
37
|
+
def test_simple
|
38
|
+
tab = []
|
39
|
+
bool = true
|
40
|
+
100.times { tab << generate_id { bool = !bool ; bool } }
|
41
|
+
assert_equal(tab.size, tab.uniq.size)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/ruby_ex/hookable.rb
ADDED
@@ -0,0 +1,262 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: hookable.rb 216 2005-05-08 11:04:46Z ertai $
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require_gem 'activesupport'
|
8
|
+
require 'active_support/class_inheritable_attributes'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
module Hookable
|
13
|
+
|
14
|
+
def self.included ( aClass )
|
15
|
+
super
|
16
|
+
|
17
|
+
aClass.module_eval do
|
18
|
+
|
19
|
+
def self.inheritable_attributes
|
20
|
+
if @inheritable_attributes.nil? or @inheritable_attributes.empty?
|
21
|
+
@inheritable_attributes = HashWithRecursiveCloneDup.new
|
22
|
+
end
|
23
|
+
@inheritable_attributes
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
class_inheritable_array :hooks
|
28
|
+
class_inheritable_array :hookers
|
29
|
+
inheritable_attributes[:hookers] = []
|
30
|
+
inheritable_attributes[:hooks] = []
|
31
|
+
|
32
|
+
|
33
|
+
def hook_trigger ( name, *args )
|
34
|
+
self.class.hook_trigger(name, *args)
|
35
|
+
return unless defined? @hookers
|
36
|
+
@hookers.each do |hooker|
|
37
|
+
@@hook_trigger_internal[hooker, name, *args]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def self.hook_trigger ( name, *args )
|
43
|
+
raise ArgumentError, "Unknown hook #{name}" unless hooks.include? name
|
44
|
+
hookers.each do |hooker|
|
45
|
+
@@hook_trigger_internal[hooker, name, *args]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def self.hooker_subscribe ( hooker )
|
51
|
+
hookers << hooker
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def hooker_subscribe ( hooker )
|
56
|
+
@hookers ||= []
|
57
|
+
@hookers << hooker
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def self.hook_declare ( name, *groups )
|
62
|
+
hooks << name
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
@@hook_trigger_internal = lambda do |hooker, name, *args|
|
67
|
+
if hooker.respond_to?(name)
|
68
|
+
hooker.send(name, *args)
|
69
|
+
else
|
70
|
+
if hooker.respond_to? :default_hook and not hooker.default_hook.nil?
|
71
|
+
hooker.send(hooker.default_hook, name, *args)
|
72
|
+
elsif hooker.respond_to?(:method_missing)
|
73
|
+
hooker.send(name, *args)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
class HashWithRecursiveCloneDup < Hash
|
84
|
+
|
85
|
+
def initialize_copy ( aHash )
|
86
|
+
aHash.each { |k, v| self[k] = v.dup }
|
87
|
+
end
|
88
|
+
|
89
|
+
end # class HashWithRecursiveCloneDup
|
90
|
+
|
91
|
+
end # module Hookable
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
if $0 == __FILE__
|
96
|
+
|
97
|
+
require 'test/unit'
|
98
|
+
require 'hooker'
|
99
|
+
|
100
|
+
class HookableHookerTest < Test::Unit::TestCase
|
101
|
+
|
102
|
+
class HookerTest
|
103
|
+
include Hooker
|
104
|
+
|
105
|
+
attr_reader :stack
|
106
|
+
|
107
|
+
def log ( *args )
|
108
|
+
@stack ||= []
|
109
|
+
@stack << args
|
110
|
+
end
|
111
|
+
|
112
|
+
def method_missing ( *a )
|
113
|
+
log(:method_missing, *a)
|
114
|
+
end
|
115
|
+
|
116
|
+
def hook1 ( *a )
|
117
|
+
log(:hook1, *a)
|
118
|
+
end
|
119
|
+
|
120
|
+
def reset
|
121
|
+
@stack.clear if @stack
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
STATIC_HOOKER_TEST = HookerTest.new
|
127
|
+
|
128
|
+
|
129
|
+
class HookableTest
|
130
|
+
include Hookable
|
131
|
+
|
132
|
+
hook_declare :hook1
|
133
|
+
|
134
|
+
hook_declare :hook2, :group1
|
135
|
+
|
136
|
+
def run
|
137
|
+
run1
|
138
|
+
run2
|
139
|
+
end
|
140
|
+
|
141
|
+
def run1
|
142
|
+
hook_trigger :hook1
|
143
|
+
end
|
144
|
+
|
145
|
+
def run2
|
146
|
+
hook_trigger :hook2, 42
|
147
|
+
hook_trigger :hook3 rescue nil
|
148
|
+
end
|
149
|
+
|
150
|
+
def << ( hooker )
|
151
|
+
hooker_subscribe hooker
|
152
|
+
end
|
153
|
+
|
154
|
+
hooker_subscribe STATIC_HOOKER_TEST
|
155
|
+
|
156
|
+
def self.ref
|
157
|
+
[
|
158
|
+
[[:hook1], [:method_missing, :hook2, 42]],
|
159
|
+
[[:hook1], [:default, :hook2, 42]],
|
160
|
+
[[:hook_1_and_2], [:hook_1_and_2, 42]],
|
161
|
+
[[:hook1], [:method_missing, :default_by_method_missing, :hook2, 42]],
|
162
|
+
[[:hook1], [:hook2, 42]],
|
163
|
+
[[:hook1], [:method_missing, :hook2_by_dynamic_hook_method, 42]]
|
164
|
+
]
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
class SubHookableTest < HookableTest
|
172
|
+
hook_declare :hook3
|
173
|
+
|
174
|
+
def self.ref
|
175
|
+
[
|
176
|
+
[[:hook1], [:method_missing, :hook2, 42], [:method_missing, :hook3]],
|
177
|
+
[[:hook1], [:default, :hook2, 42], [:default, :hook3]],
|
178
|
+
[[:hook_1_and_2], [:hook_1_and_2, 42], [:method_missing, :hook3]],
|
179
|
+
[[:hook1], [:method_missing, :default_by_method_missing, :hook2, 42],
|
180
|
+
[:method_missing, :default_by_method_missing, :hook3]],
|
181
|
+
[[:hook1], [:hook2, 42], [:default, :hook3]],
|
182
|
+
[[:hook1], [:method_missing, :hook2_by_dynamic_hook_method, 42],
|
183
|
+
[:method_missing, :hook3]]
|
184
|
+
]
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
class HookerTest1 < HookerTest
|
192
|
+
def default ( *a )
|
193
|
+
log(:default, *a)
|
194
|
+
end
|
195
|
+
hook_default_method :default
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
class HookerTest2 < HookerTest
|
201
|
+
def hook_1_and_2 ( *a )
|
202
|
+
log(:hook_1_and_2, *a)
|
203
|
+
end
|
204
|
+
hook_method :hook_1_and_2, :hook1, :hook2
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
class HookerTest3 < HookerTest
|
210
|
+
hook_default_method :default_by_method_missing
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
class HookerTest4 < HookerTest
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
class HookerTest21 < HookerTest1
|
221
|
+
def hook2 ( *a )
|
222
|
+
log(:hook2, *a)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
def test_hookable
|
229
|
+
hookable_checker HookableTest.new
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
def test_sub_hookable
|
235
|
+
hookable_checker SubHookableTest.new
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
def hookable_checker ( support )
|
241
|
+
hookers = []
|
242
|
+
hookers << HookerTest1.new
|
243
|
+
hookers << HookerTest2.new
|
244
|
+
hookers << HookerTest3.new
|
245
|
+
hookers << HookerTest21.new
|
246
|
+
hooker4 = HookerTest4.new
|
247
|
+
hookers << hooker4
|
248
|
+
hookers.each do |hooker|
|
249
|
+
support << hooker
|
250
|
+
end
|
251
|
+
STATIC_HOOKER_TEST.reset
|
252
|
+
hookers.unshift STATIC_HOOKER_TEST
|
253
|
+
hooker4.hook_method(:hook2_by_dynamic_hook_method, :hook2)
|
254
|
+
support.run
|
255
|
+
hookers.zip(support.class.ref).each do |hooker, ref|
|
256
|
+
assert_equal(ref, hooker.stack)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
261
|
+
|
262
|
+
end
|
data/ruby_ex/hooker.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
+
# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
+
# License:: Gnu General Public License.
|
4
|
+
# Revision:: $Id: hooker.rb 208 2005-05-05 19:53:50Z ertai $
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require_gem 'activesupport'
|
8
|
+
require 'active_support/class_inheritable_attributes'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
module Hooker
|
13
|
+
|
14
|
+
def self.included ( aClass )
|
15
|
+
super
|
16
|
+
|
17
|
+
aClass.module_eval do
|
18
|
+
|
19
|
+
class_inheritable_accessor :default_hook
|
20
|
+
|
21
|
+
|
22
|
+
def self.hook_default_method ( method )
|
23
|
+
raise unless method.is_a? Symbol
|
24
|
+
self.default_hook = method
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def hook_method ( *a )
|
29
|
+
@@generic_hook_method[method(:instance_eval), *a]
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def self.hook_method ( *a )
|
34
|
+
@@generic_hook_method[method(:module_eval), *a]
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
@@generic_hook_method = lambda do |eval_meth, method, *hook_names|
|
39
|
+
raise unless method.is_a? Symbol
|
40
|
+
hook_names.each do |hook_name|
|
41
|
+
raise unless hook_name.is_a? Symbol
|
42
|
+
eval_meth[%Q{
|
43
|
+
def #{hook_name} ( *a, &b )
|
44
|
+
#{method}(*a, &b)
|
45
|
+
end
|
46
|
+
}]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end # module Hooker
|