Sha256: 5b4fce8318912dfbff27e91096aa0b523174421e3f941219fa5d687cf5173392

Contents?: true

Size: 1.23 KB

Versions: 7

Compression:

Stored size: 1.23 KB

Contents

require 'metric_fu/constantize'
module MetricFu
  module Formatter
    BUILTIN_FORMATS = {
      'html' => ['MetricFu::Formatter::HTML', 'Generates a templated HTML report using the configured template class and graph engine.'],
      'yaml' => ['MetricFu::Formatter::YAML', 'Generates the raw output as yaml']
    }
    DEFAULT = [[:html]]

    class << self
      include MetricFu::Constantize

      def class_for(format)
        if (builtin = BUILTIN_FORMATS[format.to_s])
          constantize(builtin[0])
        else
          constantize(format.to_s)
        end
      end

    end

    module Templates
      MetricFu.reporting_require { 'templates/awesome/awesome_template' }

      module_function

      def options
        @options ||= {}
      end
      def option(name)
        options.fetch(name) { raise "No such template option: #{name}" }
      end

      # TODO: Remove config argument
      def configure_template(config)
        @options = {}
        @options['template_class'] = AwesomeTemplate
        @options['link_prefix'] = nil
        @options['darwin_txmt_protocol_no_thanks'] = true
        # # turning off syntax_highlighting may avoid some UTF-8 issues
        @options['syntax_highlighting'] = true
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
metric_fu-4.5.2 lib/metric_fu/formatter.rb
metric_fu-4.5.1 lib/metric_fu/formatter.rb
metric_fu-4.4.4 lib/metric_fu/formatter.rb
metric_fu-4.4.3 lib/metric_fu/formatter.rb
metric_fu-4.4.2 lib/metric_fu/formatter.rb
metric_fu-4.4.1 lib/metric_fu/formatter.rb
metric_fu-4.4.0 lib/metric_fu/formatter.rb