diff --git a/glide.lock b/glide.lock index a503b9522..43144c197 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: f01ea3a7c4236485de95f94f24a72e132da8aa547346a1577d5506646ad28231 -updated: 2018-06-08T10:05:57.441795-07:00 +hash: 6fa6f282ecddc833638528e7142991e81fbe33987514e2da1ece181a6470c568 +updated: 2018-06-08T11:35:55.674334-07:00 imports: - name: github.com/alexcesaro/statsd version: 7fea3f0d2fab1ad973e641e51dba45443a311a90 @@ -28,6 +28,8 @@ imports: version: 2ee87856327ba09384cabd113bc6b5d174e9ec0f - name: github.com/dgrijalva/jwt-go version: dbeaa9332f19a944acb5736b4456cfcc02140e29 +- name: github.com/etgryphon/stringUp + version: 31534ccd8cac1d3d205c906ea5722928b045ed8c - name: github.com/ghodss/yaml version: 0ca9ea5df5451ffdf184b4428c902747c2c11cd7 - name: github.com/go-playground/locales diff --git a/glide.yaml b/glide.yaml index 6e14bb1aa..e1a9351c7 100644 --- a/glide.yaml +++ b/glide.yaml @@ -65,6 +65,7 @@ import: version: 1.0 - package: github.com/rjtsdl/conform version: 1.2.1 +- package: github.com/etgryphon/stringUp testImport: # glide isn't able to mutually reconcile pinned versions of these deps - package: github.com/onsi/gomega diff --git a/vendor/github.com/etgryphon/stringUp/.gitignore b/vendor/github.com/etgryphon/stringUp/.gitignore new file mode 100644 index 000000000..e9702335c --- /dev/null +++ b/vendor/github.com/etgryphon/stringUp/.gitignore @@ -0,0 +1 @@ +.project \ No newline at end of file diff --git a/vendor/github.com/etgryphon/stringUp/README.md b/vendor/github.com/etgryphon/stringUp/README.md new file mode 100644 index 000000000..f93adf972 --- /dev/null +++ b/vendor/github.com/etgryphon/stringUp/README.md @@ -0,0 +1,8 @@ +# StringUp: Golang Extension Library for Strings! + +`StringUp` is a micro-package that has some useful string functionality for your Golang Project. Current Functions: + + + `CamelCase` - converts strings to their camel case equivalent + + Example: `this is it` => `thisIsIt`, `this\_is\_it` => `thisIsIt`, `this-is-it` => `thisIsIt` + +More work is being done...Kind of using this a dumping ground for string functions that I need in other projects diff --git a/vendor/github.com/etgryphon/stringUp/stringUp.go b/vendor/github.com/etgryphon/stringUp/stringUp.go new file mode 100644 index 000000000..42583b9b6 --- /dev/null +++ b/vendor/github.com/etgryphon/stringUp/stringUp.go @@ -0,0 +1,18 @@ +package stringUp + +import ( + "regexp" + "bytes" +) + + +var camelingRegex = regexp.MustCompile("[0-9A-Za-z]+") + +func CamelCase(src string)(string){ + byteSrc := []byte(src) + chunks := camelingRegex.FindAll(byteSrc, -1) + for idx, val := range chunks { + if idx > 0 { chunks[idx] = bytes.Title(val) } + } + return string(bytes.Join(chunks, nil)) +} diff --git a/vendor/github.com/etgryphon/stringUp/stringUp_test.go b/vendor/github.com/etgryphon/stringUp/stringUp_test.go new file mode 100644 index 000000000..6a898c41d --- /dev/null +++ b/vendor/github.com/etgryphon/stringUp/stringUp_test.go @@ -0,0 +1,55 @@ +package stringUp + +import ( + "testing" +) + +func TestCamelCased(t *testing.T) { + const cameled,upCameled = "thisIsIt", "ThisIsItBob" + if x := CamelCase(cameled); x != cameled { + t.Errorf("CamelCase(%v) = %v, want %v", cameled, x, cameled) + } + if x := CamelCase(upCameled); x != upCameled { + t.Errorf("CamelCase(%v) = %v, want %v", upCameled, x, upCameled) + } +} + +func TestCamelCaseSpaced(t *testing.T) { + const src,upSrc = "this is it", "This Is It Bob" + if x := CamelCase(src); x != "thisIsIt" { + t.Errorf("CamelCase(%v) = %v, want %v", src, x, "thisIsIt") + } + if x := CamelCase(upSrc); x != "ThisIsItBob" { + t.Errorf("CamelCase(%v) = %v, want %v", upSrc, x, "ThisIsItBob") + } +} + +func TestCamelCaseUnderscored(t *testing.T) { + const src,upSrc = "this_is_it", "This_Is_It_Bob" + if x := CamelCase(src); x != "thisIsIt" { + t.Errorf("CamelCase(%v) = %v, want %v", src, x, "thisIsIt") + } + if x := CamelCase(upSrc); x != "ThisIsItBob" { + t.Errorf("CamelCase(%v) = %v, want %v", upSrc, x, "ThisIsItBob") + } +} + +func TestCamelCaseDashed(t *testing.T) { + const src,upSrc = "this-is-it", "This-Is-It-Bob" + if x := CamelCase(src); x != "thisIsIt" { + t.Errorf("CamelCase(%v) = %v, want %v", src, x, "thisIsIt") + } + if x := CamelCase(upSrc); x != "ThisIsItBob" { + t.Errorf("CamelCase(%v) = %v, want %v", upSrc, x, "ThisIsItBob") + } +} + +func TestCamelCaseMixed(t *testing.T) { + const src,upSrc = "-this is_it", "This Is_It-Bob" + if x := CamelCase(src); x != "thisIsIt" { + t.Errorf("CamelCase(%v) = %v, want %v", src, x, "thisIsIt") + } + if x := CamelCase(upSrc); x != "ThisIsItBob" { + t.Errorf("CamelCase(%v) = %v, want %v", upSrc, x, "ThisIsItBob") + } +} \ No newline at end of file