wordcount

package
v0.0.0-...-2805226 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCloningRepository indicates that an error occurred while retrieving the remote Github.com repository.
	ErrCloningRepository = errors.New("Error while reading/cloning remote repository")
	// ErrParsingFile indicates an error while converting the source code to its Abstract Syntax Tree representation.
	ErrParsingFile = errors.New("Error while parsing source code to AST")
)

Functions

This section is empty.

Types

type Cloner

type Cloner interface {
	// Clone accesses a repository and clones it.
	Clone(url string) (Repository, error)
	// Filenames retrieves the names of the existing files on a repository.
	Filenames() ([]string, error)
	// File provides the bytes representation of a given file.
	File(name string) ([]byte, error)
}

Cloner interface is used to define a custom cloner.

type File

type File struct {
	Name    string
	Raw     []byte
	AST     *ast.File
	FileSet *token.FileSet
	Error   error
}

File represents a file on a code.Repository, and contains a raw representation and a ast.File representation.

type Miner

type Miner interface {
	// Name provides the name of the miner.
	Name() string
	// Visit applies the mining logic while traversing the Abstract Syntax Tree.
	Visit(node ast.Node) ast.Visitor
	// Results provides the mining results.
	Results() map[string]int
}

Miner interface is used to define a custom miner.

type Processor

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

Processor handles the logic to extract the word count from a remote source code repository.

func NewProcessor

func NewProcessor(config ProcessorConfig) Processor

NewProcessor creates a new Processor based on the provided configuration.

func (Processor) Extract

func (p Processor) Extract(url string) (map[string]int, error)

Extract explores the source code and applies the processor-defined miner.

type ProcessorConfig

type ProcessorConfig struct {
	Cloner Cloner
	Miner  Miner
}

ProcessorConfig defines the properties available for configuration for a Processor.

type Repository

type Repository struct {
	Name        string
	URL         string
	Hash        string
	DateCreated string
	Error       error
}

Repository holds information of a GitHub repository.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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