Class: RSpec::Core::Formatters::DeprecationFormatter::DelayedPrinter
- Inherits:
-
Object
- Object
- RSpec::Core::Formatters::DeprecationFormatter::DelayedPrinter
- Includes:
- Helpers
- Defined in:
- lib/rspec/core/formatters/deprecation_formatter.rb
Constant Summary
- TOO_MANY_USES_LIMIT =
4
Constants included from Helpers
Helpers::DEFAULT_PRECISION, Helpers::SUB_SECOND_PRECISION
Instance Attribute Summary (collapse)
-
- (Object) deprecation_formatter
readonly
Returns the value of attribute deprecation_formatter.
-
- (Object) deprecation_stream
readonly
Returns the value of attribute deprecation_stream.
-
- (Object) summary_stream
readonly
Returns the value of attribute summary_stream.
Instance Method Summary (collapse)
- - (Object) deprecation_summary
-
- (DelayedPrinter) initialize(deprecation_stream, summary_stream, deprecation_formatter)
constructor
A new instance of DelayedPrinter.
- - (Object) print_deferred_deprecation_warnings
- - (Object) print_deprecation_message(data)
- - (Object) stash_deprecation_message(deprecation_message)
Methods included from Helpers
#format_duration, #format_seconds, #pluralize, #strip_trailing_zeroes
Methods included from BacktraceFormatter
Constructor Details
- (DelayedPrinter) initialize(deprecation_stream, summary_stream, deprecation_formatter)
A new instance of DelayedPrinter
140 141 142 143 144 145 146 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 140 def initialize(deprecation_stream, summary_stream, deprecation_formatter) @deprecation_stream = deprecation_stream @summary_stream = summary_stream @deprecation_formatter = deprecation_formatter @seen_deprecations = Hash.new { 0 } @deprecation_messages = Hash.new { |h, k| h[k] = [] } end |
Instance Attribute Details
- (Object) deprecation_formatter (readonly)
Returns the value of attribute deprecation_formatter
138 139 140 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 138 def deprecation_formatter @deprecation_formatter end |
- (Object) deprecation_stream (readonly)
Returns the value of attribute deprecation_stream
138 139 140 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 138 def deprecation_stream @deprecation_stream end |
- (Object) summary_stream (readonly)
Returns the value of attribute summary_stream
138 139 140 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 138 def summary_stream @summary_stream end |
Instance Method Details
- (Object) deprecation_summary
163 164 165 166 167 168 169 170 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 163 def deprecation_summary return unless @deprecation_messages.any? print_deferred_deprecation_warnings deprecation_stream.puts RAISE_ERROR_CONFIG_NOTICE summary_stream.puts "\n#{pluralize(deprecation_formatter.count, 'deprecation warning')} total" end |
- (Object) print_deferred_deprecation_warnings
172 173 174 175 176 177 178 179 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 172 def print_deferred_deprecation_warnings deprecation_stream.puts "\nDeprecation Warnings:\n\n" @deprecation_messages.keys.sort_by(&:type).each do |deprecation| = @deprecation_messages[deprecation] .each { |msg| deprecation_stream.puts msg } deprecation_stream.puts end end |
- (Object) print_deprecation_message(data)
148 149 150 151 152 153 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 148 def (data) = deprecation_formatter.(data) @seen_deprecations[] += 1 () end |
- (Object) stash_deprecation_message(deprecation_message)
155 156 157 158 159 160 161 |
# File 'lib/rspec/core/formatters/deprecation_formatter.rb', line 155 def () if @seen_deprecations[] < TOO_MANY_USES_LIMIT @deprecation_messages[] << .to_s elsif @seen_deprecations[] == TOO_MANY_USES_LIMIT @deprecation_messages[] << . end end |