summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-06 11:12:21 +0000
committerw0rp <devw0rp@gmail.com>2017-02-06 11:12:27 +0000
commita3b7056cadb045906141cc342404950b6d673959 (patch)
tree0e37604b36c6f1ad5085b1e51fb6c220db39e4e3 /autoload
parenta9a76241ac12901f3f48ab80a6552204c5d01159 (diff)
downloadale-a3b7056cadb045906141cc342404950b6d673959.zip
#289 Only use the --stdin-display-name flag if the flake8 version supports it
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/semver.vim29
1 files changed, 29 insertions, 0 deletions
diff --git a/autoload/ale/semver.vim b/autoload/ale/semver.vim
new file mode 100644
index 00000000..b153dd1d
--- /dev/null
+++ b/autoload/ale/semver.vim
@@ -0,0 +1,29 @@
+" Given some text, parse a semantic versioning string from the text
+" into a triple of integeers [major, minor, patch].
+"
+" If no match can be performed, then an empty List will be returned instead.
+function! ale#semver#Parse(text) abort
+ let l:match = matchlist(a:text, '^ *\(\d\+\)\.\(\d\+\)\.\(\d\+\)')
+
+ if empty(l:match)
+ return []
+ endif
+
+ return [l:match[1] + 0, l:match[2] + 0, l:match[3] + 0]
+endfunction
+
+" Given two triples of integers [major, minor, patch], compare the triples
+" and return 1 if the lhs is greater than or equal to the rhs.
+function! ale#semver#GreaterOrEqual(lhs, rhs) abort
+ if a:lhs[0] > a:rhs[0]
+ return 1
+ elseif a:lhs[0] == a:rhs[0]
+ if a:lhs[1] > a:rhs[1]
+ return 1
+ elseif a:lhs[1] == a:rhs[1]
+ return a:lhs[2] >= a:rhs[2]
+ endif
+ endif
+
+ return 0
+endfunction