Skip to content

Commit

Permalink
reformated
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Mar 5, 2018
1 parent b241902 commit c01c516
Show file tree
Hide file tree
Showing 48 changed files with 15 additions and 32 deletions.
Empty file modified CHANGELOG.md
100755 → 100644
Empty file.
Empty file modified LICENSE.txt
100755 → 100644
Empty file.
Empty file modified NOTICE.txt
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified batch_limiter.go
100755 → 100644
Empty file.
Empty file modified batch_limiter_test.go
100755 → 100644
Empty file.
Empty file modified collections.go
100755 → 100644
Empty file.
Empty file modified collections_test.go
100755 → 100644
Empty file.
Empty file modified context.go
100755 → 100644
Empty file.
Empty file modified context_test.go
100755 → 100644
Empty file.
Empty file modified converter.go
100755 → 100644
Empty file.
Empty file modified converter_test.go
100755 → 100644
Empty file.
Empty file modified decoder.go
100755 → 100644
Empty file.
Empty file modified decoder_test.go
100755 → 100644
Empty file.
Empty file modified doc.go
100755 → 100644
Empty file.
Empty file modified encoder.go
100755 → 100644
Empty file.
Empty file modified encoder_test.go
100755 → 100644
Empty file.
Empty file modified file_logger.go
100755 → 100644
Empty file.
Empty file modified file_logger_test.go
100755 → 100644
Empty file.
Empty file modified function_util.go
100755 → 100644
Empty file.
Empty file modified function_util_test.go
100755 → 100644
Empty file.
Empty file modified iterator.go
100755 → 100644
Empty file.
Empty file modified iterator_test.go
100755 → 100644
Empty file.
Empty file modified log_message.go
100755 → 100644
Empty file.
Empty file modified macro.go
100755 → 100644
Empty file.
Empty file modified macro_test.go
100755 → 100644
Empty file.
Empty file modified mime_type.go
100755 → 100644
Empty file.
Empty file modified predicate.go
100755 → 100644
Empty file.
Empty file modified predicates.go
100755 → 100644
Empty file.
Empty file modified service_router.go
100755 → 100644
Empty file.
Empty file modified service_router_test.go
100755 → 100644
Empty file.
4 changes: 1 addition & 3 deletions stack_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ func CallerDirectory(callerIndex int) string {
return parent
}



