Skip to content

Commit

Permalink
feat: Ruby support
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed May 30, 2024
1 parent 9b0f759 commit 5f1e01a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/lint/code/lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func GetLanguageFromExt(ext string) (*Language, error) {
return Rust(), nil
case ".py":
return Python(), nil
case ".rb":
return Ruby(), nil
default:
return nil, fmt.Errorf("unsupported extension: '%s'", ext)
}
Expand Down
18 changes: 18 additions & 0 deletions internal/lint/code/rb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package code

import (
"regexp"

"github.com/smacker/go-tree-sitter/ruby"
)

func Ruby() *Language {
return &Language{
Delims: regexp.MustCompile(`#|=begin|=end`),
Parser: ruby.GetLanguage(),
Queries: []string{`(comment)+ @comment`},
Padding: func(s string) int {
return computePadding(s, []string{"#", `=begin`, `=end`})
},
}
}
9 changes: 9 additions & 0 deletions testdata/features/fragments.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Feature: Fragments
test.py:18:29:Vale.Spelling:Did you really mean 'docmentation'?
test.py:20:20:Vale.Spelling:Did you really mean 'ducmenation'?
test.py:24:13:Vale.Spelling:Did you really mean 'parapp'?
test.rb:2:23:Vale.Spelling:Did you really mean 'thre'?
test.rb:6:6:Vale.Spelling:Did you really mean 'stil'?
test.rb:9:36:Vale.Spelling:Did you really mean 'coment'?
test.rb:11:16:Vale.Spelling:Did you really mean 'foof'?
test.rb:11:21:Vale.Spelling:Did you really mean 'hopl'?
test.rb:15:16:Vale.Spelling:Did you really mean 'foof'?
test.rb:15:21:Vale.Spelling:Did you really mean 'hopll'?
test.rb:17:16:Vale.Spelling:Did you really mean 'foof'?
test.rb:17:21:Vale.Spelling:Did you really mean 'hopl'?
test.rs:3:22:Vale.Spelling:Did you really mean 'representd'?
test.rs:5:22:Vale.Spelling:Did you really mean 'representd'?
test.rs:7:39:Vale.Spelling:Did you really mean 'mattter'?
Expand Down
2 changes: 1 addition & 1 deletion testdata/fixtures/fragments/.vale.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ go = md
rb = md
cc = md

[*.{go,py,rs}]
[*.{go,py,rs,rb}]
BasedOnStyles = Vale

[*.cc]
Expand Down
2 changes: 2 additions & 0 deletions testdata/fixtures/fragments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
# XXX: this is foof hopll.

# XXX: this is foof hopl.

foof = 1

0 comments on commit 5f1e01a

Please sign in to comment.