Sha256: 43b7b02c59221f9a5600aad702fbf63fa404333920dce9d7906f210db70616f4

Contents?: true

Size: 609 Bytes

Versions: 7

Compression:

Stored size: 609 Bytes

Contents

require 'npmdc/formatters/progress'
require 'npmdc/formatters/documentation'
require 'npmdc/formatters/short'

module Npmdc
  module Formatter
    FORMATTERS = {
      progress: Npmdc::Formatters::Progress,
      doc:      Npmdc::Formatters::Documentation,
      short:    Npmdc::Formatters::Short
    }.freeze

    class << self
      def call(options)
        fmt = options.fetch('format', Npmdc.config.format)
        klass(fmt).new(options)
      end

      private

      def klass(fmt)
        FORMATTERS[fmt.to_sym] || raise(Npmdc::Errors::UnknownFormatter, formatter: fmt)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
npmdc-0.5.1 lib/npmdc/formatter.rb
npmdc-0.5.0 lib/npmdc/formatter.rb
npmdc-0.4.1 lib/npmdc/formatter.rb
npmdc-0.4.0 lib/npmdc/formatter.rb
npmdc-0.3.2 lib/npmdc/formatter.rb
npmdc-0.3.1 lib/npmdc/formatter.rb
npmdc-0.3.0 lib/npmdc/formatter.rb