ruby_ex 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +51 -0
- data/ChangeLog +1763 -0
- data/NEWS +3 -0
- data/README +1 -0
- data/Rakefile +8 -0
- data/SPEC.dyn.yml +10 -0
- data/SPEC.gem.yml +269 -0
- data/SPEC.yml +36 -0
- data/src/abstract.rb +253 -0
- data/src/abstract_node.rb +85 -0
- data/src/algorithms.rb +12 -0
- data/src/algorithms/simulated_annealing.rb +142 -0
- data/src/ask.rb +100 -0
- data/src/attributed_class.rb +303 -0
- data/src/cache.rb +350 -0
- data/src/checkout.rb +12 -0
- data/src/choose.rb +271 -0
- data/src/commands.rb +20 -0
- data/src/commands/command.rb +492 -0
- data/src/commands/datas.rb +16 -0
- data/src/commands/datas/composite.rb +31 -0
- data/src/commands/datas/data.rb +65 -0
- data/src/commands/datas/factory.rb +69 -0
- data/src/commands/datas/temp.rb +26 -0
- data/src/commands/factory.rb +67 -0
- data/src/commands/helpers.rb +81 -0
- data/src/commands/pipe.rb +66 -0
- data/src/commands/runners.rb +16 -0
- data/src/commands/runners/exec.rb +50 -0
- data/src/commands/runners/fork.rb +130 -0
- data/src/commands/runners/runner.rb +140 -0
- data/src/commands/runners/system.rb +57 -0
- data/src/commands/seq.rb +32 -0
- data/src/config_file.rb +95 -0
- data/src/const_regexp.rb +57 -0
- data/src/daemon.rb +135 -0
- data/src/diff.rb +665 -0
- data/src/dlogger.rb +62 -0
- data/src/drb/drb_observable.rb +95 -0
- data/src/drb/drb_observable_pool.rb +27 -0
- data/src/drb/drb_service.rb +44 -0
- data/src/drb/drb_undumped_attributes.rb +56 -0
- data/src/drb/drb_undumped_indexed_object.rb +55 -0
- data/src/drb/insecure_protected_methods.rb +101 -0
- data/src/drb_ex.rb +12 -0
- data/src/dumpable_proc.rb +57 -0
- data/src/filetype.rb +229 -0
- data/src/generate_id.rb +44 -0
- data/src/histogram.rb +222 -0
- data/src/hookable.rb +283 -0
- data/src/hooker.rb +54 -0
- data/src/indexed_node.rb +65 -0
- data/src/io_marshal.rb +99 -0
- data/src/ioo.rb +193 -0
- data/src/labeled_node.rb +62 -0
- data/src/logger_observer.rb +24 -0
- data/src/md5sum.rb +70 -0
- data/src/module/autoload_tree.rb +65 -0
- data/src/module/hierarchy.rb +334 -0
- data/src/module/instance_method_visibility.rb +71 -0
- data/src/node.rb +81 -0
- data/src/object_monitor.rb +143 -0
- data/src/object_monitor_activity.rb +34 -0
- data/src/observable.rb +138 -0
- data/src/observable_pool.rb +291 -0
- data/src/orderedhash.rb +252 -0
- data/src/pp_hierarchy.rb +30 -0
- data/src/random_generators.rb +29 -0
- data/src/random_generators/random_generator.rb +33 -0
- data/src/random_generators/ruby.rb +25 -0
- data/src/ruby_ex.rb +124 -0
- data/src/safe_eval.rb +346 -0
- data/src/sendmail.rb +214 -0
- data/src/service_manager.rb +122 -0
- data/src/shuffle.rb +30 -0
- data/src/spring.rb +134 -0
- data/src/spring_set.rb +134 -0
- data/src/symtbl.rb +108 -0
- data/src/synflow.rb +474 -0
- data/src/thread_mutex.rb +11 -0
- data/src/timeout_ex.rb +79 -0
- data/src/trace.rb +26 -0
- data/src/uri/druby.rb +78 -0
- data/src/uri/file.rb +63 -0
- data/src/uri/ftp_ex.rb +36 -0
- data/src/uri/http_ex.rb +41 -0
- data/src/uri/pgsql.rb +136 -0
- data/src/uri/ssh.rb +87 -0
- data/src/uri/svn.rb +113 -0
- data/src/uri_ex.rb +71 -0
- data/src/verbose_object.rb +70 -0
- data/src/yaml/basenode_ext.rb +63 -0
- data/src/yaml/chop_header.rb +24 -0
- data/src/yaml/transform.rb +450 -0
- data/src/yaml/yregexpath.rb +76 -0
- data/test/algorithms/simulated_annealing_test.rb +102 -0
- data/test/check-pkg-ruby_ex.yml +15 -0
- data/test/check-ruby_ex.yml +12 -0
- data/test/resources/autoload_tree/A.rb +11 -0
- data/test/resources/autoload_tree/B.rb +10 -0
- data/test/resources/autoload_tree/foo/C.rb +18 -0
- data/test/resources/foo.txt +6 -0
- data/test/sanity-suite.yml +12 -0
- data/test/sanity/multiple-requires.yml +20 -0
- data/test/sanity/single-requires.yml +24 -0
- data/test/test-unit-setup.rb +6 -0
- data/test/unit-suite.yml +14 -0
- metadata +269 -0
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Coming Soon.
|
data/Rakefile
ADDED
data/SPEC.dyn.yml
ADDED
data/SPEC.gem.yml
ADDED
@@ -0,0 +1,269 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.10
|
3
|
+
specification_version: 1
|
4
|
+
name: ruby_ex
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2005-06-03
|
8
|
+
summary: RubyEx contains general purpose Ruby extensions.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email:
|
12
|
+
- nicolas.despres@gmail.com
|
13
|
+
- ertai@feydakins.org
|
14
|
+
homepage: http://api.feydakins.org/ruby_ex
|
15
|
+
rubyforge_project: ruby_ex
|
16
|
+
description: ''
|
17
|
+
autorequire:
|
18
|
+
default_executable:
|
19
|
+
bindir: bin
|
20
|
+
has_rdoc: true
|
21
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
|
+
requirements:
|
23
|
+
-
|
24
|
+
- ">"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.0
|
27
|
+
version:
|
28
|
+
platform: ruby
|
29
|
+
authors:
|
30
|
+
-
|
31
|
+
- Nicolas Despr�s
|
32
|
+
- Nicolas Pouillard
|
33
|
+
files:
|
34
|
+
- src/abstract.rb
|
35
|
+
- src/abstract_node.rb
|
36
|
+
- src/algorithms.rb
|
37
|
+
- src/ask.rb
|
38
|
+
- src/attributed_class.rb
|
39
|
+
- src/cache.rb
|
40
|
+
- src/checkout.rb
|
41
|
+
- src/choose.rb
|
42
|
+
- src/commands.rb
|
43
|
+
- src/config_file.rb
|
44
|
+
- src/const_regexp.rb
|
45
|
+
- src/daemon.rb
|
46
|
+
- src/diff.rb
|
47
|
+
- src/dlogger.rb
|
48
|
+
- src/drb_ex.rb
|
49
|
+
- src/dumpable_proc.rb
|
50
|
+
- src/filetype.rb
|
51
|
+
- src/generate_id.rb
|
52
|
+
- src/histogram.rb
|
53
|
+
- src/hookable.rb
|
54
|
+
- src/hooker.rb
|
55
|
+
- src/indexed_node.rb
|
56
|
+
- src/io_marshal.rb
|
57
|
+
- src/ioo.rb
|
58
|
+
- src/labeled_node.rb
|
59
|
+
- src/logger_observer.rb
|
60
|
+
- src/md5sum.rb
|
61
|
+
- src/node.rb
|
62
|
+
- src/object_monitor.rb
|
63
|
+
- src/object_monitor_activity.rb
|
64
|
+
- src/observable.rb
|
65
|
+
- src/observable_pool.rb
|
66
|
+
- src/orderedhash.rb
|
67
|
+
- src/pp_hierarchy.rb
|
68
|
+
- src/random_generators.rb
|
69
|
+
- src/ruby_ex.rb
|
70
|
+
- src/safe_eval.rb
|
71
|
+
- src/sendmail.rb
|
72
|
+
- src/service_manager.rb
|
73
|
+
- src/shuffle.rb
|
74
|
+
- src/spring.rb
|
75
|
+
- src/spring_set.rb
|
76
|
+
- src/symtbl.rb
|
77
|
+
- src/synflow.rb
|
78
|
+
- src/thread_mutex.rb
|
79
|
+
- src/timeout_ex.rb
|
80
|
+
- src/trace.rb
|
81
|
+
- src/uri_ex.rb
|
82
|
+
- src/verbose_object.rb
|
83
|
+
- src/algorithms/simulated_annealing.rb
|
84
|
+
- src/commands/command.rb
|
85
|
+
- src/commands/datas.rb
|
86
|
+
- src/commands/factory.rb
|
87
|
+
- src/commands/helpers.rb
|
88
|
+
- src/commands/pipe.rb
|
89
|
+
- src/commands/runners.rb
|
90
|
+
- src/commands/seq.rb
|
91
|
+
- src/commands/datas/composite.rb
|
92
|
+
- src/commands/datas/data.rb
|
93
|
+
- src/commands/datas/factory.rb
|
94
|
+
- src/commands/datas/temp.rb
|
95
|
+
- src/commands/runners/exec.rb
|
96
|
+
- src/commands/runners/fork.rb
|
97
|
+
- src/commands/runners/runner.rb
|
98
|
+
- src/commands/runners/system.rb
|
99
|
+
- src/drb/drb_observable.rb
|
100
|
+
- src/drb/drb_observable_pool.rb
|
101
|
+
- src/drb/drb_service.rb
|
102
|
+
- src/drb/drb_undumped_attributes.rb
|
103
|
+
- src/drb/drb_undumped_indexed_object.rb
|
104
|
+
- src/drb/insecure_protected_methods.rb
|
105
|
+
- src/module/autoload_tree.rb
|
106
|
+
- src/module/hierarchy.rb
|
107
|
+
- src/module/instance_method_visibility.rb
|
108
|
+
- src/random_generators/random_generator.rb
|
109
|
+
- src/random_generators/ruby.rb
|
110
|
+
- src/uri/druby.rb
|
111
|
+
- src/uri/file.rb
|
112
|
+
- src/uri/ftp_ex.rb
|
113
|
+
- src/uri/http_ex.rb
|
114
|
+
- src/uri/pgsql.rb
|
115
|
+
- src/uri/ssh.rb
|
116
|
+
- src/uri/svn.rb
|
117
|
+
- src/yaml/basenode_ext.rb
|
118
|
+
- src/yaml/chop_header.rb
|
119
|
+
- src/yaml/transform.rb
|
120
|
+
- src/yaml/yregexpath.rb
|
121
|
+
- test/algorithms
|
122
|
+
- test/check-pkg-ruby_ex.yml
|
123
|
+
- test/check-ruby_ex.yml
|
124
|
+
- test/resources
|
125
|
+
- test/sanity
|
126
|
+
- test/sanity-suite.yml
|
127
|
+
- test/test-unit-setup.rb
|
128
|
+
- test/unit-suite.yml
|
129
|
+
- test/algorithms/simulated_annealing_test.rb
|
130
|
+
- test/resources/autoload_tree
|
131
|
+
- test/resources/foo.txt
|
132
|
+
- test/resources/autoload_tree/A.rb
|
133
|
+
- test/resources/autoload_tree/B.rb
|
134
|
+
- test/resources/autoload_tree/foo
|
135
|
+
- test/resources/autoload_tree/foo/C.rb
|
136
|
+
- test/sanity/multiple-requires.yml
|
137
|
+
- test/sanity/single-requires.yml
|
138
|
+
- AUTHORS
|
139
|
+
- ChangeLog
|
140
|
+
- NEWS
|
141
|
+
- Rakefile
|
142
|
+
- README
|
143
|
+
- SPEC.dyn.yml
|
144
|
+
- SPEC.gem.yml
|
145
|
+
- SPEC.yml
|
146
|
+
test_files: []
|
147
|
+
rdoc_options:
|
148
|
+
- "--inline-source"
|
149
|
+
- "--main"
|
150
|
+
- README
|
151
|
+
- "--title"
|
152
|
+
- "RubyEx -- General purpose Ruby extensions."
|
153
|
+
- "-T"
|
154
|
+
- html
|
155
|
+
extra_rdoc_files:
|
156
|
+
- README
|
157
|
+
- AUTHORS
|
158
|
+
- NEWS
|
159
|
+
- src/abstract.rb
|
160
|
+
- src/abstract_node.rb
|
161
|
+
- src/algorithms.rb
|
162
|
+
- src/ask.rb
|
163
|
+
- src/attributed_class.rb
|
164
|
+
- src/cache.rb
|
165
|
+
- src/checkout.rb
|
166
|
+
- src/choose.rb
|
167
|
+
- src/commands.rb
|
168
|
+
- src/config_file.rb
|
169
|
+
- src/const_regexp.rb
|
170
|
+
- src/daemon.rb
|
171
|
+
- src/diff.rb
|
172
|
+
- src/dlogger.rb
|
173
|
+
- src/drb_ex.rb
|
174
|
+
- src/dumpable_proc.rb
|
175
|
+
- src/filetype.rb
|
176
|
+
- src/generate_id.rb
|
177
|
+
- src/histogram.rb
|
178
|
+
- src/hookable.rb
|
179
|
+
- src/hooker.rb
|
180
|
+
- src/indexed_node.rb
|
181
|
+
- src/io_marshal.rb
|
182
|
+
- src/ioo.rb
|
183
|
+
- src/labeled_node.rb
|
184
|
+
- src/logger_observer.rb
|
185
|
+
- src/md5sum.rb
|
186
|
+
- src/node.rb
|
187
|
+
- src/object_monitor.rb
|
188
|
+
- src/object_monitor_activity.rb
|
189
|
+
- src/observable.rb
|
190
|
+
- src/observable_pool.rb
|
191
|
+
- src/orderedhash.rb
|
192
|
+
- src/pp_hierarchy.rb
|
193
|
+
- src/random_generators.rb
|
194
|
+
- src/ruby_ex.rb
|
195
|
+
- src/safe_eval.rb
|
196
|
+
- src/sendmail.rb
|
197
|
+
- src/service_manager.rb
|
198
|
+
- src/shuffle.rb
|
199
|
+
- src/spring.rb
|
200
|
+
- src/spring_set.rb
|
201
|
+
- src/symtbl.rb
|
202
|
+
- src/synflow.rb
|
203
|
+
- src/thread_mutex.rb
|
204
|
+
- src/timeout_ex.rb
|
205
|
+
- src/trace.rb
|
206
|
+
- src/uri_ex.rb
|
207
|
+
- src/verbose_object.rb
|
208
|
+
- src/algorithms/simulated_annealing.rb
|
209
|
+
- src/commands/command.rb
|
210
|
+
- src/commands/datas.rb
|
211
|
+
- src/commands/factory.rb
|
212
|
+
- src/commands/helpers.rb
|
213
|
+
- src/commands/pipe.rb
|
214
|
+
- src/commands/runners.rb
|
215
|
+
- src/commands/seq.rb
|
216
|
+
- src/commands/datas/composite.rb
|
217
|
+
- src/commands/datas/data.rb
|
218
|
+
- src/commands/datas/factory.rb
|
219
|
+
- src/commands/datas/temp.rb
|
220
|
+
- src/commands/runners/exec.rb
|
221
|
+
- src/commands/runners/fork.rb
|
222
|
+
- src/commands/runners/runner.rb
|
223
|
+
- src/commands/runners/system.rb
|
224
|
+
- src/drb/drb_observable.rb
|
225
|
+
- src/drb/drb_observable_pool.rb
|
226
|
+
- src/drb/drb_service.rb
|
227
|
+
- src/drb/drb_undumped_attributes.rb
|
228
|
+
- src/drb/drb_undumped_indexed_object.rb
|
229
|
+
- src/drb/insecure_protected_methods.rb
|
230
|
+
- src/module/autoload_tree.rb
|
231
|
+
- src/module/hierarchy.rb
|
232
|
+
- src/module/instance_method_visibility.rb
|
233
|
+
- src/random_generators/random_generator.rb
|
234
|
+
- src/random_generators/ruby.rb
|
235
|
+
- src/uri/druby.rb
|
236
|
+
- src/uri/file.rb
|
237
|
+
- src/uri/ftp_ex.rb
|
238
|
+
- src/uri/http_ex.rb
|
239
|
+
- src/uri/pgsql.rb
|
240
|
+
- src/uri/ssh.rb
|
241
|
+
- src/uri/svn.rb
|
242
|
+
- src/yaml/basenode_ext.rb
|
243
|
+
- src/yaml/chop_header.rb
|
244
|
+
- src/yaml/transform.rb
|
245
|
+
- src/yaml/yregexpath.rb
|
246
|
+
executables: []
|
247
|
+
extensions: []
|
248
|
+
requirements: []
|
249
|
+
dependencies:
|
250
|
+
- !ruby/object:Gem::Dependency
|
251
|
+
name: core_ex
|
252
|
+
version_requirement:
|
253
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
254
|
+
requirements:
|
255
|
+
-
|
256
|
+
- "~>"
|
257
|
+
- !ruby/object:Gem::Version
|
258
|
+
version: 0.1.2
|
259
|
+
version:
|
260
|
+
- !ruby/object:Gem::Dependency
|
261
|
+
name: activesupport
|
262
|
+
version_requirement:
|
263
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
264
|
+
requirements:
|
265
|
+
-
|
266
|
+
- "~>"
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
version: 1.0.4
|
269
|
+
version:
|
data/SPEC.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
Author: The TTK Team.
|
3
|
+
License: Ruby License
|
4
|
+
Revision: '$Id$'
|
5
|
+
|
6
|
+
name: ruby_ex
|
7
|
+
|
8
|
+
title: RubyEx -- General purpose Ruby extensions.
|
9
|
+
summary: RubyEx contains general purpose Ruby extensions.
|
10
|
+
description: ""
|
11
|
+
homepage: http://api.feydakins.org/ruby_ex
|
12
|
+
rubyforge_project: ttk
|
13
|
+
rubyforge_sub_package_name: ruby_ex
|
14
|
+
|
15
|
+
root_test_suite: test/check-pkg-ruby_ex.yml
|
16
|
+
rdoc_dir: doc/html
|
17
|
+
tags_url: svn://svn.feydakins.org/ruby_ex/tags
|
18
|
+
|
19
|
+
commit_command: rxci
|
20
|
+
|
21
|
+
rdoc_files: !filelist
|
22
|
+
- README
|
23
|
+
- AUTHORS
|
24
|
+
- NEWS
|
25
|
+
- src/**/*.rb
|
26
|
+
|
27
|
+
pkg_files: !filelist
|
28
|
+
- src/**/*.rb
|
29
|
+
- test/**/*
|
30
|
+
- '[A-Z]*'
|
31
|
+
|
32
|
+
dependencies:
|
33
|
+
core_ex: ~> 0.1.2
|
34
|
+
activesupport: ~> 1.0.4
|
35
|
+
# ttk: ~> 0.2.0
|
36
|
+
|
data/src/abstract.rb
ADDED
@@ -0,0 +1,253 @@
|
|
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
|
+
|
5
|
+
# $LastChangedBy: ertai $
|
6
|
+
# $Id: abstract.rb 266 2005-06-01 14:27:18Z ertai $
|
7
|
+
|
8
|
+
|
9
|
+
#FIXME: find a way to be thread safe.
|
10
|
+
|
11
|
+
|
12
|
+
require 'module/instance_method_visibility'
|
13
|
+
require 'ruby_ex'
|
14
|
+
|
15
|
+
|
16
|
+
module Concrete; end
|
17
|
+
|
18
|
+
|
19
|
+
# When this module is included into a class, this class can't be instantiate
|
20
|
+
# any more until the Concrete module is included too. This module cannot be
|
21
|
+
# included if the Concrete module has been included before in one of the
|
22
|
+
# class' superclass.
|
23
|
+
module Abstract
|
24
|
+
|
25
|
+
def self.included(klass)
|
26
|
+
super
|
27
|
+
if klass.include?(Concrete)
|
28
|
+
raise(TypeError, "#{klass} - cannot make abstract a concrete class")
|
29
|
+
end
|
30
|
+
klass.module_eval do
|
31
|
+
class << self
|
32
|
+
unless private_method_defined?(:concrete_new)
|
33
|
+
alias_method :concrete_new, :new
|
34
|
+
visibility = instance_method_visibility('new')
|
35
|
+
def new(*args, &block)
|
36
|
+
raise(TypeError, "cannot instantiate an abstract class #{name}")
|
37
|
+
end
|
38
|
+
send(visibility, :new)
|
39
|
+
private :concrete_new
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end # module Abstract
|
46
|
+
|
47
|
+
|
48
|
+
# Include this module in an abstract class to make it concrete and so, to be
|
49
|
+
# able to instantiate it again. This module can be included if and only if the
|
50
|
+
# Abstract module has been included before in one of the class' superclass.
|
51
|
+
module Concrete
|
52
|
+
|
53
|
+
def self.included(klass)
|
54
|
+
super
|
55
|
+
unless klass.include?(Abstract)
|
56
|
+
raise(TypeError, "#{klass} - not an abstract class")
|
57
|
+
end
|
58
|
+
klass.module_eval do
|
59
|
+
class << self
|
60
|
+
visibility = instance_method_visibility('new')
|
61
|
+
def new(*args, &block)
|
62
|
+
concrete_new(*args, &block)
|
63
|
+
end
|
64
|
+
send(visibility, :new)
|
65
|
+
end
|
66
|
+
|
67
|
+
def is_a?(klass)
|
68
|
+
klass == Abstract ? false : super(klass)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end # module Concrete
|
74
|
+
|
75
|
+
|
76
|
+
class Class
|
77
|
+
|
78
|
+
def abstract
|
79
|
+
include Abstract
|
80
|
+
end
|
81
|
+
|
82
|
+
def concrete
|
83
|
+
include Concrete
|
84
|
+
end
|
85
|
+
|
86
|
+
def abstract?
|
87
|
+
include?(Abstract) ? (not include?(Concrete)) : false;
|
88
|
+
end
|
89
|
+
|
90
|
+
end # class Class
|
91
|
+
|
92
|
+
|
93
|
+
test_section __FILE__ do
|
94
|
+
|
95
|
+
|
96
|
+
require 'singleton'
|
97
|
+
|
98
|
+
|
99
|
+
class AbstractTest < Test::Unit::TestCase
|
100
|
+
|
101
|
+
class R; end
|
102
|
+
|
103
|
+
class A
|
104
|
+
include Abstract
|
105
|
+
|
106
|
+
attr_reader :initialized
|
107
|
+
|
108
|
+
def initialize(toto=nil)
|
109
|
+
@initialized = true
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
class B < A; end
|
115
|
+
|
116
|
+
def test_abstract
|
117
|
+
assert_nothing_raised { R.new }
|
118
|
+
assert(A.include?(Abstract))
|
119
|
+
assert_raises(TypeError) { A.new }
|
120
|
+
assert_raises(TypeError) { B.new }
|
121
|
+
assert_raises(TypeError) do
|
122
|
+
AbstractTest.module_eval %q{
|
123
|
+
class D
|
124
|
+
include Concrete
|
125
|
+
include Abstract
|
126
|
+
end
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class C < A
|
132
|
+
include Concrete
|
133
|
+
|
134
|
+
attr_reader :toto
|
135
|
+
|
136
|
+
def initialize(toto=nil)
|
137
|
+
super
|
138
|
+
@toto = toto
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class CC < C; end
|
143
|
+
|
144
|
+
def test_concrete
|
145
|
+
assert_raises(TypeError) do
|
146
|
+
AbstractTest.module_eval %q{ class D; include Concrete; end }
|
147
|
+
end
|
148
|
+
assert(C.new.initialized)
|
149
|
+
assert_nil(C.new.toto)
|
150
|
+
assert_equal('toto', C.new('toto').toto)
|
151
|
+
assert(CC.new.initialized)
|
152
|
+
assert_equal(SC.instance, SC.instance)
|
153
|
+
assert_equal(SCC.instance, SCC.instance)
|
154
|
+
assert_not_equal(SC.instance, SCC.instance)
|
155
|
+
end
|
156
|
+
|
157
|
+
class SA
|
158
|
+
include Singleton
|
159
|
+
include Abstract
|
160
|
+
|
161
|
+
attr_reader :initialized
|
162
|
+
|
163
|
+
def initialize(toto=nil)
|
164
|
+
@initialized = true
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
class SB < SA; end
|
170
|
+
|
171
|
+
def test_abstract_singleton
|
172
|
+
assert(SA.include?(Abstract))
|
173
|
+
assert_raises(NoMethodError) { SA.new }
|
174
|
+
assert_raises(TypeError) { SA.instance }
|
175
|
+
assert_raises(NoMethodError) { SB.new }
|
176
|
+
assert_raises(TypeError) { SB.instance }
|
177
|
+
assert_raises(TypeError) do
|
178
|
+
AbstractTest.module_eval %q{
|
179
|
+
class SD; include Concrete; include Abstract; end
|
180
|
+
}
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
class SC < SA
|
185
|
+
include Concrete
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
class SCC < SC; end
|
190
|
+
|
191
|
+
def test_concrete_singleton
|
192
|
+
assert_raises(TypeError) do
|
193
|
+
AbstractTest.module_eval %q{ class SD; include Concrete; end }
|
194
|
+
end
|
195
|
+
assert_raises(NoMethodError) { SC.new }
|
196
|
+
assert(SC.instance.initialized)
|
197
|
+
assert(SCC.instance.initialized)
|
198
|
+
assert_equal(SC.instance, SC.instance)
|
199
|
+
assert_equal(SCC.instance, SCC.instance)
|
200
|
+
assert_not_equal(SC.instance, SCC.instance)
|
201
|
+
end
|
202
|
+
|
203
|
+
class IsA; include Abstract; end
|
204
|
+
class IsB < IsA; include Concrete; end
|
205
|
+
|
206
|
+
def test_is_a
|
207
|
+
assert(! IsB.new.is_a?(Abstract))
|
208
|
+
assert(IsB.new.is_a?(IsA))
|
209
|
+
assert(IsB.include?(Abstract))
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_abstract?
|
213
|
+
assert(IsA.abstract?)
|
214
|
+
assert(! IsB.abstract?)
|
215
|
+
end
|
216
|
+
|
217
|
+
class AArg
|
218
|
+
include Abstract
|
219
|
+
|
220
|
+
attr_reader :arg
|
221
|
+
|
222
|
+
def initialize(arg)
|
223
|
+
@arg = arg
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
class CArg < AArg
|
229
|
+
include Concrete
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_arg
|
233
|
+
assert_nothing_raised { CArg.new('toto') }
|
234
|
+
assert_raises(ArgumentError) { CArg.new }
|
235
|
+
end
|
236
|
+
|
237
|
+
class AA_; include Abstract; end
|
238
|
+
class BB_ < AA_; include Abstract; end
|
239
|
+
class CC_ < BB_; include Concrete; end
|
240
|
+
class DD_ < CC_; include Concrete; end
|
241
|
+
|
242
|
+
def test_double_abstract
|
243
|
+
assert_raises(TypeError) { AA_.new }
|
244
|
+
assert_raises(TypeError) { BB_.new }
|
245
|
+
assert_nothing_raised { CC_.new }
|
246
|
+
assert_nothing_raised { DD_.new }
|
247
|
+
end
|
248
|
+
|
249
|
+
end # class AbstractTest
|
250
|
+
|
251
|
+
|
252
|
+
end
|
253
|
+
|