Class: Rubocop::Formatter::FormatterSet
- Inherits:
-
Array
- Object
- Array
- Rubocop::Formatter::FormatterSet
- Defined in:
- lib/rubocop/formatter/formatter_set.rb
Overview
This is a collection of formatters. A FormatterSet can hold multiple formatter instances and provides transparent formatter API methods which invoke same method of each formatters.
Constant Summary collapse
- BUILTIN_FORMATTERS_FOR_KEYS =
{ 'progress' => ProgressFormatter, 'simple' => SimpleTextFormatter, 'clang' => ClangStyleFormatter, 'fuubar' => FuubarStyleFormatter, 'emacs' => EmacsStyleFormatter, 'json' => JSONFormatter, 'files' => FileListFormatter, 'offenses' => OffenseCountFormatter, 'disabled' => DisabledLinesFormatter }
- FORMATTER_APIS =
[:started, :file_started, :file_finished, :finished]
Instance Method Summary collapse
Instance Method Details
#add_formatter(formatter_type, output_path = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/formatter/formatter_set.rb', line 29 def add_formatter(formatter_type, output_path = nil) formatter_class = case formatter_type when Class formatter_type when /\A[A-Z]/ custom_formatter_class(formatter_type) else builtin_formatter_class(formatter_type) end output = output_path ? File.open(output_path, 'w') : $stdout self << formatter_class.new(output) end |
#close_output_files ⇒ Object
44 45 46 47 48 |
# File 'lib/rubocop/formatter/formatter_set.rb', line 44 def close_output_files each do |formatter| formatter.output.close if formatter.output.is_a?(File) end end |