Sha256: 0b836b90c6df211e083b1d3964c7673cfb2fe499dac2dd61fdfc659177671afe

Contents?: true

Size: 1.28 KB

Versions: 166

Compression:

Stored size: 1.28 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.problem.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

166 entries across 166 versions & 1 rubygems

Version Path
trackler-2.1.0.18 lib/trackler.rb
trackler-2.1.0.17 lib/trackler.rb
trackler-2.1.0.16 lib/trackler.rb
trackler-2.1.0.15 lib/trackler.rb
trackler-2.1.0.14 lib/trackler.rb
trackler-2.1.0.13 lib/trackler.rb
trackler-2.1.0.12 lib/trackler.rb
trackler-2.1.0.11 lib/trackler.rb
trackler-2.1.0.10 lib/trackler.rb
trackler-2.1.0.9 lib/trackler.rb
trackler-2.1.0.8 lib/trackler.rb
trackler-2.1.0.7 lib/trackler.rb
trackler-2.1.0.6 lib/trackler.rb
trackler-2.1.0.5 lib/trackler.rb
trackler-2.1.0.4 lib/trackler.rb
trackler-2.1.0.3 lib/trackler.rb
trackler-2.1.0.2 lib/trackler.rb
trackler-2.1.0.1 lib/trackler.rb
trackler-2.1.0.0 lib/trackler.rb
trackler-2.0.8.55 lib/trackler.rb