Class: RSpec::Core::Formatters::Loader Private
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
‘RSpec::Core::Formatters::Loader` is an internal class for managing formatters used by a particular configuration. It is not expected to be used directly, but only through the configuration interface.
Instance Attribute Summary collapse
-
#default_formatter ⇒ String
private
The default formatter to setup, defaults to ‘progress`.
-
#formatters ⇒ Array
readonly
private
The loaded formatters.
-
#reporter ⇒ Reporter
readonly
private
The reporter.
Class Method Summary collapse
-
.formatters ⇒ Object
private
Internal formatters are stored here when loaded.
Instance Method Summary collapse
- #add(formatter_to_use, *paths) ⇒ Object private
-
#initialize(reporter) ⇒ Loader
constructor
private
A new instance of Loader.
- #prepare_default(output_stream, deprecation_stream) ⇒ Object private
- #setup_default(output_stream, deprecation_stream) ⇒ Object private
Constructor Details
#initialize(reporter) ⇒ Loader
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Loader.
105 106 107 108 109 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 105 def initialize(reporter) @formatters = [] @reporter = reporter self.default_formatter = 'progress' end |
Instance Attribute Details
#default_formatter ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the default formatter to setup, defaults to ‘progress`.
118 119 120 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 118 def default_formatter @default_formatter end |
#formatters ⇒ Array (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the loaded formatters.
112 113 114 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 112 def formatters @formatters end |
#reporter ⇒ Reporter (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the reporter.
115 116 117 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 115 def reporter @reporter end |
Class Method Details
.formatters ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal formatters are stored here when loaded.
100 101 102 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 100 def self.formatters @formatters ||= {} end |
Instance Method Details
#add(formatter_to_use, *paths) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 144 def add(formatter_to_use, *paths) # If a formatter instance was passed, we can register it directly, # with no need for any of the further processing that happens below. if Loader.formatters.key?(formatter_to_use.class) register formatter_to_use, notifications_for(formatter_to_use.class) return end formatter_class = find_formatter(formatter_to_use) args = paths.map { |p| p.respond_to?(:puts) ? p : open_stream(p) } if !Loader.formatters[formatter_class].nil? formatter = formatter_class.new(*args) register formatter, notifications_for(formatter_class) elsif defined?(RSpec::LegacyFormatters) formatter = RSpec::LegacyFormatters.load_formatter formatter_class, *args register formatter, formatter.notifications else call_site = "Formatter added at: #{::RSpec::CallerFilter.first_non_rspec_line}" RSpec.warn_deprecation "|The \#{formatter_class} formatter uses the deprecated formatter\n|interface not supported directly by RSpec 3.\n|\n|To continue to use this formatter you must install the\n|`rspec-legacy_formatters` gem, which provides support\n|for legacy formatters or upgrade the formatter to a\n|compatible version.\n|\n|\#{call_site}\n".gsub(/\s*\|/, ' ') end end |
#prepare_default(output_stream, deprecation_stream) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
121 122 123 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 121 def prepare_default(output_stream, deprecation_stream) reporter.prepare_default(self, output_stream, deprecation_stream) end |
#setup_default(output_stream, deprecation_stream) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/formatters.rb', line 126 def setup_default(output_stream, deprecation_stream) add default_formatter, output_stream if @formatters.empty? unless @formatters.any? { |formatter| DeprecationFormatter === formatter } add DeprecationFormatter, deprecation_stream, output_stream end unless existing_formatter_implements?(:message) add FallbackMessageFormatter, output_stream end return unless RSpec.configuration.profile_examples? return if existing_formatter_implements?(:dump_profile) add RSpec::Core::Formatters::ProfileFormatter, output_stream end |