Sha256: 59111faf2a9f53c7b7d1e7a2beaf0184f6adfdf83fda65a4cbcf7bab2b1fa036

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

paths = Dir[File.expand_path('../trackler/**/*.rb', __FILE__)]
paths.each { |path| require path }

module Trackler
  def self.reset
    @path = nil
    @implementations = nil
    @problems = nil
    @tracks = nil
    @todos = nil
  end

  def self.path
    @path ||= Trackler::Path.root
  end

  def self.use_real_data
    reset
    @path = Trackler::Path.root
  end

  def self.use_fixture_data
    reset
    @path = Trackler::Path.fixtures
  end

  def self.problems
    @problems ||= Problems.new(path)
  end

  def self.tracks
    @tracks ||= Tracks.new(path)
  end

  def self.implementations
    return @implementations if !!@implementations

    @implementations = Hash.new { |h, k| h[k] = [] }
    tracks.each do |track|
      track.implementations.each do |implementation|
        @implementations[implementation.slug] << implementation
      end
    end
    @implementations
  end

  def self.todos
    return @todos if !!@todos

    slugs = problems.map(&:slug)

    @todos = Hash.new { |h, k| h[k] = [] }
    tracks.each do |track|
      todos = slugs - track.slugs
      @todos[track.id] = problems.select { |problem|
        todos.include?(problem.slug)
      }.sort_by { |problem|
        [implementations[problem.slug].count * -1, problem.name]
      }
    end
    @todos
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trackler-2.1.0.24 lib/trackler.rb
trackler-2.1.0.23 lib/trackler.rb
trackler-2.1.0.22 lib/trackler.rb
trackler-2.1.0.21 lib/trackler.rb
trackler-2.1.0.20 lib/trackler.rb
trackler-2.1.0.19 lib/trackler.rb