domain

package
v0.2.1-2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigTpl = `` /* 210-byte string literal not displayed */

ConfigTpl is a configuration file template.

View Source
const MockTpl = `` /* 1560-byte string literal not displayed */

MockTpl is a mock's template.

View Source
const (
	// URL is the repository url.
	URL = "https://github.com/suzuki-shunsuke/gomic"
)
View Source
const Version = "0.2.1-2"

Version is the gomic's version.

Variables

This section is empty.

Functions

This section is empty.

Types

type CfgReader

type CfgReader interface {
	Read(string) (Config, error)
}

CfgReader reads and parses a configuration file.

type Config

type Config struct {
	Default DefaultConfiguration
	Items   []Item
}

Config represents configuration.

type DefaultConfiguration

type DefaultConfiguration struct {
	SrcDefaultConfiguration
}

DefaultConfiguration represents default configuration.

type Dest

type Dest struct {
	Package string
	File    string
}

Dest represents generated file's configuration.

type FileSystem

type FileSystem interface {
	Exist(string) bool
	MkdirAll(string) error
	Write(string, []byte) error
	GetWriteCloser(string) (io.WriteCloser, error)
	Getwd() (string, error)
}

FileSystem abstracts operations of the file system.

type ImportSpec

type ImportSpec interface {
	Host() string
	Name() string
	Path() string
	String() string
}

ImportSpec represents an import statement.

type ImportSpecs

type ImportSpecs interface {
	Add(ImportSpec) (ImportSpec, error)
	Names() map[string]ImportSpec
	Paths() map[string]ImportSpec
}

ImportSpecs represents a collection of ImportSpec.

type Importer

type Importer interface {
	GetFileByFilePath(filePath string, mode parser.Mode) (*ast.File, error)
	GetPkgsInDir(dirPath string, filter func(os.FileInfo) bool, mode parser.Mode) (map[string]*ast.Package, error)
	GetBuildPkgInDir(dir string, mode build.ImportMode) (*build.Package, error)
	GetBuildPkgByPkgPath(pkgPath, srcDir string, mode build.ImportMode) (*build.Package, error)
}

Importer imports go's file and packages.

type Item

type Item struct {
	Src  Src
	Dest Dest
	DefaultConfiguration
}

Item represents configuration of each mock.

type Method

type Method interface {
	Name() string
	Declaration() string
	Definition() string
	ParamsStr() string
	ResultValuesStr() string
	HasResultNames() bool
	Imports() map[string]ImportSpec
	Results() []Var
	IsEllipsis() bool
}

Method represents a mock's method.

type MockTemplateArg

type MockTemplateArg interface {
	Version() string
	URL() string
	PackageName() string
	MockName() string
	Imports() [][]string
	Methods() []Method
}

MockTemplateArg is a template argument and represents a mock.

type Src

type Src struct {
	Package   string
	Interface string
	Name      string
	File      string
	Dir       string
	SrcDefaultConfiguration
}

Src represents source configuration.

type SrcDefaultConfiguration

type SrcDefaultConfiguration struct {
	InterfacePrefix string `yaml:"interface_prefix"`
	InterfaceSuffix string `yaml:"interface_suffix"`
	VendorDir       string `yaml:"vendor_dir"`
}

SrcDefaultConfiguration represents source's default configuration.

type TplWriter

type TplWriter interface {
	Write(dst, tpl string, data interface{}) error
}

TplWriter abstracts to write generated code to file.

type Var

type Var interface {
	Name() string
	Type() string
	PkgName() string
	PkgPath() string
}

Var represents a method's parameter and return value.

Jump to

Keyboard shortcuts

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