PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1module 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
11        def start(example_count=nil)
12          #no-op to fix #966
13        end
14
15        def deprecation(data)
16          @count += 1
17          if data[:message]
18            @deprecation_stream.print data[:message]
19          else
20            @deprecation_stream.print "DEPRECATION: " unless File === @deprecation_stream
21            @deprecation_stream.print "#{data[:deprecated]} is deprecated."
22            @deprecation_stream.print " Use #{data[:replacement]} instead." if data[:replacement]
23            @deprecation_stream.print " Called from #{data[:call_site]}." if data[:call_site]
24            @deprecation_stream.puts
25          end
26        end
27
28        def deprecation_summary
29          if @count > 0 && File === @deprecation_stream
30            @summary_stream.print "\n#{@count} deprecation"
31            @summary_stream.print "s" if @count > 1
32            @summary_stream.print " logged to "
33            @summary_stream.puts @deprecation_stream.path
34          end
35        end
36      end
37    end
38  end
39end