util

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 License: GPL-3.0, GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnixSep = "/"

	WindowsSep = "\\"
)

Variables

View Source
var AcceptedExtensions = make(map[string]bool)

AcceptedExtensions has all the file extensions that are supported by Gauge for its specs

View Source
var GetConceptFiles = func() []string {
	projRoot := config.ProjectRoot
	if projRoot == "" {
		logger.Fatalf(true, "Failed to get project root.")
	}
	absPath, err := filepath.Abs(projRoot)
	if err != nil {
		logger.Fatalf(true, "Error getting absolute path. %v", err)
	}
	return FindConceptFilesIn(absPath)
}

GetConceptFiles returns the list of concept files present in the PROJECTROOT

View Source
var GetSpecFiles = func(paths []string) []string {
	var specFiles []string
	for _, path := range paths {
		if common.DirExists(path) {
			specFiles = append(specFiles, FindSpecFilesIn(path)...)
		} else if common.FileExists(path) && IsValidSpecExtension(path) {
			f, _ := filepath.Abs(path)
			specFiles = append(specFiles, f)
		}
	}
	return specFiles
}

GetSpecFiles returns the list of spec files present at the given path. If the path itself represents a spec file, it returns the same.

Functions

func ConvertPathToURI added in v0.9.4

func ConvertPathToURI(path string) lsp.DocumentURI

ConvertPathToURI - converts OS specific file paths to file uri (eg: file://example.spec).

func ConvertToBool added in v0.8.1

func ConvertToBool(value, property string, defaultValue bool) bool

func ConvertURItoFilePath added in v0.9.4

func ConvertURItoFilePath(uri lsp.DocumentURI) string

ConvertURItoFilePath - converts file uri (eg: file://example.spec) to OS specific file paths.

func Download added in v0.3.2

func Download(url, targetDir, fileName string, silent bool) (string, error)

Download fires a HTTP GET request to download a resource to target directory

func DownloadAndUnzip added in v0.3.0

func DownloadAndUnzip(downloadLink string, tempDir string) (string, error)

DownloadAndUnzip downloads the zip file from given download link and unzips it. Returns the unzipped file path.

func FindAllNestedDirs added in v0.1.3

func FindAllNestedDirs(dir string) []string

FindAllNestedDirs returns list of all nested directories in given path

func FindConceptFilesIn

func FindConceptFilesIn(dir string) []string

FindConceptFilesIn Finds the concept files in specified directory

func FindSpecFilesIn

func FindSpecFilesIn(dir string) []string

FindSpecFilesIn Finds spec files in the given directory

func GaugeFileExtensions added in v0.9.8

func GaugeFileExtensions() []string

IsGaugeFile Returns true if spec file or concept file

func GetFileContents added in v1.0.1

func GetFileContents(filepath string) (string, error)

func GetLineCount added in v0.9.8

func GetLineCount(text string) int

GetLineCount give no of lines in given text

func GetLinesFromText added in v0.9.8

func GetLinesFromText(text string) []string

GetLinesFromText gets lines of a text in an array

func GetPathToFile added in v0.1.7

func GetPathToFile(path string) string

GetPathToFile returns the path to a given file from the Project root

func GetSpecDirs added in v0.9.8

func GetSpecDirs() []string

GetSpecDirs returns the specification directory. It checks whether the environment variable for gauge_specs_dir is set. It returns 'specs' otherwise

func IsConcept added in v0.1.3

func IsConcept(path string) bool

IsConcept Returns true if concept file

func IsDir added in v0.1.3

func IsDir(path string) bool

IsDir reports whether path describes a directory.

func IsGaugeFile added in v0.9.5

func IsGaugeFile(path string) bool

IsGaugeFile Returns true if spec file or concept file

func IsProcessRunning added in v0.3.2

func IsProcessRunning(pid int) bool

IsProcessRunning checks if the process with the given process id is still running

func IsSpec added in v0.1.3

func IsSpec(path string) bool

IsSpec Returns true if spec file file

func IsValidConceptExtension

func IsValidConceptExtension(path string) bool

IsValidConceptExtension Checks if the path has a concept file extension

func IsValidSpecExtension

func IsValidSpecExtension(path string) bool

IsValidSpecExtension Checks if the path has a spec file extension

func IsWindows added in v0.1.7

func IsWindows() bool

IsWindows returns if Gauge is running on Windows

func ListContains added in v0.9.8

func ListContains(list []string, val string) bool

func NumberOfCores added in v0.1.7

func NumberOfCores() int

NumberOfCores returns the number of CPU cores on the system

func OpenFile added in v0.9.8

func OpenFile(fileName string) (io.Writer, error)

func RelPathToProjectRoot added in v0.5.0

func RelPathToProjectRoot(path string) string

func Remove added in v0.3.0

func Remove(dir string)

Remove removes all the files and directories recursively for the given path

func RemoveTempDir added in v0.3.0

func RemoveTempDir()

RemoveTempDir removes the temp dir

func SaveFile added in v0.1.7

func SaveFile(fileName string, content string, backup bool)

SaveFile saves contents at the given path

func SetWorkingDir added in v0.4.0

func SetWorkingDir(workingDir string)

SetWorkingDir sets the current working directory to specified location

Types

This section is empty.

Jump to

Keyboard shortcuts

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