Fnlb was moved to its own repo: fnproject/lb (#702)

* Fnlb was moved to its own repo: fnproject/lb

* Clean up fnlb leftovers

* Newer deps
This commit is contained in:
Denis Makogon
2018-01-23 00:17:29 +02:00
committed by Reed Allman
parent 4ffa3d5005
commit d3be603e54
8310 changed files with 457462 additions and 1749312 deletions

View File

@@ -1 +1,3 @@
secrets.yml
vendor
Godeps

View File

@@ -17,8 +17,8 @@ package swag
import (
"io/ioutil"
"os"
"path/filepath"
"path"
"path/filepath"
"runtime"
"testing"
@@ -75,7 +75,7 @@ func TestFindPackage(t *testing.T) {
os.RemoveAll(pth2)
}()
searchPath := pth + string(filepath.ListSeparator) + pth2
searchPath := pth + string(filepath.ListSeparator) + pth2
// finds package when real name mentioned
pkg := FindInSearchPath(searchPath, "foo/bar")
assert.NotEmpty(t, pkg)

View File

@@ -20,6 +20,7 @@ import (
"regexp"
"sort"
"strings"
"sync"
"unicode"
)
@@ -40,6 +41,7 @@ var commonInitialisms = map[string]bool{
"IP": true,
"JSON": true,
"LHS": true,
"OAI": true,
"QPS": true,
"RAM": true,
"RHS": true,
@@ -66,7 +68,9 @@ var commonInitialisms = map[string]bool{
}
var initialisms []string
func init() {
var once sync.Once
func sortInitialisms() {
for k := range commonInitialisms {
initialisms = append(initialisms, k)
}
@@ -163,8 +167,9 @@ func split(str string) (words []string) {
// Split when uppercase is found (needed for Snake)
str = rex1.ReplaceAllString(str, " $1")
// check if consecutive single char things make up an initialism
// check if consecutive single char things make up an initialism
once.Do(sortInitialisms)
for _, k := range initialisms {
str = strings.Replace(str, rex1.ReplaceAllString(k, " $1"), " "+k, -1)
}
@@ -189,12 +194,26 @@ func lower(str string) string {
return strings.ToLower(trim(str))
}
// Camelize an uppercased word
func Camelize(word string) (camelized string) {
for pos, ru := range word {
if pos > 0 {
camelized += string(unicode.ToLower(ru))
} else {
camelized += string(unicode.ToUpper(ru))
}
}
return
}
// ToFileName lowercases and underscores a go type name
func ToFileName(name string) string {
var out []string
for _, w := range split(name) {
out = append(out, lower(w))
}
return strings.Join(out, "_")
}
@@ -328,6 +347,13 @@ func IsZero(data interface{}) bool {
return false
}
// AddInitialisms add additional initialisms
func AddInitialisms(words ...string) {
for _, word := range words {
commonInitialisms[upper(word)] = true
}
}
// CommandLineOptionsGroup represents a group of user-defined command line options
type CommandLineOptionsGroup struct {
ShortDescription string

View File

@@ -29,6 +29,10 @@ type translationSample struct {
func titleize(s string) string { return strings.ToTitle(s[:1]) + lower(s[1:]) }
func init() {
AddInitialisms("elb", "cap", "capwd", "wd")
}
func TestToGoName(t *testing.T) {
samples := []translationSample{
{"sample text", "SampleText"},
@@ -39,6 +43,7 @@ func TestToGoName(t *testing.T) {
{"findThingById", "FindThingByID"},
{"日本語sample 2 Text", "X日本語sample2Text"},
{"日本語findThingById", "X日本語findThingByID"},
{"findTHINGSbyID", "FindTHINGSbyID"},
}
for k := range commonInitialisms {
@@ -122,8 +127,16 @@ func TestToFileName(t *testing.T) {
samples := []translationSample{
{"SampleText", "sample_text"},
{"FindThingByID", "find_thing_by_id"},
{"CAPWD.folwdBylc", "capwd_folwd_bylc"},
{"CAPWDfolwdBylc", "capwdfolwd_bylc"},
{"CAP_WD_folwdBylc", "cap_wd_folwd_bylc"},
{"TypeOAI_alias", "type_oai_alias"},
{"Type_OAI_alias", "type_oai_alias"},
{"Type_OAIAlias", "type_oai_alias"},
{"ELB.HTTPLoadBalancer", "elb_http_load_balancer"},
{"elbHTTPLoadBalancer", "elb_http_load_balancer"},
{"ELBHTTPLoadBalancer", "elb_http_load_balancer"},
}
for k := range commonInitialisms {
samples = append(samples,
translationSample{"Sample" + k + "Text", "sample_" + lower(k) + "_text"},
@@ -139,6 +152,7 @@ func TestToCommandName(t *testing.T) {
samples := []translationSample{
{"SampleText", "sample-text"},
{"FindThingByID", "find-thing-by-id"},
{"elbHTTPLoadBalancer", "elb-http-load-balancer"},
}
for k := range commonInitialisms {
@@ -156,6 +170,7 @@ func TestToHumanName(t *testing.T) {
samples := []translationSample{
{"SampleText", "sample text"},
{"FindThingByID", "find thing by ID"},
{"elbHTTPLoadBalancer", "elb HTTP load balancer"},
}
for k := range commonInitialisms {
@@ -173,6 +188,7 @@ func TestToJSONName(t *testing.T) {
samples := []translationSample{
{"SampleText", "sampleText"},
{"FindThingByID", "findThingById"},
{"elbHTTPLoadBalancer", "elbHttpLoadBalancer"},
}
for k := range commonInitialisms {