dependency

package module
v0.0.0-...-c8674c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2015 License: MIT Imports: 6 Imported by: 2

README

go-dependency

Build StatusCoverage Status

A version dependency resolving library in Go.

Installation

The recommended way to install go-dependency

    get github.com/icambridge/go-dependency

Examples

How import the package

import (
    "github.com/icambridge/go-dependency"
)

Create your own DependencyFetcher

type MockFetcher struct {
}

func (mf MockFetcher) Get(dependencyName string) (map[string]dependency.Dependency, error) {
    return map[string]dependency.Dependency{}, nil
}

Pass that to the Repo

f := MockFetcher{}
r := dependency.GetNewRepo(f)

Then to use

d := dependency.Dependency{Require: map[string]string{"behat/behat": "~1.3"}}

p := dependency.GetPackageNames(d)

s := dependency.NewSolver(repo.Dependencies, repo.Replaces)

required, err := s.Solve(d)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPackageNames

func GetPackageNames(d Dependency) mapset.Set

func GetRules

func GetRules(dependency []Dependency) map[string]mapset.Set

func GetVersionNumbers

func GetVersionNumbers(versions map[string]Dependency) mapset.Set

func PrepVersionNumbers

func PrepVersionNumbers(versionNumbers mapset.Set) []string

Types

type Dependency

type Dependency struct {
	Name     string
	Version  string
	Requires map[string]string
	Replaces map[string]string
}

func (Dependency) ReplaceSelfVersion

func (d Dependency) ReplaceSelfVersion()

type DependencyFetcher

type DependencyFetcher interface {
	Get(dependencyName string) (map[string]Dependency, error)
}

type DependencyRepo

type DependencyRepo struct {
	DependencyNames mapset.Set
	Replaces        mapset.Set
	Dependencies    map[string]map[string]Dependency
	Fetcher         DependencyFetcher
}

func GetNewRepo

func GetNewRepo(fetcher DependencyFetcher) DependencyRepo

func (DependencyRepo) GetAll

func (r DependencyRepo) GetAll(dependencies mapset.Set)

type Solver

type Solver struct {
	Packages        map[string]map[string]Dependency
	Required        map[string]string
	Found           map[string]string
	Replaced        mapset.Set
	Rules           map[string]mapset.Set
	RuleConstraints map[string]*version.ConstraintGroup
}

func NewSolver

func NewSolver(packages map[string]map[string]Dependency, replaces mapset.Set) Solver

func (Solver) Inner

func (s Solver) Inner(rules map[string]mapset.Set) error

func (Solver) Solve

func (s Solver) Solve(root Dependency) (map[string]string, error)

type VersionSlice

type VersionSlice []string

func (VersionSlice) Len

func (p VersionSlice) Len() int

func (VersionSlice) Less

func (p VersionSlice) Less(i, j int) bool

func (VersionSlice) Swap

func (p VersionSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL