flect: github.com/gobuffalo/flect Index | Files | Directories

package flect

import "github.com/gobuffalo/flect"

Package flect is a new inflection engine to replace [https://github.com/markbates/inflect](https://github.com/markbates/inflect) designed to be more modular, more readable, and easier to fix issues on than the original.

Index

Package Files

acronyms.go camelize.go capitalize.go custom_data.go dasherize.go flect.go ident.go lower_upper.go ordinalize.go pascalize.go plural_rules.go pluralize.go rule.go singular_rules.go singularize.go titleize.go underscore.go version.go

Constants

const Version = "v0.0.1"

Version holds Flect version number

func AddPlural Uses

func AddPlural(suffix string, repl string)

AddPlural adds a rule that will replace the given suffix with the replacement suffix.

func AddSingular Uses

func AddSingular(ext string, repl string)

AddSingular adds a rule that will replace the given suffix with the replacement suffix.

func Camelize Uses

func Camelize(s string) string

Camelize returns a camelize version of a string

bob dylan = bobDylan
widget_id = widgetID
WidgetID = widgetID

func Capitalize Uses

func Capitalize(s string) string

Capitalize will cap the first letter of string

user = User
bob dylan = Bob dylan
widget_id = Widget_id

func Dasherize Uses

func Dasherize(s string) string

Dasherize returns an alphanumeric, lowercased, dashed string

Donald E. Knuth = donald-e-knuth
Test with + sign = test-with-sign
admin/WidgetID = admin-widget-id

func LoadAcronyms Uses

func LoadAcronyms(r io.Reader) error

LoadAcronyms loads rules from io.Reader param

func LoadInflections Uses

func LoadInflections(r io.Reader) error

LoadInflections loads rules from io.Reader param

func Ordinalize Uses

func Ordinalize(s string) string

Ordinalize converts a number to an ordinal version

42 = 42nd
45 = 45th
1 = 1st

func Pascalize Uses

func Pascalize(s string) string

Pascalize returns a string with each segment capitalized

user = User
bob dylan = BobDylan
widget_id = WidgetID

func Pluralize Uses

func Pluralize(s string) string

Pluralize returns a plural version of the string

user = users
person = people
datum = data

func Singularize Uses

func Singularize(s string) string

Singularize returns a singular version of the string

users = user
data = datum
people = person

func Titleize Uses

func Titleize(s string) string

Titleize will capitalize the start of each part

"Nice to see you!" = "Nice To See You!"
"i've read a book! have you?" = "I've Read A Book! Have You?"
"This is `code` ok" = "This Is `code` OK"

func Underscore Uses

func Underscore(s string) string

Underscore a string

bob dylan = bob_dylan
Nice to see you! = nice_to_see_you
widgetID = widget_id

type CustomDataParser Uses

type CustomDataParser func(io.Reader) error

CustomDataParser are functions that parse data like acronyms or plurals in the shape of a io.Reader it receives.

type Ident Uses

type Ident struct {
    Original string
    Parts    []string
}

Ident represents the string and it's parts

func New Uses

func New(s string) Ident

New creates a new Ident from the string

func (Ident) Camelize Uses

func (i Ident) Camelize() Ident

Camelize returns a camelize version of a string

bob dylan = bobDylan
widget_id = widgetID
WidgetID = widgetID

func (Ident) Capitalize Uses

func (i Ident) Capitalize() Ident

Capitalize will cap the first letter of string

user = User
bob dylan = Bob dylan
widget_id = Widget_id

func (Ident) Dasherize Uses

func (i Ident) Dasherize() Ident

Dasherize returns an alphanumeric, lowercased, dashed string

Donald E. Knuth = donald-e-knuth
Test with + sign = test-with-sign
admin/WidgetID = admin-widget-id

func (Ident) MarshalText Uses

func (i Ident) MarshalText() ([]byte, error)

MarshalText marshals Ident into byte array

func (Ident) Ordinalize Uses

func (i Ident) Ordinalize() Ident

Ordinalize converts a number to an ordinal version

42 = 42nd
45 = 45th
1 = 1st

func (Ident) Pascalize Uses

func (i Ident) Pascalize() Ident

Pascalize returns a string with each segment capitalized

user = User
bob dylan = BobDylan
widget_id = WidgetID

func (Ident) Pluralize Uses

func (i Ident) Pluralize() Ident

Pluralize returns a plural version of the string

user = users
person = people
datum = data

func (Ident) Singularize Uses

func (i Ident) Singularize() Ident

Singularize returns a singular version of the string

users = user
data = datum
people = person

func (Ident) String Uses

func (i Ident) String() string

String implements fmt.Stringer and returns the original string

func (Ident) Titleize Uses

func (i Ident) Titleize() Ident

Titleize will capitalize the start of each part

"Nice to see you!" = "Nice To See You!"
"i've read a book! have you?" = "I've Read A Book! Have You?"
"This is `code` ok" = "This Is `code` OK"

func (Ident) ToLower Uses

func (i Ident) ToLower() Ident

ToLower is a convience wrapper for strings.ToLower

func (Ident) ToUpper Uses

func (i Ident) ToUpper() Ident

ToUpper is a convience wrapper for strings.ToUpper

func (Ident) Underscore Uses

func (i Ident) Underscore() Ident

Underscore a string

bob dylan = bob_dylan
Nice to see you! = nice_to_see_you
widgetID = widget_id

func (*Ident) UnmarshalText Uses

func (i *Ident) UnmarshalText(data []byte) error

UnmarshalText unmarshalls byte array into the Ident

Directories

PathSynopsis
name

Package flect imports 15 packages (graph) and is imported by 6 packages. Updated 2018-11-14. Refresh now. Tools for package owners.