diff --git a/openc3/lib/openc3/core_ext.rb b/openc3/lib/openc3/core_ext.rb index b0bb022f23..e3f6eda262 100644 --- a/openc3/lib/openc3/core_ext.rb +++ b/openc3/lib/openc3/core_ext.rb @@ -27,7 +27,6 @@ require 'openc3/core_ext/exception' require 'openc3/core_ext/faraday' require 'openc3/core_ext/file' -require 'openc3/core_ext/hash' require 'openc3/core_ext/io' require 'openc3/core_ext/kernel' require 'openc3/core_ext/math' diff --git a/openc3/lib/openc3/core_ext/array.rb b/openc3/lib/openc3/core_ext/array.rb index f4ace8eaba..c82032e015 100644 --- a/openc3/lib/openc3/core_ext/array.rb +++ b/openc3/lib/openc3/core_ext/array.rb @@ -24,22 +24,6 @@ # OpenC3 specific additions to the Ruby Array class class Array - # Redefine inspect to only print for small numbers of - # items. Prevents exceptions taking forever to be raise with - # large objects. See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105145 - alias old_inspect inspect - - # @param max_elements [Integer] The maximum number of elements in the array to - # print out before simply displaying the array class and object id - # @return [String] String representation of the array - def inspect(max_elements = 10) - if self.length <= max_elements - old_inspect() - else - '#<' + self.class.to_s + ':' + self.object_id.to_s + '>' - end - end - # @return [Array] Cloned array after all elements called to_f def clone_to_f new_array = self.class.new(0) diff --git a/openc3/lib/openc3/core_ext/hash.rb b/openc3/lib/openc3/core_ext/hash.rb deleted file mode 100644 index 51bf59baa8..0000000000 --- a/openc3/lib/openc3/core_ext/hash.rb +++ /dev/null @@ -1,40 +0,0 @@ -# encoding: ascii-8bit - -# Copyright 2022 Ball Aerospace & Technologies Corp. -# All Rights Reserved. -# -# This program is free software; you can modify and/or redistribute it -# under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation; version 3 with -# attribution addendums as found in the LICENSE.txt -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# Modified by OpenC3, Inc. -# All changes Copyright 2022, OpenC3, Inc. -# All Rights Reserved -# -# This file may also be used under the terms of a commercial license -# if purchased from OpenC3, Inc. - -# OpenC3 specific additions to the Ruby Hash class -class Hash - # Redefine inspect to only print for small numbers of - # items. Prevents exceptions taking forever to be raised with - # large objects. See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105145 - alias old_inspect inspect - - # @param max_elements [Integer] The maximum number of elements in the Hash to - # print out before simply displaying the Hash class and object id - # @return [String] String representation of the hash - def inspect(max_elements = 10) - if self.length <= max_elements - old_inspect() - else - '#<' + self.class.to_s + ':' + self.object_id.to_s + '>' - end - end -end diff --git a/openc3/spec/core_ext/array_spec.rb b/openc3/spec/core_ext/array_spec.rb index 2aa2d074b9..f44873ef25 100644 --- a/openc3/spec/core_ext/array_spec.rb +++ b/openc3/spec/core_ext/array_spec.rb @@ -14,23 +14,16 @@ # GNU Affero General Public License for more details. # Modified by OpenC3, Inc. -# All changes Copyright 2022, OpenC3, Inc. +# All changes Copyright 2024, OpenC3, Inc. # All Rights Reserved # -# This file may also be used under the terms of a commercial license +# This file may also be used under the terms of a commercial license # if purchased from OpenC3, Inc. require 'spec_helper' require 'openc3/core_ext/array' describe Array do - describe "inspect" do - it "limits the number of items to 10" do - expect(Array.new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).inspect).to eql "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" - expect(Array.new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]).inspect).to match(/#/) - end - end - describe "clone_to_f" do it "clones the array and convert all the values to floats" do expect(Array.new([1, 2, 3, 4, 5]).clone_to_f).to eql [1.0, 2.0, 3.0, 4.0, 5.0] diff --git a/openc3/spec/core_ext/hash_spec.rb b/openc3/spec/core_ext/hash_spec.rb deleted file mode 100644 index cda9fd38fb..0000000000 --- a/openc3/spec/core_ext/hash_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -# encoding: ascii-8bit - -# Copyright 2022 Ball Aerospace & Technologies Corp. -# All Rights Reserved. -# -# This program is free software; you can modify and/or redistribute it -# under the terms of the GNU Affero General Public License -# as published by the Free Software Foundation; version 3 with -# attribution addendums as found in the LICENSE.txt -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# Modified by OpenC3, Inc. -# All changes Copyright 2022, OpenC3, Inc. -# All Rights Reserved -# -# This file may also be used under the terms of a commercial license -# if purchased from OpenC3, Inc. - -require 'spec_helper' -require 'openc3/core_ext/hash' - -describe Hash do - describe "inspect" do - it "limits the number of items to 10" do - hash = { '1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, '10' => 10 } - expect(hash.inspect).to eql '{"1"=>1, "2"=>2, "3"=>3, "4"=>4, "5"=>5, "6"=>6, "7"=>7, "8"=>8, "9"=>9, "10"=>10}' - hash['11'] = 11 - expect(hash.inspect).to match(/#/) - end - end -end