-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from mcarmonaa/modelines
Added Modeline detection strategy
- Loading branch information
Showing
25 changed files
with
1,532 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package slinguist | ||
|
||
import "strings" | ||
|
||
// GetLanguageByAlias returns the language related to the given alias or Otherlanguage otherwise. | ||
func GetLanguageByAlias(alias string) (lang string) { | ||
a := strings.Split(alias, `,`)[0] | ||
a = strings.ToLower(a) | ||
lang, ok := languagesByAlias[a] | ||
if !ok { | ||
lang = OtherLanguage | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package slinguist | ||
|
||
import . "gopkg.in/check.v1" | ||
|
||
func (s *TSuite) TestGetLanguageByAlias(c *C) { | ||
tests := []struct { | ||
alias string | ||
expectedLang string | ||
}{ | ||
{alias: "BestLanguageEver", expectedLang: OtherLanguage}, | ||
{alias: "aspx-vb", expectedLang: "ASP"}, | ||
{alias: "C++", expectedLang: "C++"}, | ||
{alias: "c++", expectedLang: "C++"}, | ||
{alias: "objc", expectedLang: "Objective-C"}, | ||
{alias: "golang", expectedLang: "Go"}, | ||
{alias: "GOLANG", expectedLang: "Go"}, | ||
{alias: "bsdmake", expectedLang: "Makefile"}, | ||
{alias: "xhTmL", expectedLang: "HTML"}, | ||
{alias: "python", expectedLang: "Python"}, | ||
} | ||
|
||
for _, test := range tests { | ||
lang := GetLanguageByAlias(test.alias) | ||
c.Assert(lang, Equals, test.expectedLang) | ||
} | ||
} |
Oops, something went wrong.