Documentation
¶
Overview ¶
Package name provides functionality for handling the URL path of a releaser. It contains a type Path that represents the URL path of a releaser and methods to validate and retrieve the well-known styled name of the releaser. It also contains a map of releasers and their well-known styled names.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPath = errors.New("the path contains invalid characters")
Functions ¶
func Humanize ¶
Humanize deobfuscates the URL path and returns the formatted, human-readable group name. If the URL path contains invalid characters then an error is returned.
Example ¶
package main
import (
"fmt"
"github.com/Defacto2/releaser/name"
)
func main() {
s, _ := name.Humanize("defacto2")
fmt.Println(s)
s, _ = name.Humanize("razor-1911-demo")
fmt.Println(s)
s, _ = name.Humanize("razor-1911-demo*trsi")
fmt.Println(s)
x, err := name.Humanize("razor-1911-demo#trsi")
fmt.Printf("%q, %s\n", x, err) // print the quoted x string and any error
}
Output: defacto2 razor 1911 demo razor 1911 demo, trsi "", the path contains invalid characters
Types ¶
type List ¶
A List is a map of releasers and their well-known styled names.
func Special ¶
func Special() List
Special returns the list of styled names that use special mix or all lower or upper casing.
Example ¶
package main
import (
"fmt"
"github.com/Defacto2/releaser/name"
)
func main() {
find := name.Path("surprise-productions")
for key, val := range name.Special() {
if key == find {
fmt.Println(val)
}
}
}
Output: Surprise! Productions
type Path ¶
type Path string
A Path is the partial URL path of the releaser.
func Obfuscate ¶
Obfuscate formats the named string to be used as a URL path.
Example:
Obfuscate("ACiD Productions") = "acid-productions"
Obfuscate("Razor 1911 Demo & Skillion") = "razor-1911-demo-ampersand-skillion"
Obfuscate("TDU-Jam!") = "tdu_jam"
func (Path) String ¶
String returns the well-known styled name of the releaser if it exists in the names, lowercase or uppercase lists. Otherwise it returns an empty string.
Example:
name.Path("acid-productions").String() = "ACiD Productions"
name.Path("razor-1911").String() = "" // unlisted
func (Path) Valid ¶
Valid returns true if the URL path uses valid characters. Valid URL paths are all lowercase and contain only alphanumeric characters, dashes, underscores, ampersands and asterisks.
Example:
name.Path("acid-productions").Valid() = true
name.Path("acid-productions!").Valid() = false