Skip to content

Commit

Permalink
Merge pull request #940 from wakatime/feature/ruby-version-file
Browse files Browse the repository at this point in the history
Add .ruby-version as Ruby language
  • Loading branch information
gandarez authored Sep 26, 2023
2 parents bb856ef + 82a1848 commit 28bd1ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/language/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ func TestDetect_ChromaTopLanguagesRetrofit(t *testing.T) {
},
"ruby": {
Filepaths: []string{
"path/to/.ruby-version",
"path/to/file.rb",
"path/to/file.rbw",
"path/to/Rakefile",
Expand Down
27 changes: 27 additions & 0 deletions pkg/lexer/ruby.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
"github.com/wakatime/wakatime-cli/pkg/log"

"github.com/alecthomas/chroma/v2/lexers"
)

// nolint:gochecknoinits
func init() {
language := heartbeat.LanguageRuby.StringChroma()
lexer := lexers.Get(language)

if lexer == nil {
log.Debugf("lexer %q not found", language)
return
}

cfg := lexer.Config()
if cfg == nil {
log.Debugf("lexer %q config not found", language)
return
}

cfg.Filenames = append(cfg.Filenames, ".ruby-version")
}

0 comments on commit 28bd1ad

Please sign in to comment.