All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Eddie Lebow https://github.com/elebow
2 " Description: Functions for integrating with Ruby tools
4 " Find the nearest dir containing "app", "db", and "config", and assume it is
5 " the root of a Rails app.
6 function! ale#ruby#FindRailsRoot(buffer) abort
7 for l:name in ['app', 'config', 'db']
8 let l:dir = fnamemodify(
9 \ ale#path#FindNearestDirectory(a:buffer, l:name),
14 \&& isdirectory(l:dir . '/app')
15 \&& isdirectory(l:dir . '/config')
16 \&& isdirectory(l:dir . '/db')
24 " Find the nearest dir containing a potential ruby project.
25 function! ale#ruby#FindProjectRoot(buffer) abort
26 let l:dir = ale#ruby#FindRailsRoot(a:buffer)
32 for l:name in ['.solargraph.yml', 'Rakefile', 'Gemfile']
33 let l:dir = fnamemodify(
34 \ ale#path#FindNearestFile(a:buffer, l:name),
38 if l:dir isnot# '.' && isdirectory(l:dir)
46 " Handle output from rubocop and linters that depend on it (e.b. standardrb)
47 function! ale#ruby#HandleRubocopOutput(buffer, lines) abort
49 let l:errors = json_decode(a:lines[0])
54 if !has_key(l:errors, 'summary')
55 \|| l:errors['summary']['offense_count'] == 0
56 \|| empty(l:errors['files'])
62 for l:error in l:errors['files'][0]['offenses']
63 let l:start_col = l:error['location']['column'] + 0
65 \ 'lnum': l:error['location']['line'] + 0,
67 \ 'end_col': l:start_col + l:error['location']['length'] - 1,
68 \ 'code': l:error['cop_name'],
69 \ 'text': l:error['message'],
70 \ 'type': ale_linters#ruby#rubocop#GetType(l:error['severity']),
77 function! ale#ruby#EscapeExecutable(executable, bundle_exec) abort
78 let l:exec_args = a:executable =~? 'bundle'
79 \ ? ' exec ' . a:bundle_exec
82 return ale#Escape(a:executable) . l:exec_args