Sha256: 048e3086bac2c2c0fd2db64038a5d688b54745bbd291a68d112d045c1fda35b1

Contents?: true

Size: 468 Bytes

Versions: 10

Compression:

Stored size: 468 Bytes

Contents

module Prosperity
  class MetricFinder < Struct.new(:directory)
    def metrics
      Dir[File.join(directory, "**/*_metric.rb")].map do |metric|
        File.basename(metric, ".rb").camelcase.constantize
      end
    end

    def self.all
      self.new(File.join(Rails.root, "app/prosperity")).metrics
    end

    def self.find_by_name(name)
      klass = name.constantize

      if klass < Metric
        klass
      else
        nil
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prosperity-0.0.11 lib/prosperity/metric_finder.rb
prosperity-0.0.10 lib/prosperity/metric_finder.rb
prosperity-0.0.9 lib/prosperity/metric_finder.rb
prosperity-0.0.8 lib/prosperity/metric_finder.rb
prosperity-0.0.7 lib/prosperity/metric_finder.rb
prosperity-0.0.6 lib/prosperity/metric_finder.rb
prosperity-0.0.5 lib/prosperity/metric_finder.rb
prosperity-0.0.4 lib/prosperity/metric_finder.rb
prosperity-0.0.3 lib/prosperity/metric_finder.rb
prosperity-0.0.2 lib/prosperity/metric_finder.rb