Class: Dobby::Formatter::FormatterSet
- Inherits:
-
Array
- Object
- Array
- Dobby::Formatter::FormatterSet
- Defined in:
- lib/dobby/formatter/formatter_set.rb
Constant Summary collapse
- BUILTIN_FORMATTERS =
{ 'simple' => SimpleFormatter, 'json' => JSONFormatter }.freeze
- FORMATTER_APIS =
%i[started finished file_started].freeze
Instance Method Summary collapse
- #add_formatter(type, output_path = nil) ⇒ Object
- #close_output_files ⇒ Object
- #file_finished(file, results) ⇒ Object
-
#initialize(options = {}) ⇒ FormatterSet
constructor
A new instance of FormatterSet.
Constructor Details
#initialize(options = {}) ⇒ FormatterSet
Returns a new instance of FormatterSet.
19 20 21 |
# File 'lib/dobby/formatter/formatter_set.rb', line 19 def initialize( = {}) @options = end |
Instance Method Details
#add_formatter(type, output_path = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dobby/formatter/formatter_set.rb', line 28 def add_formatter(type, output_path = nil) if output_path dir_path = File.dirname(output_path) FileUtils.mkdir_p(dir_path) unless File.exist?(dir_path) output = File.open(output_path, 'w') else output = $stdout end self << formatter_class(type).new(output, @options) end |
#close_output_files ⇒ Object
40 41 42 43 44 |
# File 'lib/dobby/formatter/formatter_set.rb', line 40 def close_output_files each do |formatter| formatter.output.close if formatter.output.is_a?(File) end end |
#file_finished(file, results) ⇒ Object
23 24 25 26 |
# File 'lib/dobby/formatter/formatter_set.rb', line 23 def file_finished(file, results) each { |f| f.file_finished(file, results) } results end |