@@ -171,31 +171,14 @@ def print_variable(name, value, kind)
171171 end
172172 end
173173 value_str = handle_binary_data ( value_str )
174- compact_value_str = build_compact_name ( value_str , value )
175- print ( "<variable name=\" %s\" compactValue= \" %s \" kind=\" %s\" value=\" %s\" type=\" %s\" hasChildren=\" %s\" objectId=\" %#+x\" >" ,
176- CGI . escapeHTML ( name ) , CGI . escapeHTML ( compact_value_str ) , kind , CGI . escapeHTML ( value_str ) , value . class ,
174+ escaped_value_str = CGI . escapeHTML ( value_str )
175+ print ( "<variable name=\" %s\" %s kind=\" %s\" value=\" %s\" type=\" %s\" hasChildren=\" %s\" objectId=\" %#+x\" >" ,
176+ CGI . escapeHTML ( name ) , build_compact_value_attr ( value ) , kind , escaped_value_str , value . class ,
177177 has_children , value . respond_to? ( :object_id ) ? value . object_id : value . id )
178- print ( "<value><![CDATA[%s]]></value>" , CGI . escapeHTML ( value_str ) )
178+ print ( "<value><![CDATA[%s]]></value>" , escaped_value_str )
179179 print ( '</variable>' )
180180 end
181181
182- def build_compact_name ( value_str , value )
183- compact = value_str
184- if value . is_a? ( Array )
185- slice = value [ 0 ..10 ]
186- compact = slice . inspect
187- if value . size != slice . size
188- compact = compact [ 0 ..compact . size -2 ] + ", ...]"
189- end
190- end
191- if value . is_a? ( Hash )
192- slice = value . sort_by { |k , _ | k . to_s } [ 0 ..5 ]
193- compact = slice . map { |kv | "#{ kv [ 0 ] } : #{ handle_binary_data ( kv [ 1 ] ) } " } . join ( ", " )
194- compact = "{" + compact + ( slice . size != value . size ? ", ..." : "" ) + "}"
195- end
196- compact
197- end
198-
199182 def print_breakpoints ( breakpoints )
200183 print_element 'breakpoints' do
201184 breakpoints . sort_by { |b | b . id } . each do |b |
@@ -298,7 +281,7 @@ def print_trace(context, file, line)
298281 end
299282
300283 def print_at_line ( context , file , line )
301- print "<suspended file=\' %s\' line=\' %s\' threadId=\' %d\' frames=\' %d\' />" ,
284+ print "<suspended file=\" %s\" line=\" %s\" threadId=\" %d\" frames=\" %d\" />" ,
302285 File . expand_path ( file ) , line , context . thnum , context . stack_size
303286 end
304287
@@ -344,6 +327,7 @@ def print(*params)
344327 end
345328
346329 def handle_binary_data ( value )
330+ # noinspection RubyResolve
347331 return '[Binary Data]' if ( value . respond_to? ( 'is_binary_data?' ) && value . is_binary_data? )
348332 return '[Invalid encoding]' if ( value . respond_to? ( 'valid_encoding?' ) && !value . valid_encoding? )
349333 value
@@ -357,6 +341,32 @@ def current_thread_attr(context)
357341 end
358342 end
359343
344+ def build_compact_name ( value )
345+ return compact_array_str ( value ) if value . is_a? ( Array )
346+ return compact_hash_str ( value ) if value . is_a? ( Hash )
347+ nil
348+ end
349+
350+ def compact_array_str ( value )
351+ slice = value [ 0 ..10 ]
352+ compact = slice . inspect
353+ if value . size != slice . size
354+ compact [ 0 ..compact . size -2 ] + ", ...]"
355+ end
356+ compact
357+ end
358+
359+ def compact_hash_str ( value )
360+ slice = value . sort_by { |k , _ | k . to_s } [ 0 ..5 ]
361+ compact = slice . map { |kv | "#{ kv [ 0 ] } : #{ handle_binary_data ( kv [ 1 ] ) } " } . join ( ", " )
362+ "{" + compact + ( slice . size != value . size ? ", ..." : "" ) + "}"
363+ end
364+
365+ def build_compact_value_attr ( value )
366+ compact_value_str = build_compact_name ( value )
367+ compact_value_str . nil? ? '' : "compactValue=\" #{ CGI . escapeHTML ( compact_value_str ) } \" "
368+ end
369+
360370 instance_methods . each do |m |
361371 if m . to_s . index ( 'print_' ) == 0
362372 protect m
0 commit comments