Skip to content
Light weight solver
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.nellie
CHANGELOG.md
CONTRIBUTING.md
Gemfile
LICENSE
README.md
Rakefile
grimoire.gemspec

README.md

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

You can’t perform that action at this time.