ckuru-tools 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ckuru-tools.rb +27 -0
- metadata +11 -12
- data/lib/ckuru-tools.rb~ +0 -499
data/lib/ckuru-tools.rb
CHANGED
@@ -345,6 +345,15 @@ EOF
|
|
345
345
|
ret
|
346
346
|
end
|
347
347
|
|
348
|
+
def docmdq(cmd,dir=nil)
|
349
|
+
ret = docmdqi(cmd,dir)
|
350
|
+
if ret.exitstatus != 0
|
351
|
+
raise "cmd #{cmd} exitstatus #{ret.exitstatus} : #{ret}"
|
352
|
+
end
|
353
|
+
ret
|
354
|
+
end
|
355
|
+
|
356
|
+
|
348
357
|
def docmdi(cmd,dir=nil)
|
349
358
|
if dir
|
350
359
|
unless Dir.chdir(dir)
|
@@ -363,6 +372,24 @@ EOF
|
|
363
372
|
end
|
364
373
|
$?
|
365
374
|
end
|
375
|
+
|
376
|
+
def docmdqi(cmd,dir=nil)
|
377
|
+
if dir
|
378
|
+
unless Dir.chdir(dir)
|
379
|
+
ckebug 0, "failed to cd to #{dir}"
|
380
|
+
return nil
|
381
|
+
end
|
382
|
+
end
|
383
|
+
cmd.gsub!(/\\/,"\\\\\\\\\\\\\\\\")
|
384
|
+
cmd.gsub!(/\'/,"\\\\'")
|
385
|
+
cmd.gsub!(/\"/,"\\\\\\\\\\\"")
|
386
|
+
system("bash -c \"#{cmd}\"")
|
387
|
+
if $?.exitstatus != 0
|
388
|
+
print " ** failed ** exit code #{$?.exitstatus} "
|
389
|
+
end
|
390
|
+
$?
|
391
|
+
end
|
392
|
+
|
366
393
|
|
367
394
|
################################################################################
|
368
395
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ckuru-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: The infamous ckuru-tools gem. A miscellaneous grab bag of ruby class
|
15
15
|
extensions, utility classes, etc.
|
@@ -18,25 +18,24 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- ./spec/spec_helper.rb
|
22
21
|
- ./spec/ckuru-tools_spec.rb
|
22
|
+
- ./spec/spec_helper.rb
|
23
23
|
- ./lib/args.rb
|
24
|
-
- ./lib/debug.rb
|
25
|
-
- ./lib/ckuru-tools.rb~
|
26
24
|
- ./lib/ckuru-tools.rb
|
25
|
+
- ./lib/debug.rb
|
26
|
+
- ./tasks/ann.rake
|
27
|
+
- ./tasks/bones.rake
|
27
28
|
- ./tasks/gem.rake
|
28
|
-
- ./tasks/notes.rake
|
29
29
|
- ./tasks/git.rake
|
30
|
-
- ./tasks/
|
30
|
+
- ./tasks/manifest.rake
|
31
|
+
- ./tasks/notes.rake
|
31
32
|
- ./tasks/post_load.rake
|
33
|
+
- ./tasks/rdoc.rake
|
32
34
|
- ./tasks/rubyforge.rake
|
33
35
|
- ./tasks/setup.rb
|
34
|
-
- ./tasks/
|
36
|
+
- ./tasks/spec.rake
|
35
37
|
- ./tasks/svn.rake
|
36
|
-
- ./tasks/manifest.rake
|
37
|
-
- ./tasks/rdoc.rake
|
38
38
|
- ./tasks/test.rake
|
39
|
-
- ./tasks/spec.rake
|
40
39
|
- ./bin/ckuru-arg-tester
|
41
40
|
- ./bin/ckuru-tools
|
42
41
|
- ./bin/generate_as_controller
|
@@ -61,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
60
|
version: '0'
|
62
61
|
requirements: []
|
63
62
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.8.
|
63
|
+
rubygems_version: 1.8.24
|
65
64
|
signing_key:
|
66
65
|
specification_version: 3
|
67
66
|
summary: The infamous ckuru-tools gem. A miscellaneous grab bag of ruby class extensions,
|
data/lib/ckuru-tools.rb~
DELETED
@@ -1,499 +0,0 @@
|
|
1
|
-
# $Id$
|
2
|
-
|
3
|
-
# Equivalent to a header guard in C/C++
|
4
|
-
# Used to prevent the class/module from being loaded more than once
|
5
|
-
unless defined? CkuruTools
|
6
|
-
|
7
|
-
class Module
|
8
|
-
def instance_of_class_accessor( klass, *symbols )
|
9
|
-
|
10
|
-
symbols.each do |symbol|
|
11
|
-
module_eval( "def #{symbol}() @#{symbol}; end" )
|
12
|
-
module_eval( "def #{symbol}=(val) raise ArgumentError.new('#{symbol} must be a #{klass}, not one of ' + val.class.ancestors.to_s) unless val.class.inherits_from? #{klass} ; @#{symbol} = val; self.send(:after_#{symbol}_set) if self.respond_to?(:after_#{symbol}_set); end" )
|
13
|
-
end
|
14
|
-
end
|
15
|
-
def class_accessor( klass, *symbols )
|
16
|
-
symbols.each do |symbol|
|
17
|
-
module_eval( "def #{symbol}() @#{symbol}; end" )
|
18
|
-
module_eval( "
|
19
|
-
def #{symbol}=(val)
|
20
|
-
raise ArgumentError.new('argument to #{symbol} must be a class') unless val.is_a? Class
|
21
|
-
raise ArgumentError.new('#{symbol} must be a #{klass}') unless val.inherits_from? #{klass}
|
22
|
-
@#{symbol} = val
|
23
|
-
end" )
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# raise ArgumentError.new("assignment must be of class CkuruTools::TypedArray, not \#{arr.class}") unless arr.instance_inherits_from? CkuruTools::TypedArray
|
28
|
-
# raise ArgumentError.new("TypedArray must require #{klass}") unless arr.required_type == #{klass}
|
29
|
-
def typed_array_accessor(klass,*symbols)
|
30
|
-
symbols.each do |symbol|
|
31
|
-
module_eval( "def #{symbol}() @#{symbol}; end" )
|
32
|
-
module_eval <<"EOF"
|
33
|
-
def #{symbol}=(arr)
|
34
|
-
@#{symbol} = CkuruTools::TypedArray.new(#{klass})
|
35
|
-
arr.each do |elem|
|
36
|
-
@#{symbol}.push elem
|
37
|
-
end
|
38
|
-
@#{symbol}
|
39
|
-
end
|
40
|
-
EOF
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
module CkuruTools
|
46
|
-
|
47
|
-
def self.parameters(h,*args)
|
48
|
-
raise ArgumentError.new("argument to #{self.class}##{current_method} must be of class Hash; you may get this error if you don't call a function with a hash; check the initial call") unless h.is_a? Hash
|
49
|
-
ret = []
|
50
|
-
args.each do |a|
|
51
|
-
name,options = a
|
52
|
-
options = options || {}
|
53
|
-
unless h[:no_recurse]
|
54
|
-
vals = only_these_parameters(
|
55
|
-
options.merge!(:no_recurse => true),
|
56
|
-
[:instance_that_inherits_from, {:instance_of => Class}],
|
57
|
-
[:instance_of, {:instance_of => Class}],
|
58
|
-
[:klass_that_inherits_from, {:instance_of => Class}],
|
59
|
-
[:klass_of, {:instance_of => Class}],
|
60
|
-
[:no_recurse, {:instance_of => TrueClass}],
|
61
|
-
[:required, {:instance_of => TrueClass}],
|
62
|
-
[:default, {:instance_of => TrueClass}]
|
63
|
-
)
|
64
|
-
instance_that_inherits_from, instance_of, klass_that_inherits_from, klass_of, no_recurse, required, default = vals
|
65
|
-
end
|
66
|
-
|
67
|
-
if val = h[name]
|
68
|
-
if instance_that_inherits_from
|
69
|
-
unless val.class.inherits_from? instance_that_inherits_from
|
70
|
-
raise ArgumentError.new(
|
71
|
-
"argument :#{name} to #{self.class}##{calling_method} must be an instance that inherits from #{instance_that_inherits_from}, #{val.class} does not")
|
72
|
-
end
|
73
|
-
elsif instance_of
|
74
|
-
unless val.class == instance_of
|
75
|
-
raise ArgumentError.new(
|
76
|
-
"argument :#{name} to #{self.class}##{calling_method} must be an instance of class #{instance_of}, not #{val.class}")
|
77
|
-
end
|
78
|
-
elsif klass_that_inherits_from
|
79
|
-
unless val.inherits_from? klass_that_inherits_from
|
80
|
-
raise ArgumentError.new("argument :#{name} to #{self.class}##{calling_method} must inherits from class #{klass_that_inherits_from}, #{val} does not")
|
81
|
-
end
|
82
|
-
elsif klass_of
|
83
|
-
unless val == klass_to
|
84
|
-
raise ArgumentError.new("argument :#{name} to #{self.class}##{calling_method} must be of class #{klass_of}, not #{val}")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
else
|
88
|
-
if options[:default]
|
89
|
-
val = options[:default]
|
90
|
-
elsif options[:required]
|
91
|
-
raise ArgumentError.new("argument :#{name} to #{self.class}##{calling_method} is required")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
ret.push val
|
95
|
-
end
|
96
|
-
ret
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
def self.only_these_parameters(h,*args)
|
101
|
-
ret = parameters(h,*args)
|
102
|
-
keys = h.keys
|
103
|
-
args.each do |a|
|
104
|
-
name,options = a
|
105
|
-
keys.delete name
|
106
|
-
end
|
107
|
-
if keys.length > 0
|
108
|
-
raise ArgumentError.new("unknown parameters #{keys.inspect} passed to #{self.class}##{calling_method}")
|
109
|
-
end
|
110
|
-
ret
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.validate_hash_arguments(h,*args)
|
114
|
-
raise ArgumentError.new("argument to #{current_method} must be of class Hash") unless h.is_a? Hash
|
115
|
-
ret = []
|
116
|
-
args.each do |a|
|
117
|
-
name,options = a
|
118
|
-
options = options || {}
|
119
|
-
unless h[:no_recurse]
|
120
|
-
vals = only_these_parameters(
|
121
|
-
options.merge!(:no_recurse => true),
|
122
|
-
[:instance_that_inherits_from, {:instance_of => Class}],
|
123
|
-
[:instance_of, {:instance_of => Class}],
|
124
|
-
[:klass_that_inherits_from, {:instance_of => Class}],
|
125
|
-
[:klass_of, {:instance_of => Class}],
|
126
|
-
[:no_recurse, {:instance_of => TrueClass}],
|
127
|
-
[:required, {:instance_of => TrueClass}],
|
128
|
-
[:default, {:instance_of => TrueClass}]
|
129
|
-
)
|
130
|
-
instance_that_inherits_from, instance_of, klass_that_inherits_from, klass_of, no_recurse, required, default = vals
|
131
|
-
end
|
132
|
-
|
133
|
-
if val = h[name]
|
134
|
-
if instance_that_inherits_from
|
135
|
-
unless val.class.inherits_from? instance_that_inherits_from
|
136
|
-
raise ArgumentError.new(
|
137
|
-
"argument :#{name} to #{calling_method} must be an instance that inherits from #{instance_that_inherits_from}, #{val.class} does not")
|
138
|
-
end
|
139
|
-
elsif instance_of
|
140
|
-
unless val.class == instance_of
|
141
|
-
raise ArgumentError.new(
|
142
|
-
"argument :#{name} to #{calling_method} must be an instance of class #{instance_of}, not #{val.class}")
|
143
|
-
end
|
144
|
-
elsif klass_that_inherits_from
|
145
|
-
unless val.inherits_from? klass_that_inherits_from
|
146
|
-
raise ArgumentError.new("argument :#{name} to #{calling_method} must inherits from class #{klass_that_inherits_from}, #{val} does not")
|
147
|
-
end
|
148
|
-
elsif klass_of
|
149
|
-
unless val == klass_of
|
150
|
-
raise ArgumentError.new("argument :#{name} to #{calling_method} must be of class #{klass_of}, not #{val}")
|
151
|
-
end
|
152
|
-
end
|
153
|
-
else
|
154
|
-
if options[:default]
|
155
|
-
val = options[:default]
|
156
|
-
elsif options[:required]
|
157
|
-
raise ArgumentError.new("argument :#{name} to #{calling_method} is required")
|
158
|
-
end
|
159
|
-
end
|
160
|
-
ret.push val
|
161
|
-
end
|
162
|
-
ret
|
163
|
-
end
|
164
|
-
|
165
|
-
|
166
|
-
def self.class_space
|
167
|
-
ret = TypedArray.new(Class)
|
168
|
-
ObjectSpace.each_object {|x| ret.push(x) if x.is_a? Class}
|
169
|
-
ret.uniq
|
170
|
-
end
|
171
|
-
|
172
|
-
# :stopdoc:
|
173
|
-
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
174
|
-
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
175
|
-
# :startdoc:
|
176
|
-
|
177
|
-
# Returns the version string for the library.
|
178
|
-
#
|
179
|
-
def self.version
|
180
|
-
VERSION
|
181
|
-
end
|
182
|
-
|
183
|
-
# Returns the library path for the module. If any arguments are given,
|
184
|
-
# they will be joined to the end of the libray path using
|
185
|
-
# <tt>File.join</tt>.
|
186
|
-
#
|
187
|
-
def self.libpath( *args )
|
188
|
-
args.empty? ? LIBPATH : ::File.join(LIBPATH, *args)
|
189
|
-
end
|
190
|
-
|
191
|
-
# Returns the lpath for the module. If any arguments are given,
|
192
|
-
# they will be joined to the end of the path using
|
193
|
-
# <tt>File.join</tt>.
|
194
|
-
#
|
195
|
-
def self.path( *args )
|
196
|
-
args.empty? ? PATH : ::File.join(PATH, *args)
|
197
|
-
end
|
198
|
-
|
199
|
-
# Utility method used to rquire all files ending in .rb that lie in the
|
200
|
-
# directory below this file that has the same name as the filename passed
|
201
|
-
# in. Optionally, a specific _directory_ name can be passed in such that
|
202
|
-
# the _filename_ does not have to be equivalent to the directory.
|
203
|
-
#
|
204
|
-
def self.require_all_libs_relative_to( fname, dir = nil )
|
205
|
-
dir ||= ::File.basename(fname, '.*')
|
206
|
-
search_me = ::File.expand_path(
|
207
|
-
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
208
|
-
|
209
|
-
Dir.glob(search_me).sort.each {|rb| require rb}
|
210
|
-
end
|
211
|
-
|
212
|
-
#
|
213
|
-
# extending HashInitalizerClass enables you to get Object.new(hash) functionality
|
214
|
-
# where each key will dispatch to an object setter method.
|
215
|
-
#
|
216
|
-
# Usage:
|
217
|
-
#
|
218
|
-
# class MyClass < HashInitalizerClass
|
219
|
-
# ..attr_accessor :foo
|
220
|
-
# end
|
221
|
-
#
|
222
|
-
# m = MyClass(:foo => "bar")
|
223
|
-
# m.foo
|
224
|
-
# => "bar"
|
225
|
-
#
|
226
|
-
#
|
227
|
-
|
228
|
-
class HashInitializerClass
|
229
|
-
# check for required attributes
|
230
|
-
def required_attributes(*symbols)
|
231
|
-
symbols.each do |symbol|
|
232
|
-
raise ArgumentError.new("attribute :#{symbol} must be set in #{self.class}.initialize") if self.send(symbol).nil?
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
# parse and return parameters from a hash
|
237
|
-
#
|
238
|
-
# view = only_these_parameters(h,[:view,{:klass => View,:required => true}])
|
239
|
-
# or
|
240
|
-
#
|
241
|
-
# view = parameters(h,[:view,{:klass => View,:required => true}])
|
242
|
-
|
243
|
-
def parameters(h,*args)
|
244
|
-
CkuruTools.parameters(h,args)
|
245
|
-
end
|
246
|
-
|
247
|
-
# insure that only the defined parameters have been passed to a function
|
248
|
-
def only_these_parameters(h,*args)
|
249
|
-
CkuruTools.only_these_parameters(h,args)
|
250
|
-
end
|
251
|
-
|
252
|
-
|
253
|
-
def initialize(h={})
|
254
|
-
raise ArgumentError.new("argument to #{self.class}##{current_method} must be of class Hash") unless h.is_a? Hash
|
255
|
-
h.keys.each do |k|
|
256
|
-
self.send("#{k}=",h[k])
|
257
|
-
end
|
258
|
-
|
259
|
-
yield self if block_given?
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
end # module CkuruTools
|
264
|
-
|
265
|
-
CkuruTools.require_all_libs_relative_to __FILE__
|
266
|
-
CkuruTools.require_all_libs_relative_to CkuruTools.libpath
|
267
|
-
|
268
|
-
#
|
269
|
-
# class Foo < ActiveRecord::Base
|
270
|
-
# end
|
271
|
-
#
|
272
|
-
# Foo.inherits_from? ActiveRecord::Base
|
273
|
-
# => true
|
274
|
-
#
|
275
|
-
class Class
|
276
|
-
|
277
|
-
# show's live decendants of this class
|
278
|
-
def decendants
|
279
|
-
CkuruTools.class_space.select {|x| x.inherits_from? self and x != self}
|
280
|
-
end
|
281
|
-
|
282
|
-
def inherits_from?(klass)
|
283
|
-
raise ArgumentError.new("argument must be of type Class") unless klass.is_a? Class
|
284
|
-
if klass == self
|
285
|
-
true
|
286
|
-
elsif self.superclass.is_a? Class
|
287
|
-
self.superclass.inherits_from? klass
|
288
|
-
else
|
289
|
-
false
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
class Array
|
295
|
-
def to_comma_separated_string
|
296
|
-
ret = ''
|
297
|
-
self.each do |elem|
|
298
|
-
ret += ',' if ret.length > 0
|
299
|
-
ret += elem.to_s
|
300
|
-
end
|
301
|
-
ret
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
class Object
|
306
|
-
# this method allows a an 'initialize' method to define itself as a abstract class; yet still run some code.
|
307
|
-
#
|
308
|
-
# To use effectively place at the last line of an initialize method like so:
|
309
|
-
#
|
310
|
-
# class DataSource < ::CkuruTools::HashInitializerClass
|
311
|
-
# def initialize(h={})
|
312
|
-
# super h
|
313
|
-
# this_is_an_abstract_constructor_for AuraVisualize::DataSource
|
314
|
-
# end
|
315
|
-
# end
|
316
|
-
|
317
|
-
def this_is_an_abstract_constructor_for(klass)
|
318
|
-
unless self.class.superclass.inherits_from? klass # abstract constructor
|
319
|
-
str = ''
|
320
|
-
self.class.decendants.each do |d|
|
321
|
-
str += "#{d}\n"
|
322
|
-
end
|
323
|
-
raise <<"EOF"
|
324
|
-
Do not call method of #{self.class}.#{calling_method} directly, you must instantiate a base class.
|
325
|
-
|
326
|
-
Maybe you want one of these?:
|
327
|
-
|
328
|
-
#{str}
|
329
|
-
EOF
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
# see if this object's class inherits from another class
|
334
|
-
def instance_inherits_from?(klass)
|
335
|
-
self.class.inherits_from?(klass)
|
336
|
-
end
|
337
|
-
|
338
|
-
def _require ; each {|r| require r } ; end
|
339
|
-
|
340
|
-
def docmd(cmd,dir=nil)
|
341
|
-
ret = docmdi(cmd,dir)
|
342
|
-
if ret.exitstatus != 0
|
343
|
-
raise "cmd #{cmd} exitstatus #{ret.exitstatus} : #{ret}"
|
344
|
-
end
|
345
|
-
ret
|
346
|
-
end
|
347
|
-
|
348
|
-
def docmdi(cmd,dir=nil)
|
349
|
-
if dir
|
350
|
-
unless Dir.chdir(dir)
|
351
|
-
ckebug 0, "failed to cd to #{dir}"
|
352
|
-
return nil
|
353
|
-
end
|
354
|
-
end
|
355
|
-
ret = msg_exec "running #{cmd}" do
|
356
|
-
cmd.gsub!(/\\/,"\\\\\\\\\\\\\\\\")
|
357
|
-
cmd.gsub!(/\'/,"\\\\'")
|
358
|
-
cmd.gsub!(/\"/,"\\\\\\\\\\\"")
|
359
|
-
system("bash -c \"#{cmd}\"")
|
360
|
-
if $?.exitstatus != 0
|
361
|
-
print " ** failed ** exit code #{$?.exitstatus} "
|
362
|
-
end
|
363
|
-
end
|
364
|
-
$?
|
365
|
-
end
|
366
|
-
|
367
|
-
################################################################################
|
368
|
-
|
369
|
-
def docmd_dir(h={})
|
370
|
-
ret = nil
|
371
|
-
if h[:dir]
|
372
|
-
unless Dir.chdir(h[:dir])
|
373
|
-
ckebug 0, "failed to cd to #{h[:dir]}"
|
374
|
-
return nil
|
375
|
-
end
|
376
|
-
end
|
377
|
-
if h[:commands]
|
378
|
-
h[:commands].each do |cmd|
|
379
|
-
ret = docmd(cmd)
|
380
|
-
if ret.exitstatus != 0
|
381
|
-
ckebug 0, "giving up"
|
382
|
-
return ret
|
383
|
-
end
|
384
|
-
end
|
385
|
-
end
|
386
|
-
ret
|
387
|
-
end
|
388
|
-
|
389
|
-
def emacs_trace
|
390
|
-
begin
|
391
|
-
yield
|
392
|
-
rescue Exception => e
|
393
|
-
puts e
|
394
|
-
puts "... exception thrown from ..."
|
395
|
-
e.backtrace.each do |trace|
|
396
|
-
a = trace.split(/:/)
|
397
|
-
if a[0].match(/^\//)
|
398
|
-
puts "#{a[0]}:#{a[1]}: #{a[2..a.length].join(':')}"
|
399
|
-
else
|
400
|
-
d = File.dirname(a[0])
|
401
|
-
f = File.basename(a[0])
|
402
|
-
dir = `cd #{d}; pwd`.chomp
|
403
|
-
goodpath = File.join(dir,f)
|
404
|
-
|
405
|
-
puts "#{goodpath}:#{a[1]}: #{a[2..a.length].join(':')}"
|
406
|
-
end
|
407
|
-
if $emacs_trace_debugger
|
408
|
-
require 'ruby-debug'
|
409
|
-
end
|
410
|
-
end
|
411
|
-
raise "sorry ...exiting"
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
def ckebug(level,msg)
|
416
|
-
CkuruTools::Debug.instance.debug(level,msg)
|
417
|
-
end
|
418
|
-
|
419
|
-
def current_method
|
420
|
-
caller[0].match(/`(.*?)'/)[1]
|
421
|
-
end
|
422
|
-
|
423
|
-
def calling_method
|
424
|
-
caller[1] ? caller[1].match(/`(.*?)'/)[1] : ""
|
425
|
-
end
|
426
|
-
|
427
|
-
def calling_method2
|
428
|
-
if caller[2]
|
429
|
-
if matchdata = caller[2].match(/`(.*?)'/)
|
430
|
-
matchdata[1]
|
431
|
-
else
|
432
|
-
""
|
433
|
-
end
|
434
|
-
else
|
435
|
-
""
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
def calling_method3
|
440
|
-
if caller[3]
|
441
|
-
if matchdata = caller[3].match(/`(.*?)'/)
|
442
|
-
matchdata[2]
|
443
|
-
else
|
444
|
-
""
|
445
|
-
end
|
446
|
-
else
|
447
|
-
""
|
448
|
-
end
|
449
|
-
end
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
def calling_method_sig
|
454
|
-
caller[1] ? caller[1] : ""
|
455
|
-
end
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
# def calling_method
|
460
|
-
# if caller[2]
|
461
|
-
# caller[2].match(/`(.*?)'/)[1]
|
462
|
-
# else
|
463
|
-
# ""
|
464
|
-
# end
|
465
|
-
|
466
|
-
# end
|
467
|
-
|
468
|
-
end
|
469
|
-
end
|
470
|
-
|
471
|
-
class Time
|
472
|
-
def ckuru_time_string
|
473
|
-
strftime("%m/%d/%Y %H;%M;%S")
|
474
|
-
end
|
475
|
-
end
|
476
|
-
|
477
|
-
def printmsg(msg,newline=true)
|
478
|
-
print "#{Time.new.ckuru_time_string}: #{msg}"
|
479
|
-
puts if newline
|
480
|
-
end
|
481
|
-
|
482
|
-
|
483
|
-
#module MlImportUtils
|
484
|
-
def msg_exec(msg)
|
485
|
-
printmsg("#{msg} ... ",false)
|
486
|
-
t1 = Time.new
|
487
|
-
ret = yield
|
488
|
-
puts "done (#{Time.new - t1})"
|
489
|
-
ret
|
490
|
-
end
|
491
|
-
|
492
|
-
def chatty_exec(level,name)
|
493
|
-
ret = yield
|
494
|
-
ckebug level, "#{name} is #{ret}"
|
495
|
-
ret
|
496
|
-
end
|
497
|
-
|
498
|
-
|
499
|
-
# EOF
|