dyff

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADDITION     = '+'
	REMOVAL      = '-'
	MODIFICATION = '±'
	ORDERCHANGE  = '⇆'
)

Constants to distinguish between the different kinds of differences

Variables

View Source
var DebugLogger = log.New(ioutil.Discard, "Debug: ", log.Lshortfile)

DebugLogger is the debugging logger definition

View Source
var ErrorLogger = log.New(os.Stderr, "Error: ", log.Lshortfile)

ErrorLogger is the error logger definition

View Source
var FixedTerminalWidth = -1

FixedTerminalWidth disables terminal width detection and reset it with a fixed given value

View Source
var LoggingLevel = ERROR

LoggingLevel stores the currently configured logging level

View Source
var MinorChangeThreshold = 0.1

MinorChangeThreshold specifies how many percent of the text needs to be changed so that it still qualifies as being a minor string change.

View Source
var NonStandardIdentifierGuessCountThreshold = 3

NonStandardIdentifierGuessCountThreshold specifies how many list entries are needed for the guess-the-identifier function to actually consider the key name. Or in short, if the lists only contain two entries each, there are more possibilities to find unique enough keys, which might no qualify as such.

View Source
var UseGoPatchPaths = false

UseGoPatchPaths style paths instead of Spruce Dot-Style

View Source
var WarningLogger = log.New(ioutil.Discard, "Warning: ", log.Lshortfile)

WarningLogger is the warning logger definition

Functions

func ChangeRoot

func ChangeRoot(inputFile *ytbx.InputFile, path string, translateListToDocuments bool) error

ChangeRoot changes the root of an input file to a position inside its document based on the given path. Input files with more than one document are not supported, since they could have multiple elements with that path.

func CreateTableStyleString

func CreateTableStyleString(separator string, indent int, columns ...string) string

CreateTableStyleString takes the multi-line input strings as columns and arranges an output string to create a table-style output format with proper padding so that the text blocks can be arranged next to each other.

func GetIdentifierFromNamedList

func GetIdentifierFromNamedList(list []interface{}) string

GetIdentifierFromNamedList returns the identifier key used in the provided list, or an empty string if there is none. The identifier key is either 'name', 'key', or 'id'.

func ListStringKeys

func ListStringKeys(mapslice yaml.MapSlice) ([]string, error)

ListStringKeys returns a list of the keys of the YAML MapSlice (map). Only string keys are supported. Other types will result in an error.

func Plural

func Plural(amount int, text ...string) string

Plural returns a string with the number and noun in either singular or plural form. If one text argument is given, the plural will be done with the plural s. If two arguments are provided, the second text is the irregular plural. If more than two are provided, then the additional ones are simply ignored.

func RestructureObject

func RestructureObject(obj interface{}) interface{}

RestructureObject takes an object and traverses down any sub elements such as list entries or map values to recursively call restructure itself. On YAML MapSlices (maps), it will use a look-up mechanism to decide if the order of key in that map needs to be rearranged to meet some known established human order.

func SetLoggingLevel

func SetLoggingLevel(loggingLevel LogLevel)

SetLoggingLevel will initialise the logging set-up according to the provided input

Types

type BriefReport

type BriefReport struct {
	Report
}

BriefReport is a reporter that only prints a summary

func (*BriefReport) WriteReport

func (report *BriefReport) WriteReport(out io.Writer) error

WriteReport writes a brief summary to the provided writer

type Detail

type Detail struct {
	Kind rune
	From interface{}
	To   interface{}
}

Detail encapsulate the actual details of a change, mainly the kind of difference and the values.

type Diff

type Diff struct {
	Path    ytbx.Path
	Details []Detail
}

Diff encapsulates everything noteworthy about a difference

type HumanReport

type HumanReport struct {
	NoTableStyle      bool
	DoNotInspectCerts bool
	ShowBanner        bool

	Report
}

HumanReport is a reporter with human readable output in mind

func (*HumanReport) LoadX509Certs

func (report *HumanReport) LoadX509Certs(from, to string) (string, string, error)

LoadX509Certs tries to load the provided strings as a cert each and returns a textual representation of the certs, or an error if the strings are not X509 certs

func (*HumanReport) WriteReport

func (report *HumanReport) WriteReport(out io.Writer) error

WriteReport writes a human readable report to the provided writer

type LogLevel

type LogLevel int

LogLevel covers different types of logging severities

const (
	NONE LogLevel = iota
	ERROR
	WARN
	DEBUG
)

List of possile logging levels

type Report

type Report struct {
	From  ytbx.InputFile
	To    ytbx.InputFile
	Diffs []Diff
}

Report encapsulates the actual end-result of the comparison: The input data and the list of differences.

func CompareInputFiles

func CompareInputFiles(from ytbx.InputFile, to ytbx.InputFile) (Report, error)

CompareInputFiles is one of the convenience main entry points for comparing objects. In this case the representation of an input file, which might contain multiple documents. It returns a report with the list of differences. Each difference describes a change to comes from "from" to "to", hence the names.

type ReportWriter

type ReportWriter interface {
	WriteReport(out io.Writer) error
}

ReportWriter defines the interface required for types that can write reports

Jump to

Keyboard shortcuts

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