summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorEddie Lebow <elebow@users.noreply.github.com>2017-07-12 05:43:47 -0400
committerw0rp <w0rp@users.noreply.github.com>2017-07-12 10:43:47 +0100
commitbc32e24203159945dcf3906a5e08261ccb06e065 (patch)
treeef1ddaefe8aee1a7ca37c156a11c447753dee17f /autoload
parent400580e4e8fc330166658c689d1abf05db38ab3b (diff)
downloadale-bc32e24203159945dcf3906a5e08261ccb06e065.zip
Add rails_best_practices handler (resolves #655) (#751)
* Move FindRailsRoot() to more general location * Add rails_best_practices handler (resolves #655) * Update documentation for rails_best_practices Also add brakeman to *ale* documentation. * rails_best_practices: allow overriding the executable * rails_best_practices: format help correctly * rails_best_practices: capture tool output on Windows
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/rails_best_practices.vim6
-rw-r--r--autoload/ale/ruby.vim22
2 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/handlers/rails_best_practices.vim b/autoload/ale/handlers/rails_best_practices.vim
new file mode 100644
index 00000000..51bafbb0
--- /dev/null
+++ b/autoload/ale/handlers/rails_best_practices.vim
@@ -0,0 +1,6 @@
+call ale#Set('ruby_rails_best_practices_options', '')
+call ale#Set('ruby_rails_best_practices_executable', 'rails_best_practices')
+
+function! ale#handlers#rails_best_practices#GetExecutable(buffer) abort
+ return ale#Var(a:buffer, 'ruby_rails_best_practices_executable')
+endfunction
diff --git a/autoload/ale/ruby.vim b/autoload/ale/ruby.vim
new file mode 100644
index 00000000..503ff1db
--- /dev/null
+++ b/autoload/ale/ruby.vim
@@ -0,0 +1,22 @@
+" Author: Eddie Lebow https://github.com/elebow
+" Description: Functions for integrating with Ruby tools
+
+" Find the nearest dir contining "app", "db", and "config", and assume it is
+" the root of a Rails app.
+function! ale#ruby#FindRailsRoot(buffer) abort
+ for l:name in ['app', 'config', 'db']
+ let l:dir = fnamemodify(
+ \ ale#path#FindNearestDirectory(a:buffer, l:name),
+ \ ':h:h'
+ \)
+
+ if l:dir !=# '.'
+ \&& isdirectory(l:dir . '/app')
+ \&& isdirectory(l:dir . '/config')
+ \&& isdirectory(l:dir . '/db')
+ return l:dir
+ endif
+ endfor
+
+ return ''
+endfunction