perception 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +2 -0
- data/Manifest.txt +5 -3
- data/README.rdoc +27 -11
- data/demo/Example_Output_1.rb +183 -0
- data/demo/Example_Output_2.rb +63 -0
- data/demo/{demo_pp.rb → demo1.rb} +34 -12
- data/demo/demo2.rb +37 -0
- data/demo/demo3.rb +201 -0
- data/lib/perception/date_and_time.rb +2 -0
- data/lib/perception/logging.rb +10 -2
- data/lib/perception/numeric.rb +58 -20
- data/lib/perception/perception_main.rb +87 -38
- data/lib/perception/perception_private.rb +15 -4
- data/lib/perception/ppp.rb +4 -3
- data/lib/perception/string_spread.rb +6 -2
- data/test/test_numeric.rb +9 -9
- data/version.rb +1 -1
- metadata +7 -5
- data/demo/demo_system_info.rb +0 -28
- data/demo/demo_zz.rb +0 -333
data/lib/perception/logging.rb
CHANGED
@@ -28,6 +28,7 @@ module Perception
|
|
28
28
|
# @logdev = #<Logger::LogDevice:0x2a57c60 @dev=#<File:C:/Ruby-Projekte/perception/log/see.log>, @filename='C:/Ruby-Projekte/perception/log/see.log', @mutex=#<<>>, @shift_age=0, @shift_size=1048576>,
|
29
29
|
# @progname = nil>
|
30
30
|
#
|
31
|
+
# More: {Object#log log}, {Object#rawlog rawlog}
|
31
32
|
# @return [Logger]
|
32
33
|
#
|
33
34
|
def logger( logdir=nil, filename='see.log' )
|
@@ -107,7 +108,12 @@ end # module
|
|
107
108
|
|
108
109
|
class Object
|
109
110
|
|
110
|
-
# Same as method see, but outputs in logfile only
|
111
|
+
# Same as method see, but outputs in logfile only.
|
112
|
+
#
|
113
|
+
# If you want to use both logfile and console , use
|
114
|
+
# seee.out << :log
|
115
|
+
#
|
116
|
+
# More: {Object#rawlog rawlog}, {Perception::SeeSession#logger seee.logger}
|
111
117
|
def log(input=:kein_input, *rest)
|
112
118
|
out_bak = seee.out.dup
|
113
119
|
seee.out=[:log]
|
@@ -121,7 +127,9 @@ class Object
|
|
121
127
|
end
|
122
128
|
|
123
129
|
|
124
|
-
# raw output into logfile
|
130
|
+
# raw output into logfile without formating.
|
131
|
+
#
|
132
|
+
# More: {Object#log log}, {Perception::SeeSession#logger seee.logger}
|
125
133
|
def rawlog(input='')
|
126
134
|
seee.logger << (input)
|
127
135
|
nil
|
data/lib/perception/numeric.rb
CHANGED
@@ -10,13 +10,15 @@ end
|
|
10
10
|
|
11
11
|
module Perception
|
12
12
|
|
13
|
+
|
13
14
|
module NumericI
|
14
15
|
|
15
16
|
# ------------------------------------------------------------------------------
|
16
|
-
# @group
|
17
|
+
# @group Intelligent round: slash needless digits
|
17
18
|
#
|
18
19
|
|
19
|
-
#
|
20
|
+
# Intelligent round: slash needless digits.
|
21
|
+
# Specify only the significant digits so that the magnitude can be easily realised.
|
20
22
|
# Needless are digits that are
|
21
23
|
# * beyond the measurement precision or
|
22
24
|
# * not perceived by humans (instead they disturb the reception)
|
@@ -43,6 +45,7 @@ module Perception
|
|
43
45
|
#
|
44
46
|
# @return [Numeric]
|
45
47
|
# @param [Integer] precision How many digits are significant?
|
48
|
+
#
|
46
49
|
def significant( precision = 3)
|
47
50
|
|
48
51
|
# sprintf mit gemischter Schreibweise
|
@@ -81,24 +84,56 @@ module Perception
|
|
81
84
|
# @group Easily human readable numbers
|
82
85
|
#
|
83
86
|
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
87
|
+
# Formats a number for easily human readability.
|
88
|
+
# Example: (using +.inspect_see+ without options)
|
89
|
+
# input (barrier) output (barrier) note
|
90
|
+
# -------------------------------------------------------------------------------------------------------
|
91
|
+
# -7213541 ########-7 210 000 ######## Intelligent fallback strategy if space is not sufficient
|
92
|
+
# 7213541 ########7 210 000 ########
|
93
|
+
# -553337 ######## -553 000 ########
|
94
|
+
# 553337 ######## 553 000 ######## Intelligent round: slash needless digits
|
95
|
+
# -12567.89 ######## -12 600 ########
|
96
|
+
# 12567.89 ######## 12 600 ######## Thousands separator only if necessary
|
97
|
+
# -1256.789 ######## -1260 ########
|
98
|
+
# 1256.789 ######## 1260 ########
|
99
|
+
# -123.56789 ######## -124 ########
|
100
|
+
# 123.56789 ######## 124 ########
|
101
|
+
# 100.01 ######## 100 ########
|
102
|
+
# 12.0 ######## 12 ########
|
103
|
+
# 12 ######## 12 ########
|
104
|
+
# -12.56789 ######## -12.6 ########
|
105
|
+
# 12.56789 ######## 12.6 ########
|
106
|
+
# -1.256789 ######## -1.26 ########
|
107
|
+
# 1.256789 ######## 1.26 ########
|
108
|
+
# -0.1256789 ######## -0.126 ########
|
109
|
+
# 0.1256789 ######## 0.126 ########
|
110
|
+
# -0.01256789 ######## -0.0126########
|
111
|
+
# 0.01256789 ######## 0.0126########
|
112
|
+
# -0.001256789 ######## -0.00126########
|
113
|
+
# 0.001256789 ######## 0.00126########
|
114
|
+
# -0.0001256789 ######## -0.000126########
|
115
|
+
# 0.0001256789 ######## 0.000126########
|
116
|
+
#
|
117
|
+
# Features:
|
118
|
+
# * aligned right with the separator as reference point
|
119
|
+
# * you can preced a currency symbol or append units, without destroying the alignment
|
120
|
+
# * intelligent fallback strategy if the predetermined space is not sufficient
|
121
|
+
# * thousands separator if necessary, and only if necessary
|
122
|
+
# * only the significant digits are specified so that the magnitude can be easily realised (see {#significant})
|
90
123
|
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
124
|
+
# If you don't need alignment and thousands separator, use {Perception::NumericI#significant significant} instead.
|
125
|
+
# See {http://de.wikipedia.org/wiki/Wikipedia:Schreibweise_von_Zahlen Schreibweise von Zahlen}.
|
126
|
+
#
|
127
|
+
# @return [String]
|
128
|
+
# @param [Hash] options
|
129
|
+
# @option options [Integer] :precision how many digits are significant? Default: 3
|
130
|
+
# @option options [Integer] :space_l space before the separator as reference point
|
131
|
+
# @option options [Integer] :space_r space behind the separator. Default depends on class (Integer or Float).
|
132
|
+
# @option options [Char] :separator separator
|
133
|
+
# @option options [Char] :delimiter thousands separator
|
134
|
+
# @option options [String] :pre preceding string (e.g. a currency symbol)
|
135
|
+
# @option options [String] :past appended string (e.g. a unit)
|
99
136
|
#
|
100
|
-
# Für eine schlichte linksbündige Ausgabe reicht die Methode #significant!
|
101
|
-
# vgl. http://de.wikipedia.org/wiki/Wikipedia:Schreibweise_von_Zahlen
|
102
137
|
#
|
103
138
|
def inspect_see(options={})
|
104
139
|
precision = options[:precision] || 3
|
@@ -106,7 +141,7 @@ module Perception
|
|
106
141
|
past = options[:past] || ''
|
107
142
|
space_l = options[:space_l] || 9 + pre.size
|
108
143
|
space_r = options[:space_r] || (self.kind_of?(Integer) ? (0+past.size) : (5+past.size)) # Integer oder Float?
|
109
|
-
separator = options[:separator] || '
|
144
|
+
separator = options[:separator] || '.'
|
110
145
|
delimiter = options[:delimiter] || ' '
|
111
146
|
|
112
147
|
|
@@ -173,7 +208,7 @@ if $0 == __FILE__ && Drumherum::loaded? then
|
|
173
208
|
|
174
209
|
# Hier einstellen, was laufen soll
|
175
210
|
$run = :try1
|
176
|
-
|
211
|
+
$run = :try2
|
177
212
|
#$run = :tests
|
178
213
|
#$run = :demo
|
179
214
|
|
@@ -197,11 +232,14 @@ if $0 == __FILE__ && Drumherum::loaded? then
|
|
197
232
|
|
198
233
|
when :try2 #-------------------------------------------------------------------------------
|
199
234
|
|
235
|
+
seee.out << :log
|
200
236
|
test = [7213541, 553337, 12567.89, 1256.789, 123.56789, 100.01, 100.0, 99.9, 12.0, 12, 12.56789, 1.256789, 1.5, 0, 0.1256789,0.01256789,0.001256789,0.0001256789, ]
|
201
237
|
test.each do |t|
|
202
238
|
t = t*-1
|
239
|
+
see_print "#"
|
203
240
|
see_print t.to_s.rjust(15) + ' ########' + t.to_f.inspect_see + "########\n"
|
204
241
|
t = t*-1
|
242
|
+
see_print "#"
|
205
243
|
see_print t.to_s.rjust(15) + ' ########' + t.to_f.inspect_see + "########\n"
|
206
244
|
end
|
207
245
|
|
@@ -17,22 +17,27 @@ require 'kyanite/enumerable/structure' # Methode contentclass
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
# Perception: Human perceptible printouts
|
21
|
-
# ========================================
|
20
|
+
# = Perception: Human perceptible printouts
|
22
21
|
#
|
23
22
|
# Welcome to Perception. It's a intuitive toolkit for simple everyday debugging.
|
24
|
-
# Perception offers a powerfull replacement for print, puts and pp
|
23
|
+
# Perception offers a powerfull replacement for print, puts and pp
|
24
|
+
# and is an alternative to {https://github.com/michaeldv/awesome_print Awesome Print}.
|
25
|
+
#
|
25
26
|
# You get auto-intended and structured output on your console without any configuration.
|
27
|
+
#
|
26
28
|
# Perception also offers temporary printouts (overwritten by the next print),
|
27
29
|
# printing two informations in one line without destroying the structure and
|
28
30
|
# optionally slows down printing to readable speed, depending on the complexity of the output.
|
29
31
|
#
|
30
32
|
module Perception
|
31
33
|
|
32
|
-
#
|
34
|
+
# An instance of SeeSession corresponds to a session with the console.
|
33
35
|
class SeeSession
|
36
|
+
|
37
|
+
# @group Automatic Indenting
|
34
38
|
|
35
39
|
# Turns automatic indention ON.
|
40
|
+
# @return void
|
36
41
|
def indent!
|
37
42
|
@indent = true
|
38
43
|
@level = SEE_LEVEL_START
|
@@ -42,7 +47,8 @@ module Perception
|
|
42
47
|
end
|
43
48
|
|
44
49
|
|
45
|
-
# Turns automatic indention OFF.
|
50
|
+
# Turns automatic indention OFF.
|
51
|
+
# @return void
|
46
52
|
def left!
|
47
53
|
@indent = false
|
48
54
|
@level = SEE_LEVEL_START
|
@@ -50,10 +56,46 @@ module Perception
|
|
50
56
|
@call_stack_now = 0
|
51
57
|
nil
|
52
58
|
end
|
59
|
+
|
60
|
+
# @group Slowing down
|
61
|
+
|
62
|
+
# Slows down output to readable speed.
|
63
|
+
# The speed depends on the length and the complexity of the printing.
|
64
|
+
# You can adjust the speed with the parameter:
|
65
|
+
# * slow! 1 --> same as slow!
|
66
|
+
# * slow! 2 --> slow, but double speed
|
67
|
+
# * slow! 0.5 --> even slower
|
68
|
+
# * slow! nil --> full speed (same as fast!)
|
69
|
+
# @return void
|
70
|
+
# @param [Float] speed
|
71
|
+
def slow!(speed=1)
|
72
|
+
@speed = speed
|
73
|
+
nil
|
74
|
+
end
|
53
75
|
|
54
76
|
|
77
|
+
# Adjusts printing speed to full speed.
|
78
|
+
# This is used after slow!
|
79
|
+
# @return void
|
80
|
+
def fast!
|
81
|
+
@speed = nil
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
|
85
|
+
# @group Simple Benchmarking
|
86
|
+
|
87
|
+
# @return [Float] the time in seconds since the last printout with see.
|
88
|
+
def bench
|
89
|
+
return 0 unless @time_last
|
90
|
+
return (Time.now - @time_last)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
# @group Progress Indicator
|
95
|
+
|
55
96
|
# Undos the last print.
|
56
97
|
# Note: Indention will get lost.
|
98
|
+
# @return void
|
57
99
|
def clear!
|
58
100
|
return if @cursor_now <= SEE_TAB_WIDTH * @level
|
59
101
|
return if @string_last.empty?
|
@@ -71,41 +113,16 @@ module Perception
|
|
71
113
|
|
72
114
|
# Marks the last print as temporary.
|
73
115
|
# The following print will overwrite it.
|
74
|
-
# Note: Indention will get lost.
|
116
|
+
# Note: Indention will get lost.
|
117
|
+
# @return void
|
75
118
|
def temp!
|
76
119
|
@delayed_clear = true
|
77
120
|
nil
|
78
121
|
end
|
79
122
|
|
80
123
|
|
81
|
-
#
|
82
|
-
# The speed depends on the length and the complexity of the printing.
|
83
|
-
# You can adjust the speed with the parameter:
|
84
|
-
# * slow! 1 --> same as slow!
|
85
|
-
# * slow! 2 --> slow, but double speed
|
86
|
-
# * slow! 0.5 --> even slower
|
87
|
-
# * slow! nil --> full speed (same as fast!)
|
88
|
-
def slow!(speed=1)
|
89
|
-
@speed = speed
|
90
|
-
nil
|
91
|
-
end
|
92
|
-
|
93
|
-
|
94
|
-
# Adjusts printing speed to full speed.
|
95
|
-
# This is used after slow!
|
96
|
-
def fast!
|
97
|
-
@speed = nil
|
98
|
-
nil
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
# Returns the time in seconds since the last #see-printout.
|
103
|
-
def bench
|
104
|
-
return 0 unless @time_last
|
105
|
-
return (Time.now - @time_last)
|
106
|
-
end
|
124
|
+
# @group Two layers of information in one line
|
107
125
|
|
108
|
-
|
109
126
|
# Shows two informations in one line. See the demo.
|
110
127
|
#
|
111
128
|
# Via seee.flash! können zwei Informationen abwechselnd in der gleichen Zeile angezeigt werden.
|
@@ -114,6 +131,7 @@ module Perception
|
|
114
131
|
# Ohne Angabe eines Zweittextes wird der Ersttext einfach zum Blinken gebracht. Nachträglich, also wenn er schon ausgegeben ist.
|
115
132
|
# Das ist sehr nützlich, wenn man bestimme Werte verfolgen will.
|
116
133
|
#
|
134
|
+
# @return void
|
117
135
|
def flash!(alternativtext=' ', how_many=6)
|
118
136
|
string_bak = @string_last.dup
|
119
137
|
method_bak = @method_last
|
@@ -149,6 +167,8 @@ class Object
|
|
149
167
|
# Wrapper for SeeSession
|
150
168
|
#
|
151
169
|
|
170
|
+
# @group Main methods
|
171
|
+
|
152
172
|
# Returns the SeeSession-Object. Offers the following methods:
|
153
173
|
# * seee.indent!
|
154
174
|
# * seee.left!
|
@@ -159,12 +179,34 @@ class Object
|
|
159
179
|
# * seee.flash!
|
160
180
|
# * seee.bench
|
161
181
|
#
|
182
|
+
# @return [Perception::SeeSession]
|
162
183
|
def seee
|
163
184
|
return Perception::SeeSession.instance
|
164
185
|
end
|
165
186
|
|
187
|
+
|
188
|
+
|
166
189
|
|
167
|
-
#
|
190
|
+
# You get auto-intended and structured output on your console without any configuration.
|
191
|
+
# Usage:
|
192
|
+
# require 'perception'
|
193
|
+
# and use +see+ instead of +pp+, +puts+, +print+ and +.inspect+.
|
194
|
+
#
|
195
|
+
# This is the printout for a nested hash as example:
|
196
|
+
# {:hash => true,
|
197
|
+
# :init => true,
|
198
|
+
# :nil => nil,
|
199
|
+
# :symbol => :symbol,
|
200
|
+
# :text => 'text',
|
201
|
+
# :array => [1, 2, 3],
|
202
|
+
# :integer => 1,
|
203
|
+
# :string => 'hallo',
|
204
|
+
# :nochn_hash => {:key=>:value, :bla=>:blubb, :array=>[:a, :b, :c], :another_key=>'another value'}}
|
205
|
+
#
|
206
|
+
# See more examples at {file:demo/Example_Output_1.rb} and {file:demo/Example_Output_2.rb}
|
207
|
+
# or watch the interactive demo at {file:demo/demo3.rb}.
|
208
|
+
#
|
209
|
+
# @return [String]
|
168
210
|
def see(input=:kein_input, *rest)
|
169
211
|
|
170
212
|
if input == :kein_input
|
@@ -181,6 +223,7 @@ class Object
|
|
181
223
|
end # def
|
182
224
|
|
183
225
|
|
226
|
+
# @private
|
184
227
|
def see_each(input)
|
185
228
|
if self.contentclass == Array
|
186
229
|
see_puts '['
|
@@ -190,11 +233,12 @@ class Object
|
|
190
233
|
input.each {|elt| see elt}
|
191
234
|
end
|
192
235
|
|
193
|
-
|
236
|
+
# @group Several variants of see
|
194
237
|
|
195
238
|
# Like see, but temporary print.
|
196
239
|
# The following print will overwrite it.
|
197
|
-
# Note: Indention will get lost.
|
240
|
+
# Note: Indention will get lost.
|
241
|
+
# @return [String]
|
198
242
|
def see_temp(input=:kein_input)
|
199
243
|
if input == :kein_input
|
200
244
|
seee.delayed_newlines += 1
|
@@ -206,6 +250,7 @@ class Object
|
|
206
250
|
|
207
251
|
|
208
252
|
# Shows two informations in one line. See the demo.
|
253
|
+
# @return [String]
|
209
254
|
def see_flash(input=:kein_input, alternativtext=' ', times=6)
|
210
255
|
if input == :kein_input
|
211
256
|
seee.delayed_newlines += 1
|
@@ -218,7 +263,8 @@ class Object
|
|
218
263
|
|
219
264
|
# Like see, but forces behavior like the originally puts method.
|
220
265
|
# So you get a newline after every print.
|
221
|
-
# Note: All newlines are delayed. This offers you to undo the print.
|
266
|
+
# Note: All newlines are delayed. This offers you to undo the print.
|
267
|
+
# @return [String]
|
222
268
|
def see_puts(input=:kein_input)
|
223
269
|
if input == :kein_input
|
224
270
|
seee.delayed_newlines += 1
|
@@ -231,12 +277,14 @@ class Object
|
|
231
277
|
# Like see, but forces behavior like the originally print method.
|
232
278
|
# So you have fully control over your newlines.
|
233
279
|
# Note: If you use "\n", #see will indent it. See SEE_LEVEL_START.
|
280
|
+
# @return [String]
|
234
281
|
def see_print(input=$_)
|
235
282
|
return seee.process_print( input, :method => :print )
|
236
283
|
end
|
237
284
|
|
238
285
|
|
239
|
-
# Like see, but
|
286
|
+
# Like see, but behavior similar to the originally pp method.
|
287
|
+
# @return [String]
|
240
288
|
def see_pp(input=:kein_input)
|
241
289
|
if input == :kein_input
|
242
290
|
seee.delayed_newlines += 1
|
@@ -247,6 +295,7 @@ class Object
|
|
247
295
|
|
248
296
|
|
249
297
|
|
298
|
+
# @endgroup
|
250
299
|
|
251
300
|
|
252
301
|
|
@@ -12,9 +12,12 @@ end
|
|
12
12
|
module Perception
|
13
13
|
|
14
14
|
|
15
|
-
|
15
|
+
|
16
|
+
|
16
17
|
class SeeSession
|
17
18
|
@@instance = nil
|
19
|
+
|
20
|
+
# @private
|
18
21
|
attr_accessor :time_last, :delayed_newlines, :level, :indent, :out
|
19
22
|
|
20
23
|
# ------------------------------------------------------------------------------
|
@@ -22,6 +25,7 @@ module Perception
|
|
22
25
|
#
|
23
26
|
|
24
27
|
# Liefert die eine notwendige Instanz
|
28
|
+
# @private
|
25
29
|
def self.instance
|
26
30
|
return @@instance if @@instance
|
27
31
|
@@instance = SeeSession.new
|
@@ -29,11 +33,12 @@ module Perception
|
|
29
33
|
end
|
30
34
|
|
31
35
|
|
36
|
+
# @private
|
32
37
|
def initialize
|
33
38
|
init
|
34
39
|
end
|
35
40
|
|
36
|
-
|
41
|
+
# @private
|
37
42
|
def init
|
38
43
|
# früher
|
39
44
|
@string_last = '' # enthält den letzten ausgegebenen String (damit man ihn löschen und wiederherstellen kann)
|
@@ -67,6 +72,7 @@ module Perception
|
|
67
72
|
# Ausgeben
|
68
73
|
#
|
69
74
|
|
75
|
+
# @private
|
70
76
|
def wait!(string_akt)
|
71
77
|
return unless @time_last
|
72
78
|
verstrichene_zeit = Time.now - @time_last
|
@@ -81,6 +87,7 @@ module Perception
|
|
81
87
|
end # wait
|
82
88
|
|
83
89
|
|
90
|
+
# @private
|
84
91
|
def adjust_level
|
85
92
|
@call_stack_now = caller.size
|
86
93
|
call_stack_diff = @call_stack_now - @call_stack_last
|
@@ -97,6 +104,7 @@ module Perception
|
|
97
104
|
end
|
98
105
|
|
99
106
|
|
107
|
+
# @private
|
100
108
|
def clear_indent!
|
101
109
|
@call_stack_last = 0 # wie direkt nach der Initialisierung
|
102
110
|
@call_stack_now = 0
|
@@ -109,6 +117,7 @@ module Perception
|
|
109
117
|
|
110
118
|
|
111
119
|
# Gibt das see aus
|
120
|
+
# @private
|
112
121
|
def process_print( input, options={} )
|
113
122
|
|
114
123
|
# vorbereiten
|
@@ -157,6 +166,7 @@ module Perception
|
|
157
166
|
|
158
167
|
|
159
168
|
# Führt die aufgeschobenen Newlines aus. Ohne Berücksichtigung der Zeit.
|
169
|
+
# @private
|
160
170
|
def process_newline
|
161
171
|
result = "\n" * @delayed_newlines
|
162
172
|
self.clear! if @delayed_clear
|
@@ -166,6 +176,7 @@ module Perception
|
|
166
176
|
end
|
167
177
|
|
168
178
|
|
179
|
+
# @private
|
169
180
|
def printout(string, backward=nil)
|
170
181
|
if @out.include?(:console)
|
171
182
|
spacer = (' '*SEE_TAB_WIDTH * @level)
|
@@ -205,8 +216,8 @@ end # module
|
|
205
216
|
|
206
217
|
class Object
|
207
218
|
|
208
|
-
#
|
209
|
-
#
|
219
|
+
# Returns the result of +inspect+ or the result of +to_s+, depending on the class.
|
220
|
+
# No duck typing.
|
210
221
|
def inspect_or_to_s
|
211
222
|
return 'empty' if self == ''
|
212
223
|
return self.to_s if self.class == String
|
data/lib/perception/ppp.rb
CHANGED
@@ -8,6 +8,7 @@ end
|
|
8
8
|
|
9
9
|
|
10
10
|
# patches pretty print
|
11
|
+
# @private
|
11
12
|
class PPP < PP
|
12
13
|
|
13
14
|
|
@@ -347,7 +348,7 @@ class PPP < PP
|
|
347
348
|
|
348
349
|
end # class
|
349
350
|
|
350
|
-
|
351
|
+
# @private
|
351
352
|
class String
|
352
353
|
|
353
354
|
# @return [String]
|
@@ -357,7 +358,7 @@ class String
|
|
357
358
|
|
358
359
|
end
|
359
360
|
|
360
|
-
|
361
|
+
# @private
|
361
362
|
class Set
|
362
363
|
|
363
364
|
# @return [String]
|
@@ -376,7 +377,7 @@ class Set
|
|
376
377
|
|
377
378
|
end
|
378
379
|
|
379
|
-
|
380
|
+
# @private
|
380
381
|
class Dictionary
|
381
382
|
|
382
383
|
# @return [String]
|
@@ -9,9 +9,11 @@ require 'kyanite/array_of_enumerables'
|
|
9
9
|
|
10
10
|
|
11
11
|
module Perception
|
12
|
+
|
13
|
+
# @private
|
12
14
|
module StringSpreadI
|
13
15
|
|
14
|
-
|
16
|
+
# @private
|
15
17
|
def analyze_columns(options={})
|
16
18
|
|
17
19
|
# vorbereiten
|
@@ -64,6 +66,7 @@ module Perception
|
|
64
66
|
# Mit position_add= 0 werden die Spaces vor dem gefundenen Zeichen eingefügt.
|
65
67
|
# Standard ist position_add= search.size, damit werden die Spaces hinter den gefundenen Zeichen eingefügt.
|
66
68
|
# Mit PPP_ANTI_NEWLINE werden Zeilen markiert, bei denen anschließend noch das \n entfernt werden kann.
|
69
|
+
# @private
|
67
70
|
def spread_line(tabstops=[], search=/,/, position_add=nil, start=0)
|
68
71
|
#puts "spread_line, self=#{self.inspect_pp} tabstops=#{tabstops.join('-')}"
|
69
72
|
position_add = search.inspect.size-2 unless position_add
|
@@ -100,7 +103,7 @@ module Perception
|
|
100
103
|
end # def
|
101
104
|
|
102
105
|
|
103
|
-
|
106
|
+
# @private
|
104
107
|
def spread(options={})
|
105
108
|
# vorbereiten
|
106
109
|
level_start = options[:level_start] || 1
|
@@ -129,6 +132,7 @@ module Perception
|
|
129
132
|
end # module
|
130
133
|
end # module
|
131
134
|
|
135
|
+
# @private
|
132
136
|
class String
|
133
137
|
include Perception::StringSpreadI
|
134
138
|
end
|
data/test/test_numeric.rb
CHANGED
@@ -33,17 +33,17 @@ class TestPerceptionNumeric < UnitTest
|
|
33
33
|
' 124 ',
|
34
34
|
' 100 ',
|
35
35
|
' 100 ',
|
36
|
-
' 99
|
36
|
+
' 99.9 ',
|
37
37
|
' 12 ',
|
38
38
|
' 12 ',
|
39
|
-
' 12
|
40
|
-
' 1
|
41
|
-
' 1
|
39
|
+
' 12.6 ',
|
40
|
+
' 1.26 ',
|
41
|
+
' 1.5 ',
|
42
42
|
' 0 ',
|
43
|
-
' 0
|
44
|
-
' 0
|
45
|
-
' 0
|
46
|
-
' 0
|
43
|
+
' 0.126 ',
|
44
|
+
' 0.0126',
|
45
|
+
' 0.00126',
|
46
|
+
' 0.000126']
|
47
47
|
result= test.collect { |t| t.to_f.inspect_see }
|
48
48
|
assert_equal expect, result
|
49
49
|
|
@@ -79,7 +79,7 @@ class TestPerceptionNumeric < UnitTest
|
|
79
79
|
assert_equal "\n" + result, see_print(test); setup
|
80
80
|
|
81
81
|
test = -0.000314162353463463136537846595
|
82
|
-
result = ' -0
|
82
|
+
result = ' -0.000314'
|
83
83
|
assert_equal "\n" + result, see(test); setup
|
84
84
|
assert_equal "\n" + result, see_pp(test); setup
|
85
85
|
assert_equal "\n" + result, see_puts(test); setup
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perception
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
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-10-
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: drumherum
|
@@ -109,9 +109,11 @@ files:
|
|
109
109
|
- Rakefile.rb
|
110
110
|
- README.rdoc
|
111
111
|
- version.rb
|
112
|
-
- demo/
|
113
|
-
- demo/
|
114
|
-
- demo/
|
112
|
+
- demo/demo1.rb
|
113
|
+
- demo/demo2.rb
|
114
|
+
- demo/demo3.rb
|
115
|
+
- demo/Example_Output_1.rb
|
116
|
+
- demo/Example_Output_2.rb
|
115
117
|
- init.rb
|
116
118
|
- lib/perception.rb
|
117
119
|
- lib/perception/const.rb
|
data/demo/demo_system_info.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# ruby encoding: utf-8
|
2
|
-
# ü
|
3
|
-
if $0 == __FILE__
|
4
|
-
require 'drumherum'
|
5
|
-
smart_init
|
6
|
-
require 'perception'
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'rbconfig'
|
10
|
-
seee.out << :log
|
11
|
-
see Config::CONFIG
|
12
|
-
see
|
13
|
-
see
|
14
|
-
see "------------------------------------------------------"
|
15
|
-
|
16
|
-
# require 'awesome_print'
|
17
|
-
# ap Config::CONFIG
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|