rbbt-util 5.44.1 → 6.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rbbt +67 -90
- data/etc/app.d/base.rb +2 -2
- data/etc/app.d/semaphores.rb +3 -3
- data/lib/rbbt/annotations/annotated_array.rb +207 -207
- data/lib/rbbt/annotations/refactor.rb +27 -0
- data/lib/rbbt/annotations/util.rb +282 -282
- data/lib/rbbt/annotations.rb +343 -320
- data/lib/rbbt/association/database.rb +200 -225
- data/lib/rbbt/association/index.rb +294 -291
- data/lib/rbbt/association/item.rb +227 -227
- data/lib/rbbt/association/open.rb +35 -34
- data/lib/rbbt/association/util.rb +0 -169
- data/lib/rbbt/association.rb +2 -4
- data/lib/rbbt/entity/identifiers.rb +119 -118
- data/lib/rbbt/entity/refactor.rb +12 -0
- data/lib/rbbt/entity.rb +319 -315
- data/lib/rbbt/hpc/batch.rb +72 -53
- data/lib/rbbt/hpc/lsf.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/batches.rb +2 -2
- data/lib/rbbt/hpc/orchestrate/chains.rb +25 -5
- data/lib/rbbt/hpc/orchestrate/rules.rb +2 -2
- data/lib/rbbt/hpc/orchestrate.rb +19 -13
- data/lib/rbbt/hpc/slurm.rb +18 -18
- data/lib/rbbt/knowledge_base/entity.rb +13 -5
- data/lib/rbbt/knowledge_base/query.rb +2 -2
- data/lib/rbbt/knowledge_base/registry.rb +32 -31
- data/lib/rbbt/knowledge_base/traverse.rb +1 -1
- data/lib/rbbt/knowledge_base.rb +1 -1
- data/lib/rbbt/monitor.rb +36 -25
- data/lib/rbbt/persist/refactor.rb +166 -0
- data/lib/rbbt/persist/tsv/tokyocabinet.rb +105 -105
- data/lib/rbbt/persist/tsv.rb +187 -185
- data/lib/rbbt/persist.rb +556 -551
- data/lib/rbbt/refactor.rb +20 -0
- data/lib/rbbt/resource/path/refactor.rb +178 -0
- data/lib/rbbt/resource/path.rb +317 -497
- data/lib/rbbt/resource/util.rb +0 -48
- data/lib/rbbt/resource.rb +3 -390
- data/lib/rbbt/tsv/accessor.rb +2 -838
- data/lib/rbbt/tsv/attach.rb +303 -299
- data/lib/rbbt/tsv/change_id.rb +244 -245
- data/lib/rbbt/tsv/csv.rb +87 -85
- data/lib/rbbt/tsv/dumper.rb +2 -100
- data/lib/rbbt/tsv/excel.rb +26 -24
- data/lib/rbbt/tsv/field_index.rb +4 -1
- data/lib/rbbt/tsv/filter.rb +3 -2
- data/lib/rbbt/tsv/index.rb +2 -284
- data/lib/rbbt/tsv/manipulate.rb +750 -747
- data/lib/rbbt/tsv/marshal.rb +3 -3
- data/lib/rbbt/tsv/matrix.rb +2 -2
- data/lib/rbbt/tsv/parallel/through.rb +2 -1
- data/lib/rbbt/tsv/parallel/traverse.rb +783 -781
- data/lib/rbbt/tsv/parser.rb +678 -678
- data/lib/rbbt/tsv/refactor.rb +195 -0
- data/lib/rbbt/tsv/stream.rb +253 -251
- data/lib/rbbt/tsv/util.rb +420 -420
- data/lib/rbbt/tsv.rb +210 -208
- data/lib/rbbt/util/R/eval.rb +4 -4
- data/lib/rbbt/util/R/plot.rb +62 -166
- data/lib/rbbt/util/R.rb +21 -18
- data/lib/rbbt/util/cmd.rb +2 -318
- data/lib/rbbt/util/color.rb +269 -269
- data/lib/rbbt/util/colorize.rb +89 -89
- data/lib/rbbt/util/concurrency/processes/refactor.rb +22 -0
- data/lib/rbbt/util/concurrency/processes/worker.rb +2 -2
- data/lib/rbbt/util/concurrency/processes.rb +389 -386
- data/lib/rbbt/util/config.rb +169 -167
- data/lib/rbbt/util/iruby.rb +20 -0
- data/lib/rbbt/util/log/progress/report.rb +241 -241
- data/lib/rbbt/util/log/progress/util.rb +99 -99
- data/lib/rbbt/util/log/progress.rb +102 -102
- data/lib/rbbt/util/log/refactor.rb +49 -0
- data/lib/rbbt/util/log.rb +486 -532
- data/lib/rbbt/util/migrate.rb +1 -1
- data/lib/rbbt/util/misc/concurrent_stream.rb +248 -246
- data/lib/rbbt/util/misc/development.rb +12 -11
- data/lib/rbbt/util/misc/exceptions.rb +117 -112
- data/lib/rbbt/util/misc/format.rb +2 -230
- data/lib/rbbt/util/misc/indiferent_hash.rb +2 -107
- data/lib/rbbt/util/misc/inspect.rb +2 -476
- data/lib/rbbt/util/misc/lock.rb +109 -106
- data/lib/rbbt/util/misc/omics.rb +9 -1
- data/lib/rbbt/util/misc/pipes.rb +765 -793
- data/lib/rbbt/util/misc/refactor.rb +20 -0
- data/lib/rbbt/util/misc/ssw.rb +27 -17
- data/lib/rbbt/util/misc/system.rb +0 -15
- data/lib/rbbt/util/misc.rb +39 -20
- data/lib/rbbt/util/named_array/refactor.rb +4 -0
- data/lib/rbbt/util/named_array.rb +3 -220
- data/lib/rbbt/util/open/refactor.rb +7 -0
- data/lib/rbbt/util/open.rb +3 -857
- data/lib/rbbt/util/procpath.rb +6 -6
- data/lib/rbbt/util/python/paths.rb +27 -0
- data/lib/rbbt/util/python/run.rb +115 -0
- data/lib/rbbt/util/python/script.rb +110 -0
- data/lib/rbbt/util/python/util.rb +3 -3
- data/lib/rbbt/util/python.rb +22 -81
- data/lib/rbbt/util/semaphore.rb +152 -148
- data/lib/rbbt/util/simpleopt.rb +9 -8
- data/lib/rbbt/util/ssh/refactor.rb +19 -0
- data/lib/rbbt/util/ssh.rb +122 -118
- data/lib/rbbt/util/tar.rb +117 -115
- data/lib/rbbt/util/tmpfile.rb +69 -67
- data/lib/rbbt/util/version.rb +2 -0
- data/lib/rbbt/workflow/refactor/entity.rb +11 -0
- data/lib/rbbt/workflow/refactor/export.rb +66 -0
- data/lib/rbbt/workflow/refactor/inputs.rb +24 -0
- data/lib/rbbt/workflow/refactor/recursive.rb +64 -0
- data/lib/rbbt/workflow/refactor/task_info.rb +65 -0
- data/lib/rbbt/workflow/refactor.rb +153 -0
- data/lib/rbbt/workflow/remote_workflow/driver/ssh.rb +55 -32
- data/lib/rbbt/workflow/remote_workflow/remote_step/rest.rb +3 -1
- data/lib/rbbt/workflow/remote_workflow/remote_step/ssh.rb +14 -5
- data/lib/rbbt/workflow/remote_workflow/remote_step.rb +19 -7
- data/lib/rbbt/workflow/remote_workflow.rb +6 -1
- data/lib/rbbt/workflow/step/run.rb +766 -766
- data/lib/rbbt/workflow/step/save_load_inputs.rb +254 -254
- data/lib/rbbt/workflow/step.rb +2 -362
- data/lib/rbbt/workflow/task.rb +118 -118
- data/lib/rbbt/workflow/usage.rb +289 -287
- data/lib/rbbt/workflow/util/archive.rb +6 -5
- data/lib/rbbt/workflow/util/data.rb +1 -1
- data/lib/rbbt/workflow/util/orchestrator.rb +249 -246
- data/lib/rbbt/workflow/util/trace.rb +79 -44
- data/lib/rbbt/workflow.rb +4 -882
- data/lib/rbbt-util.rb +21 -13
- data/lib/rbbt.rb +16 -3
- data/python/rbbt/__init__.py +19 -1
- data/share/Rlib/plot.R +37 -37
- data/share/Rlib/svg.R +22 -5
- data/share/install/software/lib/install_helpers +1 -1
- data/share/rbbt_commands/hpc/list +2 -3
- data/share/rbbt_commands/hpc/orchestrate +4 -4
- data/share/rbbt_commands/hpc/tail +2 -0
- data/share/rbbt_commands/hpc/task +10 -7
- data/share/rbbt_commands/lsf/list +2 -3
- data/share/rbbt_commands/lsf/orchestrate +4 -4
- data/share/rbbt_commands/lsf/tail +2 -0
- data/share/rbbt_commands/lsf/task +10 -7
- data/share/rbbt_commands/migrate +1 -1
- data/share/rbbt_commands/pbs/list +2 -3
- data/share/rbbt_commands/pbs/orchestrate +4 -4
- data/share/rbbt_commands/pbs/tail +2 -0
- data/share/rbbt_commands/pbs/task +10 -7
- data/share/rbbt_commands/resource/produce +8 -1
- data/share/rbbt_commands/slurm/list +2 -3
- data/share/rbbt_commands/slurm/orchestrate +4 -4
- data/share/rbbt_commands/slurm/tail +2 -0
- data/share/rbbt_commands/slurm/task +10 -7
- data/share/rbbt_commands/system/clean +5 -5
- data/share/rbbt_commands/system/status +5 -5
- data/share/rbbt_commands/tsv/get +2 -3
- data/share/rbbt_commands/tsv/info +10 -13
- data/share/rbbt_commands/tsv/keys +18 -14
- data/share/rbbt_commands/tsv/slice +2 -2
- data/share/rbbt_commands/tsv/transpose +6 -2
- data/share/rbbt_commands/workflow/info +20 -24
- data/share/rbbt_commands/workflow/list +1 -1
- data/share/rbbt_commands/workflow/prov +20 -13
- data/share/rbbt_commands/workflow/server +11 -1
- data/share/rbbt_commands/workflow/task +76 -71
- data/share/rbbt_commands/workflow/write_info +26 -9
- data/share/software/opt/ssw/ssw.c +861 -0
- data/share/software/opt/ssw/ssw.h +130 -0
- data/share/workflow_config.ru +3 -3
- metadata +40 -2
data/lib/rbbt/entity.rb
CHANGED
@@ -1,315 +1,319 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
found = k
|
43
|
-
break
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
base.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
def
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
def
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
def
|
115
|
-
self.
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
def
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
def
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
define_method
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
self.send(single_name, *args
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
self
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
res = self.send(multi_name)
|
247
|
-
self.instance_variable_set("@multiple_result_" + name.to_s, res)
|
248
|
-
res
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
end
|
1
|
+
require_relative 'refactor'
|
2
|
+
Rbbt.require_instead 'scout/entity'
|
3
|
+
require_relative 'entity/refactor'
|
4
|
+
#require_relative 'persist'
|
5
|
+
#require_relative 'entity/identifiers'
|
6
|
+
#
|
7
|
+
#module Entity
|
8
|
+
#
|
9
|
+
# UNPERSISTED_PREFIX = "entity_unpersisted_property_"
|
10
|
+
#
|
11
|
+
# class MultipleEntity < TryAgain; end
|
12
|
+
#
|
13
|
+
# class DontPersist < Exception
|
14
|
+
# attr_accessor :payload
|
15
|
+
# def self.initialize(payload)
|
16
|
+
# @payload = payload
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# class << self
|
21
|
+
# attr_accessor :formats, :entity_property_cache
|
22
|
+
# end
|
23
|
+
# FORMATS = begin
|
24
|
+
# hash = {}
|
25
|
+
# class << hash
|
26
|
+
# alias orig_include? include?
|
27
|
+
#
|
28
|
+
# attr_accessor :find_cache
|
29
|
+
#
|
30
|
+
# def find(value)
|
31
|
+
# self.find_cache ||= {}
|
32
|
+
# if self.find_cache.include? value
|
33
|
+
# self.find_cache[value]
|
34
|
+
# else
|
35
|
+
# self.find_cache[value] = begin
|
36
|
+
# if orig_include? value
|
37
|
+
# self.find_cache[value] = value
|
38
|
+
# else
|
39
|
+
# found = nil
|
40
|
+
# each do |k,v|
|
41
|
+
# if value.to_s == k.to_s
|
42
|
+
# found = k
|
43
|
+
# break
|
44
|
+
# elsif value.to_s =~ /\(#{Regexp.quote k}\)/
|
45
|
+
# found = k
|
46
|
+
# break
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
# found
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
#
|
55
|
+
# def [](value)
|
56
|
+
# res = super
|
57
|
+
# return res if res
|
58
|
+
# key = find(value)
|
59
|
+
# key ? super(key) : nil
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# def []=(key,value)
|
63
|
+
# self.find_cache = nil
|
64
|
+
# super
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# def include?(value)
|
68
|
+
# find(value) != nil
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# hash
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# def self.formats
|
76
|
+
# FORMATS
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# dir = (defined?(Rbbt) && defined?(Resource) && Resource === Rbbt ? Rbbt.var.entity_property : 'var/entity_property')
|
80
|
+
# self.entity_property_cache = dir
|
81
|
+
#
|
82
|
+
# def self.entity_property_cache=(dir)
|
83
|
+
# @entity_property_cache = dir
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# attr_accessor :all_formats, :all_properties
|
87
|
+
# def self.extended(base)
|
88
|
+
# base.extend Annotation
|
89
|
+
# base.include ExtendedArray
|
90
|
+
# Entity.formats[base.to_s] = base
|
91
|
+
#
|
92
|
+
# base.module_eval do
|
93
|
+
# attr_accessor :_ary_property_cache
|
94
|
+
#
|
95
|
+
# attr_accessor :template, :list_template, :action_template, :list_action_template, :keep_id
|
96
|
+
#
|
97
|
+
# def self.format=(formats)
|
98
|
+
# formats = [formats] unless Array === formats
|
99
|
+
# self.all_formats ||= []
|
100
|
+
# self.all_formats = self.all_formats.concat(formats).uniq
|
101
|
+
# formats.each do |format|
|
102
|
+
# Entity.formats[format] ||= self
|
103
|
+
# end
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
# def _ary_property_cache
|
107
|
+
# @_ary_property_cache ||= {}
|
108
|
+
# end
|
109
|
+
#
|
110
|
+
# def base_entity
|
111
|
+
# self.annotation_types.select{|m| Entity === m}.last
|
112
|
+
# end
|
113
|
+
#
|
114
|
+
# def property(*args, &block)
|
115
|
+
# class << self; self; end.property(*args,&block)
|
116
|
+
# end
|
117
|
+
#
|
118
|
+
# def to_yaml(*args)
|
119
|
+
# self.clean_annotations.dup.to_yaml(*args)
|
120
|
+
# end
|
121
|
+
#
|
122
|
+
#
|
123
|
+
# def encode_with(coder)
|
124
|
+
# coder.scalar = clean_annotations
|
125
|
+
# end
|
126
|
+
#
|
127
|
+
# def consolidate
|
128
|
+
# self.inject(nil){|acc,e|
|
129
|
+
# if acc.nil?
|
130
|
+
# acc = e
|
131
|
+
# else
|
132
|
+
# acc.concat e
|
133
|
+
# end
|
134
|
+
# }
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# def all_properties
|
138
|
+
# annotation_types.select{|m| Entity === m}.collect{|e| e.all_properties}.flatten.uniq
|
139
|
+
# end
|
140
|
+
#
|
141
|
+
# def self.property(name, &block)
|
142
|
+
# Log.debug "Defining property #{name} for #{self}"
|
143
|
+
#
|
144
|
+
# case
|
145
|
+
# when (Hash === name and name.size == 1)
|
146
|
+
# name, type = name.collect.first
|
147
|
+
# when (String === name or Symbol === name)
|
148
|
+
# type = :single
|
149
|
+
# else
|
150
|
+
# raise "Format of name ( => type) not understood: #{name.inspect}"
|
151
|
+
# end
|
152
|
+
#
|
153
|
+
# name = name.to_s unless String === name
|
154
|
+
#
|
155
|
+
# persisted_name = UNPERSISTED_PREFIX + name
|
156
|
+
# self.remove_method persisted_name if methods.include? persisted_name
|
157
|
+
#
|
158
|
+
# case type
|
159
|
+
# when :both
|
160
|
+
# define_method name, &block
|
161
|
+
#
|
162
|
+
# when :single, :single2array
|
163
|
+
# single_name = "_single_" << name
|
164
|
+
# define_method single_name, &block
|
165
|
+
# define_method name do |*args, &block|
|
166
|
+
# if Array === self
|
167
|
+
# res = self.collect{|e| e.send(single_name, *args)}
|
168
|
+
# res.first.annotate(res) if Annotated === res.first && type == :single2array
|
169
|
+
# res
|
170
|
+
# else
|
171
|
+
# self.send(single_name, *args, &block)
|
172
|
+
# end
|
173
|
+
# end
|
174
|
+
# when :array, :array2single
|
175
|
+
# ary_name = "_ary_" << name
|
176
|
+
# define_method ary_name, &block
|
177
|
+
#
|
178
|
+
# define_method name do |*args, &block|
|
179
|
+
# case
|
180
|
+
# when Array === self
|
181
|
+
# self.send(ary_name, *args, &block)
|
182
|
+
# when (ExtendedArray::ExtendedArrayItem === self && Array === self.container and not self.container_index.nil? and self.container.respond_to? ary_name)
|
183
|
+
# cache_code = Misc.digest({:name => ary_name, :args => args})
|
184
|
+
# res = (self.container._ary_property_cache[cache_code] ||= self.container.send(name, *args))
|
185
|
+
# if Hash === res
|
186
|
+
# res[self]
|
187
|
+
# else
|
188
|
+
# res[self.container_index]
|
189
|
+
# end
|
190
|
+
# else
|
191
|
+
# res = self.make_list.send(ary_name, *args, &block)
|
192
|
+
# Hash === res ? res[self] : res[0]
|
193
|
+
# end
|
194
|
+
# end
|
195
|
+
# when :multiple
|
196
|
+
# multi_name = "_multiple_" << name
|
197
|
+
#
|
198
|
+
# define_method multi_name do
|
199
|
+
# if self.instance_variable_get("@multiple_result_" + name.to_s)
|
200
|
+
# return self.instance_variable_get("@multiple_result_" + name.to_s)
|
201
|
+
# end
|
202
|
+
# raise MultipleEntity, "Entity property #{name} runs with multiple entities"
|
203
|
+
# end
|
204
|
+
#
|
205
|
+
# define_method name do |*args|
|
206
|
+
#
|
207
|
+
# if self.instance_variable_get("@multiple_result_" + name.to_s)
|
208
|
+
# return self.instance_variable_get("@multiple_result_" + name.to_s)
|
209
|
+
# end
|
210
|
+
#
|
211
|
+
# obj = if Array === self
|
212
|
+
# self
|
213
|
+
# elsif self.respond_to?(:container) && Array === self.container
|
214
|
+
# self.container
|
215
|
+
# else
|
216
|
+
# self.make_list
|
217
|
+
# end
|
218
|
+
#
|
219
|
+
# missing = []
|
220
|
+
# obj.each do |e|
|
221
|
+
# begin
|
222
|
+
# res = e.send(multi_name)
|
223
|
+
# e.instance_variable_set("@multiple_result_" + name.to_s, res)
|
224
|
+
# rescue MultipleEntity
|
225
|
+
# missing << e
|
226
|
+
# end
|
227
|
+
# end
|
228
|
+
#
|
229
|
+
# res = missing.any? ? block.call(missing) : nil
|
230
|
+
# case res
|
231
|
+
# when Array
|
232
|
+
# missing.zip(res).each do |o,res|
|
233
|
+
# raise "Multiple function '#{name}' result 'nil' for element '#{o}'" if res.nil?
|
234
|
+
# o.instance_variable_set("@multiple_result_" + name.to_s, res)
|
235
|
+
# o.send(multi_name)
|
236
|
+
# end
|
237
|
+
# when Hash
|
238
|
+
# res.each do |o,res|
|
239
|
+
# raise "Multiple function '#{name}' result 'nil' for element '#{o}'" if res.nil?
|
240
|
+
# o.instance_variable_set("@multiple_result_" + name.to_s, res)
|
241
|
+
# o.send(multi_name)
|
242
|
+
# end
|
243
|
+
# end
|
244
|
+
#
|
245
|
+
# if Array === self
|
246
|
+
# res = self.collect{|o| o.send(multi_name)}
|
247
|
+
# self.instance_variable_set("@multiple_result_" + name.to_s, res)
|
248
|
+
# res
|
249
|
+
# else
|
250
|
+
# res = self.send(multi_name)
|
251
|
+
# self.instance_variable_set("@multiple_result_" + name.to_s, res)
|
252
|
+
# res
|
253
|
+
# end
|
254
|
+
# end
|
255
|
+
#
|
256
|
+
# else
|
257
|
+
# raise "Type not undestood in property: #{ type }"
|
258
|
+
# end
|
259
|
+
# @all_properties ||= []
|
260
|
+
# @all_properties << name
|
261
|
+
# end
|
262
|
+
#
|
263
|
+
# def self.persist(method_name, type = nil, options = {})
|
264
|
+
# type = :memory if type.nil?
|
265
|
+
# options ||= {}
|
266
|
+
# options = IndiferentHash.add_defaults options, :dir => File.join(Entity.entity_property_cache, self.to_s, method_name.to_s)
|
267
|
+
#
|
268
|
+
# orig_method_name = method_name
|
269
|
+
# multi_name = "_multiple_" + method_name.to_s
|
270
|
+
# single_name = "_single_" + method_name.to_s
|
271
|
+
#
|
272
|
+
# method_name = multi_name if self.instance_methods.include?(multi_name.to_sym)
|
273
|
+
# method_name = single_name if self.instance_methods.include?(single_name.to_sym)
|
274
|
+
#
|
275
|
+
# orig_name = UNPERSISTED_PREFIX + method_name.to_s
|
276
|
+
# alias_method orig_name, method_name unless self.instance_methods.include? orig_name.to_sym
|
277
|
+
#
|
278
|
+
# define_method method_name do |*args|
|
279
|
+
# id = self.id
|
280
|
+
# persist_name = orig_method_name.to_s + ":" << (Array === id ? Misc.digest(id) : id)
|
281
|
+
#
|
282
|
+
# persist_options = options
|
283
|
+
# persist_options = persist_options.merge(:other => {:args => args}) if args and args.any?
|
284
|
+
#
|
285
|
+
# begin
|
286
|
+
# Persist.persist(persist_name, type, persist_options.merge(:persist => true)) do
|
287
|
+
# self.send(orig_name, *args)
|
288
|
+
# end
|
289
|
+
# rescue DontPersist
|
290
|
+
# $!.payload
|
291
|
+
# end
|
292
|
+
# end
|
293
|
+
# end
|
294
|
+
#
|
295
|
+
# def self.unpersist(method_name)
|
296
|
+
# return unless orig_name = persisted?(method_name)
|
297
|
+
# alias_method method_name, orig_name
|
298
|
+
# remove_method orig_name
|
299
|
+
# end
|
300
|
+
#
|
301
|
+
# def self.persisted?(method_name)
|
302
|
+
# ["", "_multiple_", "_single_"].each do |type|
|
303
|
+
# orig_name = (UNPERSISTED_PREFIX + type + method_name.to_s).to_sym
|
304
|
+
# return orig_name if instance_methods.include?(orig_name)
|
305
|
+
# end
|
306
|
+
# return false
|
307
|
+
# end
|
308
|
+
#
|
309
|
+
# def self.with_persisted(method_name)
|
310
|
+
# persisted = persisted? method_name
|
311
|
+
# persist method_name unless persisted
|
312
|
+
# res = yield
|
313
|
+
# unpersist method_name unless persisted
|
314
|
+
# res
|
315
|
+
# end
|
316
|
+
#
|
317
|
+
# end
|
318
|
+
# end
|
319
|
+
#end
|