From: Edgar HIPP Date: Thu, 9 Jul 2015 20:32:43 +0000 (+0200) Subject: Move cli entry poiny to path-extractor/ X-Git-Url: http://www.git.stargrave.org/?p=path-extractor.git;a=commitdiff_plain;h=81502d5728b14d8a9d193d5eb5078d58514e04f3 Move cli entry poiny to path-extractor/ --- diff --git a/extractor.go b/extractor.go index b7be986..0b03664 100644 --- a/extractor.go +++ b/extractor.go @@ -1,4 +1,4 @@ -package main +package pathextractor import "regexp" @@ -10,7 +10,7 @@ func pathExtractor(input string) [][][]byte { return temp } -func getAllMatches(input string) []string { +func GetAllMatches(input string) []string { matches := [][][]byte{} result := []string{} s := string("") diff --git a/pe.go b/path-extractor/pe.go similarity index 69% rename from pe.go rename to path-extractor/pe.go index 5147f27..d95d456 100644 --- a/pe.go +++ b/path-extractor/pe.go @@ -1,5 +1,7 @@ package main +import "github.com/edi9999/path-extractor" + import ( "bufio" "fmt" @@ -10,7 +12,7 @@ func main() { stdin := os.Stdin if scanner := bufio.NewScanner(stdin); scanner != nil { for scanner.Scan() { - matches := getAllMatches(scanner.Text()) + matches := pathextractor.GetAllMatches(scanner.Text()) for _, match := range matches { fmt.Println(match) } diff --git a/pe_test.go b/pe_test.go index 2ef95b2..6545029 100644 --- a/pe_test.go +++ b/pe_test.go @@ -1,64 +1,64 @@ -package main +package pathextractor import "testing" func TestGitIgnore(t *testing.T) { - output := getAllMatches("?? alt/generateStore.php") + output := GetAllMatches("?? alt/generateStore.php") if output[0] != "alt/generateStore.php" { t.Errorf("Doesnt match files", output[0]) } - output = getAllMatches("hello .gitignore") + output = GetAllMatches("hello .gitignore") if output[0] != ".gitignore" { t.Errorf("Doesnt match hidden files", output[0]) } - output = getAllMatches(" mail@mail.com ") + output = GetAllMatches(" mail@mail.com ") if len(output) != 0 { t.Errorf("Matches email adresses", output[0]) } - output = getAllMatches("v1.2") + output = GetAllMatches("v1.2") if len(output) != 0 { t.Errorf("Matches version number", output[0]) } - output = getAllMatches("obj.slice()") + output = GetAllMatches("obj.slice()") if len(output) != 0 { t.Errorf("Matches function call", output[0]) } - output = getAllMatches("~/www") + output = GetAllMatches("~/www") if len(output) == 0 || output[0] != "~/www" { t.Errorf("Doesnt match home", output[0]) } - output = getAllMatches("origin/master") + output = GetAllMatches("origin/master") if len(output) != 0 { t.Errorf("Matches remote name", output[0]) } - output = getAllMatches("john doe (dead on 28/04/2014)") + output = GetAllMatches("john doe (dead on 28/04/2014)") if len(output) != 0 { t.Errorf("Matches date", output[0]) } - output = getAllMatches("john doe ,dead on 28/04/2014") + output = GetAllMatches("john doe ,dead on 28/04/2014") if len(output) != 0 { t.Errorf("Matches date", output[0]) } - output = getAllMatches(".gitignore , ~/www") + output = GetAllMatches(".gitignore , ~/www") if len(output) != 2 { t.Errorf("Doesnt match multi", output[0]) } - output = getAllMatches("var/") + output = GetAllMatches("var/") if len(output) != 1 { t.Errorf("Doesnt match dir", output[0]) } - output = getAllMatches("//") + output = GetAllMatches("//") if len(output) != 0 { t.Errorf("Comment matches", output[0]) } diff --git a/validators.go b/validators.go index 74b7746..cd9477d 100644 --- a/validators.go +++ b/validators.go @@ -1,4 +1,4 @@ -package main +package pathextractor import ( "regexp"