From 3ac1c9a22fc8ee176650d91542bb71d05884feac Mon Sep 17 00:00:00 2001 From: Greg Cobb Date: Mon, 24 Aug 2020 11:56:13 -0700 Subject: [PATCH] Remove unused RingBuffer class Call was removed in 25efe93 as part of removing varz --- lib/cloud_controller.rb | 2 ++ lib/sinatra/vcap.rb | 1 - lib/vcap/ring_buffer.rb | 16 --------- spec/unit/lib/vcap/ring_buffer_spec.rb | 47 -------------------------- 4 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 lib/vcap/ring_buffer.rb delete mode 100644 spec/unit/lib/vcap/ring_buffer_spec.rb diff --git a/lib/cloud_controller.rb b/lib/cloud_controller.rb index f5fbf966349..33225095141 100644 --- a/lib/cloud_controller.rb +++ b/lib/cloud_controller.rb @@ -8,6 +8,8 @@ require 'uaa/token_coder' +module VCAP; end + require 'sinatra/vcap' require File.expand_path('../config/environment', __dir__) diff --git a/lib/sinatra/vcap.rb b/lib/sinatra/vcap.rb index 46b5370bc8d..1200ac17126 100644 --- a/lib/sinatra/vcap.rb +++ b/lib/sinatra/vcap.rb @@ -1,4 +1,3 @@ -require 'vcap/ring_buffer' require 'vcap/rest_api' require 'vcap/request' require 'presenters/error_presenter' diff --git a/lib/vcap/ring_buffer.rb b/lib/vcap/ring_buffer.rb deleted file mode 100644 index 57c92623749..00000000000 --- a/lib/vcap/ring_buffer.rb +++ /dev/null @@ -1,16 +0,0 @@ -module VCAP - class RingBuffer < Array - attr_reader :max_size - - def initialize(max_size) - @max_size = max_size - end - - def push(item) - super - self.shift if size > @max_size - end - - alias_method :<<, :push - end -end diff --git a/spec/unit/lib/vcap/ring_buffer_spec.rb b/spec/unit/lib/vcap/ring_buffer_spec.rb deleted file mode 100644 index 07a7a224b16..00000000000 --- a/spec/unit/lib/vcap/ring_buffer_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' -require 'vcap/ring_buffer' - -module VCAP - RSpec.describe RingBuffer do - MAX_ENTRIES = 5 - let(:rb) { RingBuffer.new(MAX_ENTRIES) } - - context 'empty' do - it '.empty? should be true' do - expect(rb.empty?).to be true - end - end - - context 'with max push MAX_ENTRIES times' do - before do - MAX_ENTRIES.times do |i| - rb.push i - end - end - - it '.empty? should be false' do - expect(rb.empty?).to be false - end - - it '.size should return MAX_ENTRIES' do - expect(rb.size).to eq(MAX_ENTRIES) - end - - it 'should be in the correct order' do - a = [] - MAX_ENTRIES.times { |i| a.push i } - expect(rb).to eq(a) - end - - it '.push should add a new entry and drop the old one' do - rb.push 'a' - expect(rb).to eq([1, 2, 3, 4, 'a']) - end - - it '.<< should add a new entry and drop the old one' do - rb << 'a' - expect(rb).to eq([1, 2, 3, 4, 'a']) - end - end - end -end