]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/ale_linters/cucumber/cucumber.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / ale_linters / cucumber / cucumber.vim
1 " Author: Eddie Lebow https://github.com/elebow
2 " Description: Cucumber, a BDD test tool
3
4 function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort
5     let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features')
6
7     if !empty(l:features_dir)
8         let l:features_arg = '-r ' . ale#Escape(l:features_dir)
9     else
10         let l:features_arg = ''
11     endif
12
13     return 'cucumber --dry-run --quiet --strict --format=json '
14     \   . l:features_arg . ' %t'
15 endfunction
16
17 function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort
18     try
19         let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0]
20     catch
21         return []
22     endtry
23
24     let l:output = []
25
26     for l:element in get(l:json, 'elements', [])
27         for l:step in l:element['steps']
28             if l:step['result']['status'] is# 'undefined'
29                 call add(l:output, {
30                 \   'lnum': l:step['line'],
31                 \   'code': 'E',
32                 \   'text': 'Undefined step'
33                 \})
34             endif
35         endfor
36     endfor
37
38     return l:output
39 endfunction
40
41 call ale#linter#Define('cucumber', {
42 \   'name': 'cucumber',
43 \   'executable': 'cucumber',
44 \   'command': function('ale_linters#cucumber#cucumber#GetCommand'),
45 \   'callback': 'ale_linters#cucumber#cucumber#Handle'
46 \})