func hasMatch(target string, candidates ...string) bool {
for _, candidate := range candidates {
if strings.HasSuffix(target, candidate) {
Expand Down Expand Up @@ -53,4 +51,4 @@ func DiscoverCaller(offset, maxDepth int, ignoreFiles ...string) (string, string
callerName := caller.Name()
dotPosition := strings.LastIndex(callerName, ".")
return filename, callerName[dotPosition+1:], line
}
}
Empty file modified struct_helper.go
100755 → 100644
Empty file.
Empty file modified struct_helper_test.go
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion time_format.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func GetTimeLayout(input interface{}) string {
return DateFormatToLayout(value)
}


case map[string]interface{}:
if value, found := settings[DateLayoutKeyword]; found {
return AsString(value)
Expand Down
Empty file modified time_format_test.go
100755 → 100644
Empty file.
32 changes: 12 additions & 20 deletions tokenizer.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func (m IntMatcher) Match(input string, offset int) (matched int) {
return i
}


//LiteralMatcher represents a matcher that finds any literals in the input
type LiteralMatcher struct{}

Expand Down Expand Up @@ -166,52 +165,50 @@ func (m IdMatcher) Match(input string, offset int) (matched int) {
}

//SequenceMatcher represents a matcher that finds any sequence until find provided terminators
type sequenceMatcher struct{
type sequenceMatcher struct {
Terminators []string
}


func (m sequenceMatcher) hasTerminator(candidate string) bool {
var candidateLength = len(candidate)
for _, terminator := range m.Terminators {
terminatorLength :=len(terminator)
terminatorLength := len(terminator)
if len(terminator) > candidateLength {
continue
}
if terminator == string(candidate[:terminatorLength]) {
return true
return true
}
}
return false
}


//Match matches a literal in the input, it returns number of character matched.
func (m sequenceMatcher) Match(input string, offset int) (matched int) {
var i = 0;
var i = 0
for ; i < len(input)-offset; i++ {
if m.hasTerminator(string(input[offset+i:])) {
break
}
}
return i
}

//NewSequenceMatcher creates a new matcher that finds any sequence until find provided terminators
func NewSequenceMatcher(terminators ... string) Matcher {
func NewSequenceMatcher(terminators ...string) Matcher {
return &sequenceMatcher{
Terminators:terminators,
Terminators: terminators,
}
}

//CustomIdMatcher represents a matcher that finds any literals with additional custom set of characters in the input
type customIdMatcher struct{
type customIdMatcher struct {
Allowed map[string]bool
}


func (m *customIdMatcher) isValid(aChar string) bool {
if isLetter(aChar) {
return true
return true
}
if isDigit(aChar) {
return true
Expand All @@ -222,7 +219,7 @@ func (m *customIdMatcher) isValid(aChar string) bool {
//Match matches a literal in the input, it returns number of character matched.
func (m *customIdMatcher) Match(input string, offset int) (matched int) {

if !m.isValid(input[offset:offset+1]) {
if !m.isValid(input[offset : offset+1]) {
return 0
}
var i = 1
Expand All @@ -236,21 +233,16 @@ func (m *customIdMatcher) Match(input string, offset int) (matched int) {
}

//NewCustomIdMatcher creates new custom matcher
func NewCustomIdMatcher(allowedChars ... string) Matcher {
func NewCustomIdMatcher(allowedChars ...string) Matcher {
var result = &customIdMatcher{
Allowed:make(map[string]bool),
Allowed: make(map[string]bool),
}
for _, allowed := range allowedChars {
result.Allowed[allowed] = true
}
return result
}






//LiteralMatcher represents a matcher that finds any literals in the input
type BodyMatcher struct {
Begin string
Expand Down
10 changes: 2 additions & 8 deletions tokenizer_test.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,20 @@ func TestNewTokenizer(t *testing.T) {

}



func Test_NewCustomIdMatcher(t *testing.T) {
matcher:= toolbox.NewCustomIdMatcher("$")
matcher := toolbox.NewCustomIdMatcher("$")
assert.Equal(t, 5, matcher.Match("Z $Abcf", 2))
assert.Equal(t, 1, matcher.Match("Z Abcf", 0))
assert.Equal(t, 0, matcher.Match("### ##", 0))
}



func Test_NewSequenceMatcher(t *testing.T) {
matcher:= toolbox.NewSequenceMatcher("&&", "||")
matcher := toolbox.NewSequenceMatcher("&&", "||")
assert.Equal(t, 2, matcher.Match("123", 1))
assert.Equal(t, 4, matcher.Match("123 && 123", 0))


}


func TestMatchKeyword(t *testing.T) {
matcher := toolbox.KeywordMatcher{"Abc", true}
assert.Equal(t, 3, matcher.Match("Z Abcf", 2))
Expand Down
Empty file modified types.go
100755 → 100644
Empty file.
Empty file modified types_test.go
100755 → 100644
Empty file.
Empty file modified uri.go
100755 → 100644
Empty file.
Empty file modified uri_helper.go
100755 → 100644
Empty file.
Empty file modified uri_helper_test.go
100755 → 100644
Empty file.
Empty file modified uri_test.go
100755 → 100644
Empty file.
Empty file modified value_provider.go
100755 → 100644
Empty file.
Empty file modified value_provider_test.go
100755 → 100644
Empty file.
Empty file modified writer_at.go
100755 → 100644
Empty file.
Empty file modified writer_at_test.go
100755 → 100644
Empty file.

0 comments on commit c01c516

Please sign in to comment.