/vendor/bundle/jruby/2.1/gems/rspec-core-2.14.8/lib/rspec/core/formatters/deprecation_formatter.rb

https://github.com/delowong/logstash · Ruby · 39 lines · 35 code · 3 blank · 1 comment · 4 complexity · 7143c54687b3b3eb0e0dfa683519dd34 MD5 · raw file

  1. module RSpec
  2. module Core
  3. module Formatters
  4. class DeprecationFormatter
  5. def initialize(deprecation_stream=$stderr, summary_stream=$stdout)
  6. @deprecation_stream = deprecation_stream
  7. @summary_stream = summary_stream
  8. @count = 0
  9. end
  10. def start(example_count=nil)
  11. #no-op to fix #966
  12. end
  13. def deprecation(data)
  14. @count += 1
  15. if data[:message]
  16. @deprecation_stream.print data[:message]
  17. else
  18. @deprecation_stream.print "DEPRECATION: " unless File === @deprecation_stream
  19. @deprecation_stream.print "#{data[:deprecated]} is deprecated."
  20. @deprecation_stream.print " Use #{data[:replacement]} instead." if data[:replacement]
  21. @deprecation_stream.print " Called from #{data[:call_site]}." if data[:call_site]
  22. @deprecation_stream.puts
  23. end
  24. end
  25. def deprecation_summary
  26. if @count > 0 && File === @deprecation_stream
  27. @summary_stream.print "\n#{@count} deprecation"
  28. @summary_stream.print "s" if @count > 1
  29. @summary_stream.print " logged to "
  30. @summary_stream.puts @deprecation_stream.path
  31. end
  32. end
  33. end
  34. end
  35. end
  36. end