geist

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package geist produces reports from templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeDoubleQuotes

func EscapeDoubleQuotes(text string) string

EscapeDoubleQuotes substitutes an escaped double-quote character sequence (\") for each actual doublequote character in the argument and returns the updated string.

func EscapeNewlines

func EscapeNewlines(text string) string

EscapeNewlines substitutes an escaped newline character sequence (\\n) for for each actual newline character (\n) in the argument and returns the updated string.

func EscapeRawText

func EscapeRawText(dp DelimiterPair, text string) (escapedText string, err error)

EscapeRawText finds substrings delimited by the given DelimiterPair and within each escapes newlines and replaces the starting and end delimiters with double quotes.

func GetParameterAppendedBody

func GetParameterAppendedBody(args []string) (body string)

func PrependPrefixes

func PrependPrefixes(rp *Template, text string) string

func RemoveEscapedLineEndings

func RemoveEscapedLineEndings(text string) string

func RemoveNewlines

func RemoveNewlines(text string) string

func RestoreNewlines

func RestoreNewlines(text string) string

func WriteStringTable

func WriteStringTable(sa [][]string, colSeparators bool) string

Types

type Binding

type Binding map[string]struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

func (Binding) DelimitedValue

func (b Binding) DelimitedValue(name string) (delimitedValue string)

type Client

type Client interface {
	Select(query string) (rs *ResultSet, err error)
}

type DataTable

type DataTable interface {
	ColumnCount() int
	RowCount() int
	Row(rowIndex int) []string
	Column(columnIndex int) []string
	Rows() [][]string
	FormattedTable(columnSeparator bool) string
}

type DelimiterPair

type DelimiterPair struct {
	Start string
	End   string
}

DelimiterPair defines the start and end delimiter for a report text region.

var DefaultDelimiters DelimiterPair
var GraveDelimiters DelimiterPair
var JSPDelimiters DelimiterPair
var MacroDelimiters DelimiterPair
var TripleSingleQuoteDelimiters DelimiterPair

type GeistError

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

func NewGeistError

func NewGeistError(summary string, err error, prepend bool) GeistError

func (GeistError) Error

func (e GeistError) Error() string

func (GeistError) Unwrap

func (e GeistError) Unwrap() error
type Head struct {
	Vars []string `json:"vars"`
}

type Properties

type Properties struct {
	Delimiters DelimiterPair
	Funcs      textTemplate.FuncMap
	Client     *Client
	Prefixes   map[string]string
	Macros     map[string]*Template
	Queries    map[string]string
	Rules      map[string]string
}

type RestClient added in v0.2.5

type RestClient struct {
	HttpClient *http.Client
	Logger     *log.Logger
	Endpoint   string
}

func NewRestClient added in v0.2.5

func NewRestClient(endpoint string) *RestClient

type ResultSet

type ResultSet struct {
	Head    Head    `json:"head"`
	Results Results `json:"results"`
}

func (*ResultSet) Bindings

func (sr *ResultSet) Bindings() []Binding

func (*ResultSet) Column

func (sr *ResultSet) Column(columnIndex int) []string

func (*ResultSet) ColumnCount

func (rs *ResultSet) ColumnCount() int

func (*ResultSet) FormattedTable

func (rs *ResultSet) FormattedTable(columnSeparator bool) string

func (*ResultSet) JSONString

func (rs *ResultSet) JSONString() (jsonString string, err error)

func (*ResultSet) Row

func (sr *ResultSet) Row(rowIndex int) []string

func (*ResultSet) RowCount

func (rs *ResultSet) RowCount() int

func (*ResultSet) Rows

func (rs *ResultSet) Rows() [][]string

func (*ResultSet) Variables

func (sr *ResultSet) Variables() []string

type Results

type Results struct {
	Bindings []Binding `json:"bindings"`
}

type SparqlClient

type SparqlClient struct {
	RestClient
	Parameters string
}

func NewSparqlClient

func NewSparqlClient(endpoint string) *SparqlClient

func (*SparqlClient) Construct

func (sc *SparqlClient) Construct(format string, query string) (triples []byte, err error)

func (*SparqlClient) DeleteRequest

func (sc *SparqlClient) DeleteRequest(url string) (
	responseBody []byte, err error)

func (*SparqlClient) GetRequest

func (sc *SparqlClient) GetRequest(url string, contentType string,
	acceptType string) (responseBody []byte, err error)

func (*SparqlClient) PostData

func (sc *SparqlClient) PostData(format string, data []byte) (responseBody []byte, err error)

func (*SparqlClient) PostRequest

func (sc *SparqlClient) PostRequest(url string, contentType string, acceptType string,
	requestBody []byte) (responseBody []byte, err error)

func (*SparqlClient) PostSparqlRequest

func (sc *SparqlClient) PostSparqlRequest(contentType string, acceptType string,
	requestBody []byte) (responseBody []byte, err error)

func (SparqlClient) Select

func (sc SparqlClient) Select(query string) (rs *ResultSet, err error)

func (*SparqlClient) SelectAll

func (sc *SparqlClient) SelectAll() (rs *ResultSet, err error)

func (*SparqlClient) SelectCSV

func (sc *SparqlClient) SelectCSV(query string) (csv string, err error)

func (*SparqlClient) SelectXML

func (sc *SparqlClient) SelectXML(query string) (csv string, err error)

type TableWriter

type TableWriter struct {
	MaxRowLen    int
	RowSeparator string
	// contains filtered or unexported fields
}

func NewTableWriter

func NewTableWriter(colSeparators bool) *TableWriter

func (*TableWriter) String

func (tw *TableWriter) String() string

func (*TableWriter) Write

func (tw *TableWriter) Write(row []byte) (n int, err error)

func (*TableWriter) WriteRow

func (tw *TableWriter) WriteRow(rowArray []string)

func (*TableWriter) WriteStringArray

func (tw *TableWriter) WriteStringArray(sa [][]string)

type Template

type Template struct {
	Name         string
	Text         string
	TextTemplate *textTemplate.Template
	Properties   Properties
}

Template is customizable to create reports from different kinds of templates.

func NewTemplate

func NewTemplate(name string, text string, delimiters *DelimiterPair, client Client) *Template

NewTemplate returns a geist.Template with the given customizations.

func (*Template) AddFuncs

func (rp *Template) AddFuncs(newFunctions textTemplate.FuncMap)

func (*Template) AddFunction

func (rp *Template) AddFunction(name string, function interface{})

func (*Template) CompileFunctions

func (rt *Template) CompileFunctions(text string) (remainder string)

func (*Template) Expand

func (rp *Template) Expand(data interface{}) (result string, err error)

func (*Template) ExpandSubreport

func (rp *Template) ExpandSubreport(name string, text string, data interface{}) (report string, err error)

func (*Template) Parse

func (rp *Template) Parse() (err error)

func (*Template) Select

func (rt *Template) Select(query string) (rs *ResultSet, err error)

Jump to

Keyboard shortcuts

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