Project

grimoire

0.0
No commit activity in last 3 years
No release in over 3 years
Specialized constraint solver allowing weighted results
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 10

Runtime

< 0.5, >= 0.1.12
< 1.0, >= 0.1.10
 Project Readme

Grimoire

Light weight generic dependency resolver. Supports weighted solutions via scored units.

Usage

Basic usage flow:

  • Create a system
system = Grimoire::System.new
  • Add units
system.add_units(
  Grimoire::Unit.new(
    :name => 'unit1',
    :version => '1.0.0'
  ),
  Grimoire::Unit.new(
    :name => 'unit1',
    :version => '1.1.0'
  ),
  ...
)
  • Create a score keeper

NOTE: Score keeper is optional and must be subclassed. This example will not actually work.

score_keeper = Grimoire::ScoreKeeper.new
  • Create solver
solver = Grimoire::Solver.new(
  :system => system,
  :score_keeper => score_keeper,
  :requirements => [
    ['unit1', '> 2.0.0'],
    ['unit2', '> 1', '< 3']
  ]
)
  • Create a solver with restrictions (optional)
solver = Grimoire::Solver.new(
  :system => system,
  :score_keeper => score_keeper,
  :requirements => [
    ['unit1', '> 2.0.0'],
    ['unit2', '> 1', '< 3']
  ],
  :restrictions => [
    ['unit1', '< 3'],
    ['unit2', '> 1.2.0']
  ]
)
  • Generate solutions
solutions = solver.generate!
p solutions.pop

The ideal solution will be the first path on the queue.

Info