Skip to content

Commit 327b1de

Browse files
author
Kevin Paulisse
committed
Convert Integer class -> Fixnum for diffy comparisons
1 parent 20c688f commit 327b1de

File tree

1 file changed

+11
-1
lines changed
  • lib/octocatalog-diff/catalog-diff/display

1 file changed

+11
-1
lines changed

lib/octocatalog-diff/catalog-diff/display/text.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,16 @@ def self.left_pad(spaces, text = '')
438438
[' ' * spaces, text].join('')
439439
end
440440

441+
# Utility Method!
442+
# Given a class, output that same class, except preserve some backward compatible
443+
# or equivalent class names.
444+
# @param class_name [String] Class name as input
445+
# @return [String] Class name as output
446+
def self.class_name_for_diffy(class_name)
447+
return 'Fixnum' if class_name == 'Integer'
448+
class_name
449+
end
450+
441451
# Utility Method!
442452
# Given an arbitrary object, convert it into a string for use by 'diffy'.
443453
# This basically exists so we can do something prettier than just calling .inspect or .to_s
@@ -448,7 +458,7 @@ def self.stringify_for_diffy(obj)
448458
return JSON.pretty_generate(obj) if [Hash, Array].include?(obj.class)
449459
return '""' if obj.is_a?(String) && obj == ''
450460
return obj if [String, Fixnum, Integer, Float].include?(obj.class)
451-
"#{obj.class}: #{obj.inspect}"
461+
"#{class_name_for_diffy(obj.class)}: #{obj.inspect}"
452462
end
453463

454464
# Utility Method!

0 commit comments

Comments
 (0)