perception 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/0 start all Tests.bat +20 -0
- data/History.txt +4 -0
- data/License.txt +21 -0
- data/Manifest.txt +29 -0
- data/PostInstall.txt +6 -0
- data/README.txt +55 -0
- data/Rakefile.rb +127 -0
- data/demo/demo_pp.rb +163 -0
- data/demo/demo_zz.rb +332 -0
- data/init.rb +2 -0
- data/lib/perception/const.rb +78 -0
- data/lib/perception/date_and_time.rb +78 -0
- data/lib/perception/logging.rb +123 -0
- data/lib/perception/numeric.rb +194 -0
- data/lib/perception/perception_main.rb +317 -0
- data/lib/perception/perception_private.rb +231 -0
- data/lib/perception/ppp.rb +377 -0
- data/lib/perception/string_spread.rb +155 -0
- data/lib/perception/test.rb +114 -0
- data/lib/perception.rb +36 -0
- data/test/_start_all.rb +10 -0
- data/test/test_date_and_time.rb +54 -0
- data/test/test_numeric.rb +104 -0
- data/test/test_ppp.rb +297 -0
- data/website/index.html +11 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +119 -0
data/demo/demo_zz.rb
ADDED
@@ -0,0 +1,332 @@
|
|
1
|
+
|
2
|
+
if $0 == __FILE__
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'perception' )
|
4
|
+
else
|
5
|
+
require 'perception'
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
module Perception #:nodoc
|
10
|
+
|
11
|
+
class DemoSee
|
12
|
+
@@initialized_count = 0
|
13
|
+
|
14
|
+
def initialize( announce_first=true )
|
15
|
+
@@initialized_count += 1
|
16
|
+
return if (@@initialized_count == 1 && !announce_first)
|
17
|
+
seee.fast!
|
18
|
+
#seee.left!
|
19
|
+
seee.indent!
|
20
|
+
see ("\n" * 5) if @@initialized_count > 1
|
21
|
+
see "Perception Demo ##{@@initialized_count}"
|
22
|
+
see "=================="
|
23
|
+
see
|
24
|
+
wait_for_key('Press any key to start')
|
25
|
+
end # def
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
# Printing basic types
|
30
|
+
def demo_see_basic_types
|
31
|
+
see '1dim Arrays:'
|
32
|
+
see a=['this','is','an','array','1']
|
33
|
+
see b=['this','is','another','array','2']
|
34
|
+
see c=['and','this','is','another', :tree]
|
35
|
+
see d=['complex array', [1,2,3], {:key => :value, :love => :baby}, 4.0, :four]
|
36
|
+
see d=['next','is','two','blank', 'lines']
|
37
|
+
see
|
38
|
+
see
|
39
|
+
see '2dim Arrays'
|
40
|
+
see [a,b,c,d]
|
41
|
+
see
|
42
|
+
see
|
43
|
+
see 'Other Objects:'
|
44
|
+
see []
|
45
|
+
see 'ordinary string (without "")'
|
46
|
+
see '(next one is empty)'
|
47
|
+
see ''
|
48
|
+
see 1
|
49
|
+
see 2
|
50
|
+
see 3.0
|
51
|
+
see nil
|
52
|
+
see true
|
53
|
+
see false
|
54
|
+
see :a_symbol
|
55
|
+
see({:key => :value, :love => :baby})
|
56
|
+
see ['complex array', [1,2,3], {:key => :value, :love => :baby}, 3.0 , '']
|
57
|
+
end # def
|
58
|
+
|
59
|
+
|
60
|
+
def demo_level
|
61
|
+
seee.slow!
|
62
|
+
see "The printout is automaticaly indented. This is the printout of a nested structure of #see's:"
|
63
|
+
see
|
64
|
+
see
|
65
|
+
seee.indent!
|
66
|
+
sub_demo_level
|
67
|
+
see
|
68
|
+
see
|
69
|
+
wait_for_key
|
70
|
+
see 'You can force left printout with seee.left!. Reactivate indention with seee.indent!.'
|
71
|
+
seee.left!
|
72
|
+
see
|
73
|
+
see
|
74
|
+
sub_demo_level
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def sub_demo_level
|
79
|
+
see "Hello world. This is level zero. "
|
80
|
+
(1..1).each do
|
81
|
+
see "This is the beginning of level one."
|
82
|
+
1.downto(1) do
|
83
|
+
see "This is the beginning of level two."
|
84
|
+
1.upto(1) do
|
85
|
+
see "This is the beginning of level three."
|
86
|
+
1.times do
|
87
|
+
see "This is the beginning of level four."
|
88
|
+
see "This is the end of level four."
|
89
|
+
end
|
90
|
+
see "This is the end of level three."
|
91
|
+
end
|
92
|
+
see "This is the end of level two."
|
93
|
+
end
|
94
|
+
see "This is the end of level one."
|
95
|
+
end
|
96
|
+
see "This is level zero again. Bye. "
|
97
|
+
end # def
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
# slow printing
|
105
|
+
def demo_see_slowdown1
|
106
|
+
seee.slow!
|
107
|
+
see 'This is a string'
|
108
|
+
see 'and here we have a longer one.'
|
109
|
+
see 'so we need even longeer strings, but they all have to be different.'
|
110
|
+
see '#see has forgotten the first string. So I will tell him again: This is a string. and here we have a longer one. '
|
111
|
+
see 'In slow mode #see waits for you to read the lines. More words, longer waiting.'
|
112
|
+
see 'short prints...'
|
113
|
+
see '...short waiting.'
|
114
|
+
see 'short prints...'
|
115
|
+
see '...short waiting.'
|
116
|
+
string = 'This string is getting longer.'
|
117
|
+
(1..10).each do |i|
|
118
|
+
see string
|
119
|
+
string += ' But it repeats.'
|
120
|
+
end
|
121
|
+
see '#see only counts those words you have to read.'
|
122
|
+
see 'You can choose the speed. This is faster:'
|
123
|
+
|
124
|
+
wait_for_key
|
125
|
+
see
|
126
|
+
seee.slow!(0.5)
|
127
|
+
see 'This is a string'
|
128
|
+
see 'and here we have a longer one.'
|
129
|
+
see 'so we need even longeer strings, but they all have to be different.'
|
130
|
+
see '#see has forgotten the first string. So I will tell him again: This is a string. and here we have a longer one. '
|
131
|
+
see 'In slow mode #see waits for you to read the lines. More words, longer waiting.'
|
132
|
+
see 'short prints...'
|
133
|
+
see '...short waiting.'
|
134
|
+
see '...short waiting.'
|
135
|
+
string = 'This string is getting longer.'
|
136
|
+
(1..10).each do |i|
|
137
|
+
see string
|
138
|
+
string += ' But it repeats.'
|
139
|
+
end
|
140
|
+
see '#see only counts those words you have to read.'
|
141
|
+
see
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
def demo_see_slowdown2
|
146
|
+
seee.slow!
|
147
|
+
(1..8).each do |i|
|
148
|
+
see "#{i} see this "
|
149
|
+
end
|
150
|
+
(1..8).each do |i|
|
151
|
+
see "#{i} see that "
|
152
|
+
sleep 0.05
|
153
|
+
end
|
154
|
+
see 'The speed was always the same, but each "see that" took double the time.'
|
155
|
+
see '#see knows the time since last print.'
|
156
|
+
see 'You can use this for simple benchmarking:'
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
# Simple benchmarking
|
161
|
+
def demo_bench
|
162
|
+
see "I'm counting to 10 000 000, please wait."
|
163
|
+
10000000.downto(0) {}
|
164
|
+
see "it took #{seee.bench} seconds."
|
165
|
+
see 'You always get the time since last print with seee.bench.'
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# temporary printing
|
170
|
+
def demo_see_temp_and_clear_last
|
171
|
+
seee.slow!
|
172
|
+
see_print "countdown: "
|
173
|
+
10.downto(0) do |i|
|
174
|
+
see_temp i
|
175
|
+
end
|
176
|
+
see 'finished!'
|
177
|
+
sleep 1
|
178
|
+
seee.clear!
|
179
|
+
see 'You can clear the last print with seee.clear!'
|
180
|
+
see 'And you can print temporary informations with see_temp'
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
# print two informations on one line
|
185
|
+
def demo_see_flash1
|
186
|
+
seee.fast!
|
187
|
+
(1..1000).each do |i|
|
188
|
+
see "I am line number #{i}. Waiting for line number 327."
|
189
|
+
seee.flash! if i == 327
|
190
|
+
end
|
191
|
+
see 'You can make the last printout blink with seee.flash!'
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
# print two informations on one line
|
196
|
+
def demo_alternate_see
|
197
|
+
see ['this','is','an','array',:one]
|
198
|
+
see ['this','is','an','array',:two]
|
199
|
+
see ['this','is','an','array',:three]
|
200
|
+
see ['this', [1,2,3], {:wEDSG => :DZHe5D, :DShg => :DGStdf}, 4.0, :four]
|
201
|
+
seee.flash! ' Hoops!! '
|
202
|
+
see ['this','is','an','array',:five]
|
203
|
+
see ['this','is','an','array',:six]
|
204
|
+
see ['this','is','an','array',:seven]
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
def demo_flash_puts
|
209
|
+
see 'Bla Bla '
|
210
|
+
see 'Bla Bla '
|
211
|
+
see 'Bla Bla '
|
212
|
+
see 'Bla Bla '
|
213
|
+
see 'Bla Bla '
|
214
|
+
see 'Bla Bla '
|
215
|
+
see 'Bla Bla '
|
216
|
+
see 'Bla Bla '
|
217
|
+
see 'Important'
|
218
|
+
seee.flash!
|
219
|
+
see 'Bla Bla '
|
220
|
+
see 'Bla Bla '
|
221
|
+
see 'Bla Bla '
|
222
|
+
see 'Bla Bla '
|
223
|
+
see 'Bla Bla '
|
224
|
+
see 'Bla Bla '
|
225
|
+
see 'Bla Bla '
|
226
|
+
see 'Bla Bla '
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
def demo_flash_pp
|
231
|
+
see_pp 'Bla Bla '
|
232
|
+
see_pp 'Bla Bla '
|
233
|
+
see_pp 'Bla Bla '
|
234
|
+
see_pp 'Bla Bla '
|
235
|
+
see_pp 'Bla Bla '
|
236
|
+
see_pp 'Bla Bla '
|
237
|
+
see_pp 'Bla Bla '
|
238
|
+
see_pp 'Bla Bla '
|
239
|
+
see_pp 'Important '
|
240
|
+
seee.flash!
|
241
|
+
see_pp 'Bla Bla '
|
242
|
+
see_pp 'Bla Bla '
|
243
|
+
see_pp 'Bla Bla '
|
244
|
+
see_pp 'Bla Bla '
|
245
|
+
see_pp 'Bla Bla '
|
246
|
+
see_pp 'Bla Bla '
|
247
|
+
see_pp 'Bla Bla '
|
248
|
+
see_pp 'Bla Bla '
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
def demo_flash_print
|
253
|
+
see_print 'Bla Bla '
|
254
|
+
see_print 'Bla Bla '
|
255
|
+
see_print 'Bla Bla '
|
256
|
+
see_print 'Bla Bla '
|
257
|
+
see_print 'Bla Bla '
|
258
|
+
see_print 'Bla Bla '
|
259
|
+
see_print 'Bla Bla '
|
260
|
+
see_print 'Bla Bla '
|
261
|
+
see_print 'Important '
|
262
|
+
seee.flash!
|
263
|
+
see_print 'Bla Bla '
|
264
|
+
see_print 'Bla Bla '
|
265
|
+
see_print 'Bla Bla '
|
266
|
+
see_print 'Bla Bla '
|
267
|
+
see_print 'Bla Bla '
|
268
|
+
see_print 'Bla Bla '
|
269
|
+
see_print 'Bla Bla '
|
270
|
+
see_print 'Bla Bla '
|
271
|
+
end
|
272
|
+
|
273
|
+
|
274
|
+
def demo_noinput
|
275
|
+
method = :see
|
276
|
+
seee.slow!
|
277
|
+
Object.send(method, 'Hallo')
|
278
|
+
Object.send(method)
|
279
|
+
Object.send(method, 'Welt')
|
280
|
+
Object.send(method)
|
281
|
+
Object.send(method, 'Double')
|
282
|
+
Object.send(method)
|
283
|
+
Object.send(method)
|
284
|
+
Object.send(method, 'Space')
|
285
|
+
Object.send(method)
|
286
|
+
Object.send(method)
|
287
|
+
Object.send(method, 'Blubb')
|
288
|
+
Object.send(method)
|
289
|
+
Object.send(method)
|
290
|
+
Object.send(method, 'Blubb!!')
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
def self.see_all_demos
|
297
|
+
Perception::DemoSee.new.demo_see_basic_types
|
298
|
+
Perception::DemoSee.new.demo_level
|
299
|
+
Perception::DemoSee.new.demo_see_slowdown1
|
300
|
+
Perception::DemoSee.new.demo_see_slowdown2
|
301
|
+
Perception::DemoSee.new.demo_bench
|
302
|
+
Perception::DemoSee.new.demo_see_temp_and_clear_last
|
303
|
+
Perception::DemoSee.new.demo_see_flash1
|
304
|
+
Perception::DemoSee.new.demo_alternate_see
|
305
|
+
|
306
|
+
Perception::DemoSee.new.demo_flash_puts
|
307
|
+
Perception::DemoSee.new.demo_flash_pp
|
308
|
+
Perception::DemoSee.new.demo_flash_print
|
309
|
+
Perception::DemoSee.new.demo_noinput
|
310
|
+
end
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
end # class
|
315
|
+
end # class
|
316
|
+
|
317
|
+
|
318
|
+
if $0 == __FILE__ then
|
319
|
+
|
320
|
+
Perception::DemoSee.see_all_demos
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
data/init.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'perception' ) if $0 == __FILE__
|
3
|
+
|
4
|
+
module Perception #:nodoc
|
5
|
+
|
6
|
+
unless defined?(TIME_FORMATS)
|
7
|
+
TIME_FORMATS = {
|
8
|
+
# 0 1 2 3 4
|
9
|
+
:iso => [ '%Y-%m-%d', '%Y-%m-%d %H:%M', '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %A %H:%M:%S' ],
|
10
|
+
:de => [ '%d.%b.%Y', '%d.%b.%Y %H:%M', '%d.%b.%Y %H:%M:%S', '%d. %B %Y %H:%M:%S', '%A, %d. %B %Y %H:%M:%S' ] # %e is not working
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# Shows a ruler
|
18
|
+
unless defined? RULER
|
19
|
+
r100= "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
|
20
|
+
r10= "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
|
21
|
+
RULER = r100 + r100 + "\n" + r10 + r10
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
SEE_PERCEPTION_TIME_PER_WORD = 200 unless defined? SEE_PERCEPTION_TIME_PER_WORD
|
26
|
+
|
27
|
+
# automatic indention
|
28
|
+
SEE_TAB_WIDTH = 2 unless defined? SEE_TAB_WIDTH
|
29
|
+
SEE_LEVEL_START = 1 unless defined? SEE_LEVEL_START
|
30
|
+
SEE_INDENT_START = false unless defined? SEE_INDENT_START
|
31
|
+
|
32
|
+
|
33
|
+
# nicht verwenden: 07..13, 27
|
34
|
+
PPP_KOMMA = 1.chr unless defined? PPP_KOMMA
|
35
|
+
PPP_SEARCH = 2.chr unless defined? PPP_SEARCH
|
36
|
+
PPP_GESCHW_KLAMMER_AUF = 3.chr unless defined? PPP_GESCHW_KLAMMER_AUF
|
37
|
+
PPP_GESCHW_KLAMMER_ZU = 4.chr unless defined? PPP_GESCHW_KLAMMER_ZU
|
38
|
+
PPP_ECKIGE_KLAMMER_AUF = 5.chr unless defined? PPP_ECKIGE_KLAMMER_AUF
|
39
|
+
PPP_ECKIGE_KLAMMER_ZU = 6.chr unless defined? PPP_ECKIGE_KLAMMER_ZU
|
40
|
+
PPP_SPITZE_KLAMMER_AUF = 14.chr unless defined? PPP_SPITZE_KLAMMER_AUF
|
41
|
+
PPP_SPITZE_KLAMMER_ZU = 15.chr unless defined? PPP_SPITZE_KLAMMER_ZU
|
42
|
+
PPP_PFEIL = 16.chr+16.chr unless defined? PPP_PFEIL
|
43
|
+
PPP_TUDDELCHEN1 = 17.chr unless defined? PPP_TUDDELCHEN1
|
44
|
+
PPP_TUDDELCHEN2 = 18.chr unless defined? PPP_TUDDELCHEN2
|
45
|
+
PPP_ANTI_NEWLINE = 31.chr unless defined? PPP_ANTI_NEWLINE
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# codieren: P => Q, in P fehlen derzeit die spitzen Klammern, weil sonst Hash nicht funktioniert
|
51
|
+
# decodieren: Q => R
|
52
|
+
PPP_TR_ARRAY_P = %q{'"{}[]<>} unless defined? PPP_TR_ARRAY_P
|
53
|
+
unless defined? PPP_TR_ARRAY_Q
|
54
|
+
PPP_TR_ARRAY_Q = PPP_TUDDELCHEN1 + PPP_TUDDELCHEN2 +
|
55
|
+
PPP_GESCHW_KLAMMER_AUF + PPP_GESCHW_KLAMMER_ZU +
|
56
|
+
PPP_ECKIGE_KLAMMER_AUF + PPP_ECKIGE_KLAMMER_ZU +
|
57
|
+
PPP_SPITZE_KLAMMER_AUF + PPP_SPITZE_KLAMMER_ZU
|
58
|
+
end
|
59
|
+
PPP_TR_ARRAY_R = %q{'"{}[]<>} unless defined? PPP_TR_ARRAY_R
|
60
|
+
|
61
|
+
PPP_TR_ALL = PPP_TR_ARRAY_Q + PPP_KOMMA + PPP_ANTI_NEWLINE unless defined? PPP_TR_ALL
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
end # module
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
# -----------------------------------------------------------------------------------------
|
71
|
+
# ausprobieren
|
72
|
+
#
|
73
|
+
if $0 == __FILE__ then
|
74
|
+
|
75
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'demo', 'demo_pp' )
|
76
|
+
Perception::DemoSee.see_all_demos
|
77
|
+
|
78
|
+
end # if
|
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'perception' ) if $0 == __FILE__
|
3
|
+
|
4
|
+
|
5
|
+
module Perception #:nodoc
|
6
|
+
module TimeI
|
7
|
+
|
8
|
+
|
9
|
+
def inspect_see(options={})
|
10
|
+
norm = options[:norm] || :iso
|
11
|
+
precision_max = 4
|
12
|
+
precision = options[:precision] || precision_max
|
13
|
+
precision = 0 if precision < 0
|
14
|
+
precision = precision_max if precision > precision_max
|
15
|
+
formatstring = TIME_FORMATS[norm][precision]
|
16
|
+
self.strftime(formatstring)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
def to_s
|
23
|
+
self.inspect_see(:precision => 5)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def pretty_print(q)
|
28
|
+
q.text(self.inspect_see(:precision => 5))
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
end # module TimeI
|
33
|
+
end # module Perception
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
class Time #:nodoc:
|
39
|
+
include Perception::TimeI
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# -----------------------------------------------------------------------------------------
|
51
|
+
# Tests
|
52
|
+
#
|
53
|
+
if $0 == __FILE__ then
|
54
|
+
|
55
|
+
# ms = 2635200
|
56
|
+
# puts (Time.now - ms*0).inspect_see(:norm => :de, :precision => 5)
|
57
|
+
# see Time.now
|
58
|
+
|
59
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'test', 'test_date_and_time' )
|
60
|
+
|
61
|
+
|
62
|
+
end # if
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'perception' ) if $0 == __FILE__
|
3
|
+
|
4
|
+
|
5
|
+
module Perception #:nodoc
|
6
|
+
|
7
|
+
class SeeSession
|
8
|
+
|
9
|
+
def logger( logdir=nil, filename='see.log' )
|
10
|
+
return @logger if @logger
|
11
|
+
require 'logger' unless defined?(Logger)
|
12
|
+
|
13
|
+
# Logfile festlegen
|
14
|
+
unless logdir
|
15
|
+
mycaller = CallerUtils.mycaller(:skip => ['perception', 'ruby\gems', 'ruby/gems', 'test/unit'])
|
16
|
+
logdir = CallerUtils.mycaller_maindir(mycaller) + '/log' if mycaller
|
17
|
+
end
|
18
|
+
if ( logdir.nil? || logdir == 'test/log' )
|
19
|
+
require 'tmpdir'
|
20
|
+
logdir = Dir::tmpdir + '/log'
|
21
|
+
end
|
22
|
+
logfile = File.join(logdir, filename)
|
23
|
+
# puts "\nmycaller=#{mycaller.inspect_pp}"
|
24
|
+
# puts "\nlogdir=#{logdir.inspect_pp}"
|
25
|
+
# puts "\nlogfile=#{logfile.inspect_pp}"
|
26
|
+
|
27
|
+
|
28
|
+
# Erzeugen, wenn nötig
|
29
|
+
begin
|
30
|
+
# Dir erzeugen
|
31
|
+
unless File.exist?(logdir)
|
32
|
+
Dir.mkdir(logdir)
|
33
|
+
puts "\n\nSeeSession#logger: Directory #{logdir} created\n\n"
|
34
|
+
end
|
35
|
+
# File erzeugen
|
36
|
+
unless File.exist?(logfile)
|
37
|
+
File.open(logfile,(File::WRONLY | File::APPEND | File::CREAT))
|
38
|
+
log_status("Logfile created by #{mycaller}")
|
39
|
+
end
|
40
|
+
#Logger erzeugen
|
41
|
+
@logger = Logger.new( logfile )
|
42
|
+
log_level = :debug
|
43
|
+
@logger.level = Logger.const_get(log_level.to_s.upcase)
|
44
|
+
@logger << "\n" # dem letzten Eintrag fehlt vielleicht das newline
|
45
|
+
#rescue
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
return @logger
|
50
|
+
end # def
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
def log_status(message='')
|
55
|
+
status = "\n\n\n# " + ('-'*120) + "\n"
|
56
|
+
status += "# " + Time.now.inspect_see + "\n"
|
57
|
+
status += "# " + message + "\n"
|
58
|
+
logger << status
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end # class
|
63
|
+
|
64
|
+
|
65
|
+
end # module
|
66
|
+
|
67
|
+
|
68
|
+
class Object
|
69
|
+
|
70
|
+
# Same as method see, but outputs in logfile only
|
71
|
+
def log(input=:kein_input, *rest)
|
72
|
+
out_bak = seee.out.dup
|
73
|
+
seee.out=[:log]
|
74
|
+
if rest.empty?
|
75
|
+
see input
|
76
|
+
else
|
77
|
+
seee.process_print( ( [input] + rest), :method => :multi )
|
78
|
+
end
|
79
|
+
seee.out=out_bak
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# raw output into logfile
|
85
|
+
def rawlog(input='')
|
86
|
+
seee.logger << (input)
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
# ------------------------------------------------------------------------------
|
100
|
+
# Ausprobieren
|
101
|
+
#
|
102
|
+
if $0 == __FILE__ then
|
103
|
+
|
104
|
+
|
105
|
+
see "Hallo"
|
106
|
+
see 'Jups.', :g, :h
|
107
|
+
#seee.log_status
|
108
|
+
log 'Jups.'
|
109
|
+
log 'Jups.', :g, :h
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
end # if
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|