You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. INSTALLATION
  2. go get bitbucket.org/pkg/inflect
  3. PACKAGE
  4. package inflect
  5. FUNCTIONS
  6. func AddAcronym(word string)
  7. func AddHuman(suffix, replacement string)
  8. func AddIrregular(singular, plural string)
  9. func AddPlural(suffix, replacement string)
  10. func AddSingular(suffix, replacement string)
  11. func AddUncountable(word string)
  12. func Asciify(word string) string
  13. func Camelize(word string) string
  14. func CamelizeDownFirst(word string) string
  15. func Capitalize(word string) string
  16. func Dasherize(word string) string
  17. func ForeignKey(word string) string
  18. func ForeignKeyCondensed(word string) string
  19. func Humanize(word string) string
  20. func Ordinalize(word string) string
  21. func Parameterize(word string) string
  22. func ParameterizeJoin(word, sep string) string
  23. func Pluralize(word string) string
  24. func Singularize(word string) string
  25. func Tableize(word string) string
  26. func Titleize(word string) string
  27. func Typeify(word string) string
  28. func Uncountables() map[string]bool
  29. func Underscore(word string) string
  30. TYPES
  31. type Rule struct {
  32. // contains filtered or unexported fields
  33. }
  34. used by rulesets
  35. type Ruleset struct {
  36. // contains filtered or unexported fields
  37. }
  38. a Ruleset is the config of pluralization rules
  39. you can extend the rules with the Add* methods
  40. func NewDefaultRuleset() *Ruleset
  41. create a new ruleset and load it with the default
  42. set of common English pluralization rules
  43. func NewRuleset() *Ruleset
  44. create a blank ruleset. Unless you are going to
  45. build your own rules from scratch you probably
  46. won't need this and can just use the defaultRuleset
  47. via the global inflect.* methods
  48. func (rs *Ruleset) AddAcronym(word string)
  49. if you use acronym you may need to add them to the ruleset
  50. to prevent Underscored words of things like "HTML" coming out
  51. as "h_t_m_l"
  52. func (rs *Ruleset) AddHuman(suffix, replacement string)
  53. Human rules are applied by humanize to show more friendly
  54. versions of words
  55. func (rs *Ruleset) AddIrregular(singular, plural string)
  56. Add any inconsistant pluralizing/sinularizing rules
  57. to the set here.
  58. func (rs *Ruleset) AddPlural(suffix, replacement string)
  59. add a pluralization rule
  60. func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool)
  61. add a pluralization rule with full string match
  62. func (rs *Ruleset) AddSingular(suffix, replacement string)
  63. add a singular rule
  64. func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool)
  65. same as AddSingular but you can set `exact` to force
  66. a full string match
  67. func (rs *Ruleset) AddUncountable(word string)
  68. add a word to this ruleset that has the same singular and plural form
  69. for example: "rice"
  70. func (rs *Ruleset) Asciify(word string) string
  71. transforms latin characters like é -> e
  72. func (rs *Ruleset) Camelize(word string) string
  73. "dino_party" -> "DinoParty"
  74. func (rs *Ruleset) CamelizeDownFirst(word string) string
  75. same as Camelcase but with first letter downcased
  76. func (rs *Ruleset) Capitalize(word string) string
  77. uppercase first character
  78. func (rs *Ruleset) Dasherize(word string) string
  79. "SomeText" -> "some-text"
  80. func (rs *Ruleset) ForeignKey(word string) string
  81. an underscored foreign key name "Person" -> "person_id"
  82. func (rs *Ruleset) ForeignKeyCondensed(word string) string
  83. a foreign key (with an underscore) "Person" -> "personid"
  84. func (rs *Ruleset) Humanize(word string) string
  85. First letter of sentance captitilized
  86. Uses custom friendly replacements via AddHuman()
  87. func (rs *Ruleset) Ordinalize(str string) string
  88. "1031" -> "1031st"
  89. func (rs *Ruleset) Parameterize(word string) string
  90. param safe dasherized names like "my-param"
  91. func (rs *Ruleset) ParameterizeJoin(word, sep string) string
  92. param safe dasherized names with custom seperator
  93. func (rs *Ruleset) Pluralize(word string) string
  94. returns the plural form of a singular word
  95. func (rs *Ruleset) Singularize(word string) string
  96. returns the singular form of a plural word
  97. func (rs *Ruleset) Tableize(word string) string
  98. Rails style pluralized table names: "SuperPerson" -> "super_people"
  99. func (rs *Ruleset) Titleize(word string) string
  100. Captitilize every word in sentance "hello there" -> "Hello There"
  101. func (rs *Ruleset) Typeify(word string) string
  102. "something_like_this" -> "SomethingLikeThis"
  103. func (rs *Ruleset) Uncountables() map[string]bool
  104. func (rs *Ruleset) Underscore(word string) string
  105. lowercase underscore version "BigBen" -> "big_ben"