recipe

package
v0.0.0-...-67abcb5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = time.Now

Functions

func Add

func Add(x string, y string) (string, error)

func Age

func Age(dob string) (string, error)

func Author

func Author() string

func Change

func Change(from string, to string, input string) (string, error)

func ChangeI

func ChangeI(from string, to string, input string) (string, error)

func Divide

func Divide(x string, y string) (string, error)

func FirstChars

func FirstChars(count string, input string) (string, error)

func FormatDate

func FormatDate(format string, normalDate string) (string, error)

func FormatDateF

func FormatDateF(format string, normalDate string) (string, error)

func IfEmpty

func IfEmpty(emptyVal string, notEmptyVal string, input string) (string, error)

func IsFuture

func IsFuture(future string, past string, date string) (string, error)

func IsPast

func IsPast(past string, future string, date string) (string, error)

func LastChars

func LastChars(count string, input string) (string, error)

func Lowercase

func Lowercase(s string) string

func MassProcess

func MassProcess(incoming []string, processor Processor) (out []string)

func Modulus

func Modulus(x string, y string) (string, error)

func Multiply

func Multiply(x string, y string) (string, error)

func NoDigits

func NoDigits(s string) string

func NowTime

func NowTime(now func() time.Time) (string, error)

func NumberFormat

func NumberFormat(digits string, input string) (string, error)

func OnlyDigits

func OnlyDigits(input string) (string, error)

func Power

func Power(number string, power string) (string, error)

func ReadDate

func ReadDate(format string, input string) (string, error)

func ReadDateF

func ReadDateF(format string, input string) (string, error)

func RemoveDigits

func RemoveDigits(input string) (string, error)

func Repeat

func Repeat(count string, input string) (string, error)

func ReplaceString

func ReplaceString(search string, replace string, input string) (string, error)

func SmartDate

func SmartDate(date string) (string, error)

func Subtract

func Subtract(x string, y string) (string, error)

func Today

func Today(now func() time.Time) (string, error)

func Trim

func Trim(input string) (string, error)

func Uppercase

func Uppercase(s string) string

func Version

func Version() string

Types

type Argument

type Argument struct {
	Type  DataType
	Value string
}

func (*Argument) GetValue

func (a *Argument) GetValue(context LineContext, placeholder string) (string, error)

type DataType

type DataType int
const (
	Column DataType = iota
	Variable
	Literal
	Placeholder
	Header
)

func (DataType) String

func (i DataType) String() string

type JoinMode

type JoinMode int
const (
	Replace JoinMode = iota
	Join
)

func (JoinMode) String

func (i JoinMode) String() string

type LineContext

type LineContext struct {
	Variables map[string]string
	Columns   map[int]string
	LineNo    int
}

type Operation

type Operation struct {
	Name      string
	Arguments []Argument
}

type Output

type Output struct {
	Type  DataType
	Value string
}

func (*Output) GetValue

func (o *Output) GetValue(ctx LineContext) (string, error)

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

type Processor

type Processor func(string) string

func JoinFunc

func JoinFunc(p string) Processor

type Recipe

type Recipe struct {
	Output  Output
	Pipe    []Operation
	Comment string
}

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, lit string)

Scan returns the next token and literal value

type Token

type Token int
const (
	ILLEGAL     Token = iota
	EOF               //1 - end of file
	WS                //2 - space, tab, newline
	NEWLINE           //3 - \n (probably not needed)
	COLUMN_ID         //4 - digits
	ASSIGNMENT        //5 - <-
	PIPE              //6 - ->
	COMMENT           //7 - # ...
	PLACEHOLDER       //8 - ?
	PLUS              //9 - +
	LITERAL           //10 - "quoted"
	VARIABLE          //11 - starts w/ $
	FUNCTION          //12 - letters
	OPEN_PAREN        //13 - (
	CLOSE_PAREN       //14 - )
	COMMA             //15 - ,
	HEADER            //16 - !<digits>
)

func (Token) String

func (i Token) String() string

type Transformation

type Transformation struct {
	Variables     map[string]Recipe
	Columns       map[int]Recipe
	Headers       map[int]Recipe
	VariableOrder []string
}

func NewTransformation

func NewTransformation() *Transformation

func Parse

func Parse(source io.Reader) (*Transformation, error)

func (*Transformation) AddOperationByType

func (t *Transformation) AddOperationByType(targetType DataType, target string, operation Operation)

func (*Transformation) AddOperationToColumn

func (t *Transformation) AddOperationToColumn(column string, operation Operation)

func (*Transformation) AddOperationToHeader

func (t *Transformation) AddOperationToHeader(header string, operation Operation)

func (*Transformation) AddOperationToVariable

func (t *Transformation) AddOperationToVariable(variable string, operation Operation)

func (*Transformation) AddOutputToColumn

func (t *Transformation) AddOutputToColumn(column string) error

func (*Transformation) AddOutputToHeader

func (t *Transformation) AddOutputToHeader(header string) error

func (*Transformation) AddOutputToVariable

func (t *Transformation) AddOutputToVariable(variable string) error

func (*Transformation) Dump

func (t *Transformation) Dump(w io.Writer)

func (*Transformation) Execute

func (t *Transformation) Execute(reader *csv.Reader, writer *csv.Writer, processHeader bool, lineLimit int, parseErrIsErr bool) (*TransformationResult, error)

func (*Transformation) ValidateRecipe

func (t *Transformation) ValidateRecipe() error

type TransformationResult

type TransformationResult struct {
	HeaderLines int
	Lines       int
}

Jump to

Keyboard shortcuts

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