|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | require_relative '../display' |
4 | | -require_relative '../../util/colored.rb' |
| 4 | +require_relative '../../util/colored' |
| 5 | +require_relative '../../util/util' |
5 | 6 |
|
6 | 7 | require 'diffy' |
7 | 8 | require 'json' |
@@ -447,26 +448,16 @@ def self.class_name_for_diffy(class_name) |
447 | 448 | class_name |
448 | 449 | end |
449 | 450 |
|
450 | | - # Utility Method! |
451 | | - # `is_a?(class)` only allows one method, but this uses an array |
452 | | - # @param object [?] Object to consider |
453 | | - # @param classes [Array] Classes to determine if object is a member of |
454 | | - # @return [Boolean] True if object is_a any of the classes, false otherwise |
455 | | - def self.object_is_any_of?(object, classes) |
456 | | - classes.each { |clazz| return true if object.is_a? clazz } |
457 | | - false |
458 | | - end |
459 | | - |
460 | 451 | # Utility Method! |
461 | 452 | # Given an arbitrary object, convert it into a string for use by 'diffy'. |
462 | 453 | # This basically exists so we can do something prettier than just calling .inspect or .to_s |
463 | 454 | # on object types we anticipate seeing, while not failing entirely on other object types. |
464 | 455 | # @param obj [?] Object to be stringified |
465 | 456 | # @return [String] String representation of object for diffy |
466 | 457 | def self.stringify_for_diffy(obj) |
467 | | - return JSON.pretty_generate(obj) if object_is_any_of?(obj, [Hash, Array]) |
| 458 | + return JSON.pretty_generate(obj) if OctocatalogDiff::Util::Util.object_is_any_of?(obj, [Hash, Array]) |
468 | 459 | return '""' if obj.is_a?(String) && obj == '' |
469 | | - return obj if object_is_any_of?(obj, [String, Fixnum, Integer, Float]) |
| 460 | + return obj if OctocatalogDiff::Util::Util.object_is_any_of?(obj, [String, Fixnum, Integer, Float]) |
470 | 461 | "#{class_name_for_diffy(obj.class)}: #{obj.inspect}" |
471 | 462 | end |
472 | 463 |
|
|
0 commit comments