Documentation
¶
Overview ¶
Package srcscan scans directory trees for source code packages.
Index ¶
- Variables
- func UnitType(unit Unit) string
- type BowerComponent
- type Config
- type DirMatcher
- type FileHasSuffix
- type FileInDir
- type FileMatcher
- type FileSuffixInDir
- type GoPackage
- type GoPackageConfig
- type JavaProject
- type MarshalableUnit
- type NPMPackage
- type NPMPackageConfig
- type Profile
- type PythonModule
- type PythonPackage
- type RubyApp
- type RubyConfig
- type RubyFile
- type RubyGem
- type Unit
- type Units
Constants ¶
This section is empty.
Variables ¶
var AllProfiles = []Profile{ Profile{ Name: "NPM package", Dir: FileInDir{"package.json"}, Unit: readNPMPackage, }, Profile{ Name: "Bower component", Dir: FileInDir{"bower.json"}, Unit: readBowerComponent, }, Profile{ Name: "Python package and module", TopLevelOnly: true, Dir: FileInDir{"__init__.py"}, File: FileHasSuffix{".py"}, Unit: func(abspath, relpath string, config Config, info os.FileInfo) Unit { if info.IsDir() { return &PythonPackage{relpath} } else { return &PythonModule{relpath} } }, }, Profile{ Name: "Go package", Dir: FileSuffixInDir{".go"}, Unit: readGoPackage, }, Profile{ Name: "Java Maven project", Dir: FileInDir{"pom.xml"}, Unit: readJavaMavenProject, }, Profile{ Name: "Ruby Gem", Dir: FileSuffixInDir{".gemspec"}, Unit: readRubyGem, }, Profile{ Name: "Ruby app", Dir: FileInDir{"config.ru"}, Unit: readRubyApp, }, Profile{ Name: "Ruby file", File: FileHasSuffix{".rb"}, Unit: func(abspath, relpath string, config Config, info os.FileInfo) Unit { return &RubyFile{relpath} }, }, }
var Default = Config{ SkipDirs: []string{"node_modules", "vendor", "testdata", "site-packages", "bower_components"}, NPMPackage: NPMPackageConfig{ TestDirs: []string{"test", "tests", "spec", "specs", "unit", "mocha", "karma"}, TestSuffixes: []string{"test.js", "tests.js", "spec.js", "specs.js"}, SupportDirs: []string{"build_support", "testdata"}, SupportFilenames: []string{"Gruntfile.js", "build.js", "Makefile.dryice.js", "build.config.js"}, ExampleDirs: []string{"example", "examples", "sample", "samples", "doc", "docs", "demo", "demos"}, ScriptDirs: []string{"bin", "script", "scripts", "tool", "tools"}, GeneratedDirs: []string{"build", "dist", "pkg"}, GeneratedSuffixes: []string{".min.js", "-min.js", ".optimized.js", "-optimized.js"}, VendorDirs: []string{"vendor", "bower_components", "node_modules", "assets", "public", "static", "resources", "dep", "deps"}, }, GoPackage: GoPackageConfig{ BuildContext: build.Default, }, Ruby: RubyConfig{ TestDirs: []string{"spec", "specs", "test", "tests"}, GemSrcDirs: []string{"lib"}, AppSrcDirs: []string{"app", "lib", "config", "db"}, }, }
Functions ¶
Types ¶
type BowerComponent ¶
type BowerComponent struct { Dir string BowerJSON json.RawMessage `json:",omitempty"` }
BowerComponent represents a node.js package.
func (*BowerComponent) Path ¶
func (u *BowerComponent) Path() string
Path returns the directory containing the bower.json file.
type Config ¶
type Config struct { // Base is the base directory that all source unit paths are made relative to. Paths within the // concrete source unit structs are relative to the source unit path, not Base. If Base is the // empty string, the current working directory is used. Base string // Profiles is the list of profiles to use when scanning for source units. If nil, // AllProfiles is used. Profiles []Profile // SkipDirs is a list of names of directories that are skipped while scanning. SkipDirs []string // PathIndependent, if true, indicates that all filesystem paths should be relativized, if // possible, or else cleared. PathIndependent bool NPMPackage NPMPackageConfig GoPackage GoPackageConfig Ruby RubyConfig }
Config specifies options for Scan.
type DirMatcher ¶
type FileHasSuffix ¶
type FileHasSuffix struct{ Suffix string }
func (FileHasSuffix) FileMatches ¶
func (c FileHasSuffix) FileMatches(path string) bool
type FileInDir ¶
type FileInDir struct{ Filename string }
FileInDir matches directories containing a file with the specified name.
type FileMatcher ¶
type FileSuffixInDir ¶
type FileSuffixInDir struct{ Suffix string }
FileSuffixInDir matches directories containing a file with the specified filename suffix.
func (FileSuffixInDir) DirMatches ¶
func (c FileSuffixInDir) DirMatches(path string, filenames []string) bool
type GoPackageConfig ¶
type JavaProject ¶
JavaProject represents a Java project.
func (*JavaProject) Path ¶
func (u *JavaProject) Path() string
Path returns the directory that immediately contains the Maven pom.xml.
type MarshalableUnit ¶
type MarshalableUnit struct {
Unit Unit
}
func (*MarshalableUnit) MarshalJSON ¶
func (mu *MarshalableUnit) MarshalJSON() (data []byte, err error)
func (*MarshalableUnit) UnmarshalJSON ¶
func (mu *MarshalableUnit) UnmarshalJSON(data []byte) (err error)
type NPMPackage ¶
type NPMPackage struct { Dir string PackageJSON json.RawMessage `json:",omitempty"` LibFiles []string `json:",omitempty"` ScriptFiles []string `json:",omitempty"` SupportFiles []string `json:",omitempty"` ExampleFiles []string `json:",omitempty"` TestFiles []string `json:",omitempty"` VendorFiles []string `json:",omitempty"` GeneratedFiles []string `json:",omitempty"` }
NPMPackage represents an NPM package.
func (*NPMPackage) Path ¶
func (u *NPMPackage) Path() string
Path returns the directory containing the package.json file.
type NPMPackageConfig ¶
type Profile ¶
type Profile struct { // Name describes the source unit matched by this Profile. Name string Dir DirMatcher File FileMatcher TopLevelOnly bool Unit func(abspath, relpath string, config Config, info os.FileInfo) Unit }
Profile represents criteria for a source unit and instructions on how to create it. For example, a simple profile might represent the following: "if there is a directory with a package.json file, designate the directory as a node.js package and include all *.js files in its subdirectories."
type PythonModule ¶
type PythonModule struct {
File string
}
PythonPackage represents a Python package.
func (*PythonModule) Path ¶
func (u *PythonModule) Path() string
type PythonPackage ¶
type PythonPackage struct {
Dir string
}
PythonPackage represents a Python package.
func (*PythonPackage) Path ¶
func (u *PythonPackage) Path() string
Path returns the directory immediately containing the Python package.
type RubyConfig ¶
type RubyFile ¶
type RubyFile struct {
File string
}
individual Ruby file (collected when there is no Gemfile)
type RubyGem ¶
type RubyGem struct { Dir string Name string GemSpecFile string SrcFiles []string TestFiles []string }
RubyGem represents a Ruby Gem.