Module: Solve

Defined in:
lib/solve.rb,
lib/solve/graph.rb,
lib/solve/demand.rb,
lib/solve/errors.rb,
lib/solve/solver.rb,
lib/solve/tracers.rb,
lib/solve/version.rb,
lib/solve/artifact.rb,
lib/solve/constraint.rb,
lib/solve/dependency.rb,
lib/solve/gem_version.rb,
lib/solve/tracers/silent.rb,
lib/solve/solver/serializer.rb,
lib/solve/solver/variable_row.rb,
lib/solve/solver/constraint_row.rb,
lib/solve/solver/variable_table.rb,
lib/solve/tracers/human_readable.rb,
lib/solve/solver/constraint_table.rb

Defined Under Namespace

Modules: Errors, Tracers Classes: Artifact, Constraint, Demand, Dependency, Graph, Solver, Version

Constant Summary collapse

VERSION =
"0.8.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.tracerSolve::Formatter (readonly)

Returns:

  • (Solve::Formatter)


15
16
17
# File 'lib/solve.rb', line 15

def tracer
  @tracer
end

Class Method Details

.it!(graph, demands, options = {}) ⇒ Hash

A quick solve. Given the “world” as we know it (the graph) and a list of requirements (demands) which must be met. Return me the best solution of artifacts and verisons that I should use.

If a ui object is passed in, the resolution will be traced

Parameters:

  • graph (Solve::Graph)
  • demands (Array<Solve::Demand>, Array<String, String>)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :ui (#say) — default: nil

    a ui object for output, this will be used to output from a Solve::Tracers::HumanReadable if no other tracer is provided in options

  • :tracer (AbstractTracer) — default: nil

    a Tracer object that is used to format and output tracing information

  • :sorted (Boolean) — default: false

    should the output be a sorted list rather than a Hash

Returns:

  • (Hash)

Raises:

  • (NoSolutionError)


37
38
39
40
# File 'lib/solve.rb', line 37

def it!(graph, demands, options = {})
  @tracer = options[:tracer] || Solve::Tracers.build(options[:ui])
  Solver.new(graph, demands, options[:ui]).resolve(options)
end