lib/metric_fu/metric.rb in metric_fu-4.11.3 vs lib/metric_fu/metric.rb in metric_fu-4.11.4

- old
+ new

@@ -1,12 +1,11 @@ -require 'set' -MetricFu.lib_require { 'gem_run' } -MetricFu.lib_require { 'generator' } +require "set" +MetricFu.lib_require { "gem_run" } +MetricFu.lib_require { "generator" } # Encapsulates the configuration options for each metric module MetricFu class Metric - attr_accessor :enabled, :activated def initialize self.enabled = false @libraries = Set.new @@ -18,11 +17,11 @@ end # TODO: Confirm this catches load errors from requires in subclasses, such as for flog def activate MetricFu.metrics_require { default_metric_library_paths } - @libraries.each {|library| require(library) } + @libraries.each { |library| require(library) } self.activated = true rescue LoadError => e mf_log "#{name} metric not activated, #{e.message}" end @@ -39,24 +38,24 @@ def run_options default_run_options.merge(configured_run_options) end def default_run_args - run_options.map { |k, v| "--#{k} #{v}" }.join(' ') + run_options.map { |k, v| "--#{k} #{v}" }.join(" ") end def run not_implemented end def run_external(args = default_run_args) - runner = GemRun.new({ + runner = GemRun.new( gem_name: gem_name.to_s, metric_name: name.to_s, # version: , args: args, - }) + ) stdout, stderr, status = runner.run # TODO: do something with the stderr # for now, just acknowledge we got it unless stderr.empty? STDERR.puts "STDERR from #{gem_name}:\n#{stderr}" @@ -88,15 +87,15 @@ def self.metrics @metrics end def self.enabled_metrics - metrics.select{|metric| metric.enabled && metric.activated}.sort_by {|metric| metric.name == :hotspots ? 1 : 0 } + metrics.select { |metric| metric.enabled && metric.activated }.sort_by { |metric| metric.name == :hotspots ? 1 : 0 } end def self.get_metric(name) - metrics.find{|metric|metric.name.to_s == name.to_s} + metrics.find { |metric|metric.name.to_s == name.to_s } end def self.inherited(subclass) @metrics << subclass.new end @@ -117,11 +116,11 @@ end end # Used above to identify the stem of a setter method def method_to_attr(method) - method.to_s.sub(/=$/, '').to_sym + method.to_s.sub(/=$/, "").to_sym end private def not_implemented @@ -134,10 +133,10 @@ def default_metric_library_paths paths = [] paths << generator_path = "#{name}/generator" if has_graph? - paths << grapher_path = "#{name}/grapher" + paths << grapher_path = "#{name}/grapher" end paths end end end