class MetricFu::Configuration
Configuration
¶ ↑
The Configuration
class, as it sounds, provides methods for configuring the behaviour of MetricFu
.
Customization for CruiseControl.rb¶ ↑
The Configuration
class checks for the presence of a 'CC_BUILD_ARTIFACTS' environment variable. If it's found it will change the default output directory from the default “tmp/metric_fu to the directory represented by 'CC_BUILD_ARTIFACTS'
Metric
Configuration
¶ ↑
Each metric can be configured by e.g.
config.configure_metric(:flog) do |flog| flog.enable flog.dirs_to_flog = %w(app lib spec) ... end
or iterate over all metrics to configure by e.g.
config.configure_metrics.each do |metric| ... end
Formatter
Configuration
¶ ↑
Formatters can be configured by e.g.
config.configure_formatter(:html) config.configure_formatter(:yaml, "customreport.yml") config.configure_formatter(MyCustomFormatter)
Attributes
TODO review if these code is functionally duplicated in the base generator initialize
Public Class Methods
# File lib/metric_fu/configuration.rb, line 93 def self.configure_metric(name) yield MetricFu::Metric.get_metric(name) end
This allows us to have a nice syntax like:
MetricFu.run do |config| config.configure_metric(:churn) do ... end config.configure_formatter(MyCustomFormatter) end
See the README for more information on configuration options. TODO: Consider breaking compatibility by removing this, now unused method
# File lib/metric_fu/configuration.rb, line 89 def self.run yield MetricFu.configuration end
Public Instance Methods
TODO: Reconsider method name/behavior, as it really adds a formatter
# File lib/metric_fu/configuration.rb, line 115 def configure_formatter(format, output = nil) @formatters << MetricFu::Formatter.class_for(format).new(output: output) end
# File lib/metric_fu/configuration.rb, line 125 def configure_graph_engine(graph_engine) @graph_engine = graph_engine end
# File lib/metric_fu/configuration.rb, line 97 def configure_metric(name, &block) self.class.configure_metric(name, &block) end
# File lib/metric_fu/configuration.rb, line 101 def configure_metrics MetricFu::Io::FileSystem.set_directories MetricFu::Metric.metrics.each do |metric| if block_given? yield metric else metric.enabled = false metric.enable end metric.activate if metric.enabled unless metric.activated end end
# File lib/metric_fu/configuration.rb, line 129 def graph_engine @graph_engine end
@return [Array<Symbol>] names of enabled metrics with graphs
# File lib/metric_fu/configuration.rb, line 120 def graphed_metrics # TODO: This is a common enough need to be pushed into MetricFu::Metric as :enabled_metrics_with_graphs MetricFu::Metric.enabled_metrics.select(&:has_graph?).map(&:name) end
# File lib/metric_fu/configuration.rb, line 66 def reset # TODO: Remove calls to self and/or allow querying the # template/filesystem/metric/graph/environment, etc settings # from the configuration instance MetricFu::Io::FileSystem.set_directories @templates_configuration = MetricFu::Templates::Configuration.new MetricFu::Formatter::Templates.templates_configuration = @templates_configuration @formatters = [] @graph_engine = :bluff end
This allows us to configure the templates with:
MetricFu.run do |config| config.templates_configuration do |templates_config| templates_config.link_prefix = 'http:/' end end
# File lib/metric_fu/configuration.rb, line 140 def templates_configuration yield @templates_configuration end
@param option [String, Symbol] the requested template option @return [String] the configured template option
# File lib/metric_fu/configuration.rb, line 146 def templates_option(option) @templates_configuration.option(option) end