-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6149506
Showing
24 changed files
with
1,175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
*.log | ||
.DS_Store | ||
doc | ||
tmp | ||
pkg | ||
*.gem | ||
*.pid | ||
coverage | ||
coverage.data | ||
build/* | ||
*.pbxuser | ||
*.mode1v3 | ||
.svn | ||
profile | ||
.console_history | ||
.sass-cache/* | ||
.rake_tasks~ | ||
*.log.lck | ||
solr/ | ||
.jhw-cache/ | ||
jhw.* | ||
*.sublime* | ||
node_modules/ | ||
dist/ | ||
generated/ | ||
.vendor/ | ||
bin/* | ||
gin-bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package flect | ||
|
||
var baseAcronyms = map[string]bool{ | ||
"OK": true, | ||
"UTF8": true, | ||
"HTML": true, | ||
"JSON": true, | ||
"JWT": true, | ||
"ID": true, | ||
"UUID": true, | ||
"SQL": true, | ||
"ACK": true, | ||
"ACL": true, | ||
"ADSL": true, | ||
"AES": true, | ||
"ANSI": true, | ||
"API": true, | ||
"ARP": true, | ||
"ATM": true, | ||
"BGP": true, | ||
"BSS": true, | ||
"CCITT": true, | ||
"CHAP": true, | ||
"CIDR": true, | ||
"CIR": true, | ||
"CLI": true, | ||
"CPE": true, | ||
"CPU": true, | ||
"CRC": true, | ||
"CRT": true, | ||
"CSMA": true, | ||
"CMOS": true, | ||
"DCE": true, | ||
"DEC": true, | ||
"DES": true, | ||
"DHCP": true, | ||
"DNS": true, | ||
"DRAM": true, | ||
"DSL": true, | ||
"DSLAM": true, | ||
"DTE": true, | ||
"DMI": true, | ||
"EHA": true, | ||
"EIA": true, | ||
"EIGRP": true, | ||
"EOF": true, | ||
"ESS": true, | ||
"FCC": true, | ||
"FCS": true, | ||
"FDDI": true, | ||
"FTP": true, | ||
"GBIC": true, | ||
"gbps": true, | ||
"GEPOF": true, | ||
"HDLC": true, | ||
"HTTP": true, | ||
"HTTPS": true, | ||
"IANA": true, | ||
"ICMP": true, | ||
"IDF": true, | ||
"IDS": true, | ||
"IEEE": true, | ||
"IETF": true, | ||
"IMAP": true, | ||
"IP": true, | ||
"IPS": true, | ||
"ISDN": true, | ||
"ISP": true, | ||
"kbps": true, | ||
"LACP": true, | ||
"LAN": true, | ||
"LAPB": true, | ||
"LAPF": true, | ||
"LLC": true, | ||
"MAC": true, | ||
"Mbps": true, | ||
"MC": true, | ||
"MDF": true, | ||
"MIB": true, | ||
"MoCA": true, | ||
"MPLS": true, | ||
"MTU": true, | ||
"NAC": true, | ||
"NAT": true, | ||
"NBMA": true, | ||
"NIC": true, | ||
"NRZ": true, | ||
"NRZI": true, | ||
"NVRAM": true, | ||
"OSI": true, | ||
"OSPF": true, | ||
"OUI": true, | ||
"PAP": true, | ||
"PAT": true, | ||
"PC": true, | ||
"PIM": true, | ||
"PCM": true, | ||
"PDU": true, | ||
"POP3": true, | ||
"POTS": true, | ||
"PPP": true, | ||
"PPTP": true, | ||
"PTT": true, | ||
"PVST": true, | ||
"RAM": true, | ||
"RARP": true, | ||
"RFC": true, | ||
"RIP": true, | ||
"RLL": true, | ||
"ROM": true, | ||
"RSTP": true, | ||
"RTP": true, | ||
"RCP": true, | ||
"SDLC": true, | ||
"SFD": true, | ||
"SFP": true, | ||
"SLARP": true, | ||
"SLIP": true, | ||
"SMTP": true, | ||
"SNA": true, | ||
"SNAP": true, | ||
"SNMP": true, | ||
"SOF": true, | ||
"SRAM": true, | ||
"SSH": true, | ||
"SSID": true, | ||
"STP": true, | ||
"SYN": true, | ||
"TDM": true, | ||
"TFTP": true, | ||
"TIA": true, | ||
"TOFU": true, | ||
"UDP": true, | ||
"URL": true, | ||
"URI": true, | ||
"USB": true, | ||
"UTP": true, | ||
"VC": true, | ||
"VLAN": true, | ||
"VLSM": true, | ||
"VPN": true, | ||
"W3C": true, | ||
"WAN": true, | ||
"WEP": true, | ||
"WiFi": true, | ||
"WPA": true, | ||
"WWW": true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package flect | ||
|
||
import ( | ||
"strings" | ||
"unicode" | ||
) | ||
|
||
func Camelize(s string) string { | ||
return New(s).Camelize() | ||
} | ||
|
||
func (i Ident) Camelize() string { | ||
var out []string | ||
for i, part := range i.parts { | ||
var x string | ||
var capped bool | ||
for _, c := range part { | ||
if unicode.IsLetter(c) || unicode.IsDigit(c) { | ||
if i == 0 { | ||
x += string(unicode.ToLower(c)) | ||
continue | ||
} | ||
if !capped { | ||
capped = true | ||
x += string(unicode.ToUpper(c)) | ||
continue | ||
} | ||
x += string(c) | ||
} | ||
} | ||
if x != "" { | ||
out = append(out, x) | ||
} | ||
} | ||
return strings.Join(out, "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package flect | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_Camelize(t *testing.T) { | ||
table := []tt{ | ||
{"", ""}, | ||
{"bob dylan", "bobDylan"}, | ||
{"widgetID", "widgetID"}, | ||
{"widget_ID", "widgetID"}, | ||
{"Widget_ID", "widgetID"}, | ||
{"Nice to see you!", "niceToSeeYou"}, | ||
{"*hello*", "hello"}, | ||
{"i've read a book! have you?", "iveReadABookHaveYou"}, | ||
{"This is `code` ok", "thisIsCodeOK"}, | ||
} | ||
|
||
for _, tt := range table { | ||
t.Run(tt.act, func(st *testing.T) { | ||
r := require.New(st) | ||
r.Equal(tt.exp, Camelize(tt.act)) | ||
r.Equal(tt.exp, Camelize(tt.exp)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package flect | ||
|
||
import "unicode" | ||
|
||
func Capitalize(s string) string { | ||
return New(s).Capitalize() | ||
} | ||
|
||
func (i Ident) Capitalize() string { | ||
var x string | ||
if len(i.parts) == 0 { | ||
return "" | ||
} | ||
x = string(unicode.ToTitle(rune(i.original[0]))) | ||
if len(i.original) > 1 { | ||
x += i.original[1:] | ||
} | ||
return x | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package flect | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_Capitalize(t *testing.T) { | ||
table := []tt{ | ||
{"", ""}, | ||
{"foo", "Foo"}, | ||
{"WidgetID", "WidgetID"}, | ||
{"widgetID", "WidgetID"}, | ||
{"widget_ID", "Widget_ID"}, | ||
{"widget ID", "Widget ID"}, | ||
} | ||
|
||
for _, tt := range table { | ||
t.Run(tt.act, func(st *testing.T) { | ||
r := require.New(st) | ||
r.Equal(tt.exp, Capitalize(tt.act)) | ||
r.Equal(tt.exp, Capitalize(tt.exp)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
mode: set | ||
github.com/gobuffalo/flect/titleize.go:8.32,10.2 1 1 | ||
github.com/gobuffalo/flect/titleize.go:12.34,14.31 2 1 | ||
github.com/gobuffalo/flect/titleize.go:22.2,22.33 1 1 | ||
github.com/gobuffalo/flect/titleize.go:14.31,17.20 3 1 | ||
github.com/gobuffalo/flect/titleize.go:20.3,20.27 1 1 | ||
github.com/gobuffalo/flect/titleize.go:17.20,19.4 1 1 | ||
github.com/gobuffalo/flect/underscore.go:8.34,10.2 1 1 | ||
github.com/gobuffalo/flect/underscore.go:12.36,14.31 2 1 | ||
github.com/gobuffalo/flect/underscore.go:25.2,25.48 1 1 | ||
github.com/gobuffalo/flect/underscore.go:14.31,16.26 2 1 | ||
github.com/gobuffalo/flect/underscore.go:21.3,21.14 1 1 | ||
github.com/gobuffalo/flect/underscore.go:16.26,17.49 1 1 | ||
github.com/gobuffalo/flect/underscore.go:17.49,19.5 1 1 | ||
github.com/gobuffalo/flect/underscore.go:21.14,23.4 1 1 | ||
github.com/gobuffalo/flect/camelize.go:8.32,10.2 1 1 | ||
github.com/gobuffalo/flect/camelize.go:12.34,14.31 2 1 | ||
github.com/gobuffalo/flect/camelize.go:35.2,35.30 1 1 | ||
github.com/gobuffalo/flect/camelize.go:14.31,17.26 3 1 | ||
github.com/gobuffalo/flect/camelize.go:31.3,31.14 1 1 | ||
github.com/gobuffalo/flect/camelize.go:17.26,18.49 1 1 | ||
github.com/gobuffalo/flect/camelize.go:18.49,19.15 1 1 | ||
github.com/gobuffalo/flect/camelize.go:23.5,23.16 1 1 | ||
github.com/gobuffalo/flect/camelize.go:28.5,28.19 1 1 | ||
github.com/gobuffalo/flect/camelize.go:19.15,21.14 2 1 | ||
github.com/gobuffalo/flect/camelize.go:23.16,26.14 3 1 | ||
github.com/gobuffalo/flect/camelize.go:31.14,33.4 1 1 | ||
github.com/gobuffalo/flect/capitalize.go:5.34,7.2 1 1 | ||
github.com/gobuffalo/flect/capitalize.go:9.36,11.23 2 1 | ||
github.com/gobuffalo/flect/capitalize.go:14.2,15.25 2 1 | ||
github.com/gobuffalo/flect/capitalize.go:18.2,18.10 1 1 | ||
github.com/gobuffalo/flect/capitalize.go:11.23,13.3 1 1 | ||
github.com/gobuffalo/flect/capitalize.go:15.25,17.3 1 1 | ||
github.com/gobuffalo/flect/ident.go:15.32,17.2 1 0 | ||
github.com/gobuffalo/flect/ident.go:19.26,26.2 2 1 | ||
github.com/gobuffalo/flect/ident.go:30.33,33.17 3 1 | ||
github.com/gobuffalo/flect/ident.go:36.2,36.54 1 1 | ||
github.com/gobuffalo/flect/ident.go:41.2,43.22 3 1 | ||
github.com/gobuffalo/flect/ident.go:82.2,84.14 2 1 | ||
github.com/gobuffalo/flect/ident.go:33.17,35.3 1 1 | ||
github.com/gobuffalo/flect/ident.go:36.54,37.31 1 1 | ||
github.com/gobuffalo/flect/ident.go:37.31,39.4 1 1 | ||
github.com/gobuffalo/flect/ident.go:43.22,57.25 2 1 | ||
github.com/gobuffalo/flect/ident.go:61.3,61.17 1 1 | ||
github.com/gobuffalo/flect/ident.go:67.3,67.51 1 1 | ||
github.com/gobuffalo/flect/ident.go:73.3,73.82 1 1 | ||
github.com/gobuffalo/flect/ident.go:78.3,80.11 3 1 | ||
github.com/gobuffalo/flect/ident.go:57.25,58.12 1 0 | ||
github.com/gobuffalo/flect/ident.go:61.17,65.12 4 1 | ||
github.com/gobuffalo/flect/ident.go:67.51,71.12 4 1 | ||
github.com/gobuffalo/flect/ident.go:73.82,76.12 3 1 | ||
github.com/gobuffalo/flect/ident.go:89.27,90.27 1 1 | ||
github.com/gobuffalo/flect/ident.go:95.2,95.27 1 1 | ||
github.com/gobuffalo/flect/ident.go:90.27,91.13 1 1 | ||
github.com/gobuffalo/flect/ident.go:91.13,93.4 1 1 | ||
github.com/gobuffalo/flect/ident.go:98.49,99.23 1 1 | ||
github.com/gobuffalo/flect/ident.go:115.2,115.10 1 1 | ||
github.com/gobuffalo/flect/ident.go:99.23,101.28 2 1 | ||
github.com/gobuffalo/flect/ident.go:104.3,104.55 1 1 | ||
github.com/gobuffalo/flect/ident.go:111.3,111.14 1 1 | ||
github.com/gobuffalo/flect/ident.go:101.28,103.4 1 1 | ||
github.com/gobuffalo/flect/ident.go:104.55,105.32 1 1 | ||
github.com/gobuffalo/flect/ident.go:108.4,109.9 2 1 | ||
github.com/gobuffalo/flect/ident.go:105.32,106.13 1 1 | ||
github.com/gobuffalo/flect/ident.go:111.14,113.4 1 1 | ||
github.com/gobuffalo/flect/pascalize.go:7.33,9.2 1 1 | ||
github.com/gobuffalo/flect/pascalize.go:11.35,13.17 2 1 | ||
github.com/gobuffalo/flect/pascalize.go:16.2,16.52 1 1 | ||
github.com/gobuffalo/flect/pascalize.go:13.17,15.3 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:8.33,10.2 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:13.32,15.2 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:18.31,19.16 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:25.2,26.18 2 0 | ||
github.com/gobuffalo/flect/pluralize.go:19.16,21.23 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:21.23,23.4 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:29.32,31.2 1 0 | ||
github.com/gobuffalo/flect/pluralize.go:34.31,35.16 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:41.2,42.18 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:35.16,37.23 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:37.23,39.4 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:46.32,49.2 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:52.32,55.2 2 0 | ||
github.com/gobuffalo/flect/pluralize.go:58.32,61.2 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:63.27,64.11 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:68.2,68.14 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:65.31,66.14 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:71.32,74.2 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:81.28,81.40 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:105.35,106.23 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:109.2,111.39 3 1 | ||
github.com/gobuffalo/flect/pluralize.go:114.2,115.39 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:120.2,120.32 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:128.2,128.35 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:131.2,132.33 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:106.23,108.3 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:111.39,113.3 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:115.39,118.3 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:120.32,121.40 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:121.40,124.4 2 1 | ||
github.com/gobuffalo/flect/pluralize.go:128.35,130.3 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:254.13,255.35 1 1 | ||
github.com/gobuffalo/flect/pluralize.go:255.35,257.3 1 1 |
Oops, something went wrong.