Sha256: 51644e1b42016cb74b4c86203bdfc51ec7acd1133243eef54da24af0a16d528c

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

module RSpec
  module Core
    module Formatters
      class DeprecationFormatter
        def initialize(deprecation_stream=$stderr, summary_stream=$stdout)
          @deprecation_stream = deprecation_stream
          @summary_stream = summary_stream
          @count = 0
        end

        def deprecation(data)
          @count += 1
          if data[:message]
            @deprecation_stream.print data[:message]
          else
            @deprecation_stream.print "DEPRECATION: " unless File === @deprecation_stream
            @deprecation_stream.print "#{data[:deprecated]} is deprecated."
            @deprecation_stream.print " Use #{data[:replacement]} instead." if data[:replacement]
            @deprecation_stream.print " Called from #{data[:call_site]}." if data[:call_site]
            @deprecation_stream.puts
          end
        end

        def deprecation_summary
          if @count > 0 && File === @deprecation_stream
            @summary_stream.print "\n#{@count} deprecation"
            @summary_stream.print "s" if @count > 1
            @summary_stream.print " logged to "
            @summary_stream.puts @deprecation_stream.path
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspec-core-2.14.1 lib/rspec/core/formatters/deprecation_formatter.rb
rspec-core-2.14.0 lib/rspec/core/formatters/deprecation_formatter.rb
rspec-core-2.14.0.rc1 lib/rspec/core/formatters/deprecation_formatter.rb