...

Source file src/github.com/gobuffalo/flect/flect.go

Documentation: github.com/gobuffalo/flect

     1  /*
     2  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.
     3  */
     4  package flect
     5  
     6  import (
     7  	"strings"
     8  	"unicode"
     9  )
    10  
    11  var spaces = []rune{'_', ' ', ':', '-', '/'}
    12  
    13  func isSpace(c rune) bool {
    14  	for _, r := range spaces {
    15  		if r == c {
    16  			return true
    17  		}
    18  	}
    19  	return unicode.IsSpace(c)
    20  }
    21  
    22  func xappend(a []string, ss ...string) []string {
    23  	for _, s := range ss {
    24  		s = strings.TrimSpace(s)
    25  		for _, x := range spaces {
    26  			s = strings.Trim(s, string(x))
    27  		}
    28  		if _, ok := baseAcronyms[strings.ToUpper(s)]; ok {
    29  			s = strings.ToUpper(s)
    30  		}
    31  		if s != "" {
    32  			a = append(a, s)
    33  		}
    34  	}
    35  	return a
    36  }
    37  
    38  func abs(x int) int {
    39  	if x < 0 {
    40  		return -x
    41  	}
    42  	return x
    43  }
    44  

View as plain text