mirror of
https://github.com/yudai/gotty.git
synced 2026-01-18 15:35:30 +01:00
Check config file syntax
This commit is contained in:
parent
62f5d4aaf3
commit
83923b6f39
8 changed files with 23 additions and 240 deletions
3
Godeps/_workspace/src/github.com/fatih/camelcase/.travis.yml
generated
vendored
3
Godeps/_workspace/src/github.com/fatih/camelcase/.travis.yml
generated
vendored
|
|
@ -1,3 +0,0 @@
|
|||
language: go
|
||||
go: 1.4
|
||||
|
||||
20
Godeps/_workspace/src/github.com/fatih/camelcase/LICENSE.md
generated
vendored
20
Godeps/_workspace/src/github.com/fatih/camelcase/LICENSE.md
generated
vendored
|
|
@ -1,20 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Fatih Arslan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
40
Godeps/_workspace/src/github.com/fatih/camelcase/README.md
generated
vendored
40
Godeps/_workspace/src/github.com/fatih/camelcase/README.md
generated
vendored
|
|
@ -1,40 +0,0 @@
|
|||
# CamelCase [](http://godoc.org/github.com/fatih/camelcase) [](https://travis-ci.org/fatih/camelcase)
|
||||
|
||||
CamelCase is a Golang (Go) package to split the words of a camelcase type
|
||||
string into a slice of words. It can be used to convert a camelcase word (lower
|
||||
or upper case) into any type of word.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
go get github.com/fatih/camelcase
|
||||
```
|
||||
|
||||
## Usage and examples
|
||||
|
||||
```go
|
||||
splitted := camelcase.Split("GolangPackage")
|
||||
|
||||
fmt.Println(splitted[0], splitted[1]) // prints: "Golang", "Package"
|
||||
```
|
||||
|
||||
Both lower camel case and upper camel case are supported. For more info please
|
||||
check: [http://en.wikipedia.org/wiki/CamelCase](http://en.wikipedia.org/wiki/CamelCase)
|
||||
|
||||
Below are some example cases:
|
||||
|
||||
```
|
||||
lowercase => ["lowercase"]
|
||||
Class => ["Class"]
|
||||
MyClass => ["My", "Class"]
|
||||
MyC => ["My", "C"]
|
||||
HTML => ["HTML"]
|
||||
PDFLoader => ["PDF", "Loader"]
|
||||
AString => ["A", "String"]
|
||||
SimpleXMLParser => ["Simple", "XML", "Parser"]
|
||||
vimRPCPlugin => ["vim", "RPC", "Plugin"]
|
||||
GL11Version => ["GL", "11", "Version"]
|
||||
99Bottles => ["99", "Bottles"]
|
||||
May5 => ["May", "5"]
|
||||
BFG9000 => ["BFG", "9000"]
|
||||
```
|
||||
91
Godeps/_workspace/src/github.com/fatih/camelcase/camelcase.go
generated
vendored
91
Godeps/_workspace/src/github.com/fatih/camelcase/camelcase.go
generated
vendored
|
|
@ -1,91 +0,0 @@
|
|||
// Package camelcase is a micro package to split the words of a camelcase type
|
||||
// string into a slice of words.
|
||||
package camelcase
|
||||
|
||||
import "unicode"
|
||||
|
||||
// Split splits the camelcase word and returns a list of words. It also
|
||||
// supports digits. Both lower camel case and upper camel case are supported.
|
||||
// For more info please check: http://en.wikipedia.org/wiki/CamelCase
|
||||
//
|
||||
// Below are some example cases:
|
||||
// lowercase => ["lowercase"]
|
||||
// Class => ["Class"]
|
||||
// MyClass => ["My", "Class"]
|
||||
// MyC => ["My", "C"]
|
||||
// HTML => ["HTML"]
|
||||
// PDFLoader => ["PDF", "Loader"]
|
||||
// AString => ["A", "String"]
|
||||
// SimpleXMLParser => ["Simple", "XML", "Parser"]
|
||||
// vimRPCPlugin => ["vim", "RPC", "Plugin"]
|
||||
// GL11Version => ["GL", "11", "Version"]
|
||||
// 99Bottles => ["99", "Bottles"]
|
||||
// May5 => ["May", "5"]
|
||||
// BFG9000 => ["BFG", "9000"]
|
||||
func Split(src string) []string {
|
||||
if src == "" {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
splitIndex := []int{}
|
||||
for i, r := range src {
|
||||
// we don't care about first index
|
||||
if i == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// search till we find an upper case
|
||||
if unicode.IsLower(r) {
|
||||
continue
|
||||
}
|
||||
|
||||
prevRune := rune(src[i-1])
|
||||
|
||||
// for cases like: GL11Version, BFG9000
|
||||
if unicode.IsDigit(r) && !unicode.IsDigit(prevRune) {
|
||||
splitIndex = append(splitIndex, i)
|
||||
continue
|
||||
}
|
||||
|
||||
if !unicode.IsDigit(r) && !unicode.IsUpper(prevRune) {
|
||||
// for cases like: MyC
|
||||
if i+1 == len(src) {
|
||||
splitIndex = append(splitIndex, i)
|
||||
continue
|
||||
}
|
||||
|
||||
// for cases like: SimpleXMLParser, eclipseRCPExt
|
||||
if unicode.IsUpper(rune(src[i+1])) {
|
||||
splitIndex = append(splitIndex, i)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// If the next char is lower case, we have found a split index
|
||||
if i+1 != len(src) && unicode.IsLower(rune(src[i+1])) {
|
||||
splitIndex = append(splitIndex, i)
|
||||
}
|
||||
}
|
||||
|
||||
// nothing to split, such as "hello", "Class", "HTML"
|
||||
if len(splitIndex) == 0 {
|
||||
return []string{src}
|
||||
}
|
||||
|
||||
// now split the input string into pieces
|
||||
splitted := make([]string, len(splitIndex)+1)
|
||||
for i := 0; i < len(splitIndex)+1; i++ {
|
||||
if i == 0 {
|
||||
// first index
|
||||
splitted[i] = src[:splitIndex[0]]
|
||||
} else if i == len(splitIndex) {
|
||||
// last index
|
||||
splitted[i] = src[splitIndex[i-1]:]
|
||||
} else {
|
||||
// between first and last index
|
||||
splitted[i] = src[splitIndex[i-1]:splitIndex[i]]
|
||||
}
|
||||
}
|
||||
|
||||
return splitted
|
||||
}
|
||||
35
Godeps/_workspace/src/github.com/fatih/camelcase/camelcase_test.go
generated
vendored
35
Godeps/_workspace/src/github.com/fatih/camelcase/camelcase_test.go
generated
vendored
|
|
@ -1,35 +0,0 @@
|
|||
package camelcase
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSplit(t *testing.T) {
|
||||
var testCases = []struct {
|
||||
input string
|
||||
output []string
|
||||
}{
|
||||
{input: "", output: []string{}},
|
||||
{input: "lowercase", output: []string{"lowercase"}},
|
||||
{input: "Class", output: []string{"Class"}},
|
||||
{input: "MyClass", output: []string{"My", "Class"}},
|
||||
{input: "MyC", output: []string{"My", "C"}},
|
||||
{input: "HTML", output: []string{"HTML"}},
|
||||
{input: "PDFLoader", output: []string{"PDF", "Loader"}},
|
||||
{input: "AString", output: []string{"A", "String"}},
|
||||
{input: "SimpleXMLParser", output: []string{"Simple", "XML", "Parser"}},
|
||||
{input: "vimRPCPlugin", output: []string{"vim", "RPC", "Plugin"}},
|
||||
{input: "GL11Version", output: []string{"GL", "11", "Version"}},
|
||||
{input: "99Bottles", output: []string{"99", "Bottles"}},
|
||||
{input: "May5", output: []string{"May", "5"}},
|
||||
{input: "BFG9000", output: []string{"BFG", "9000"}},
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
res := Split(c.input)
|
||||
if !reflect.DeepEqual(res, c.output) {
|
||||
t.Errorf("input: '%s'\n\twant: %v\n\tgot : %v\n", c.input, c.output, res)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue