s:parse_name is a helper function

This commit is contained in:
gmarik 2010-12-05 23:16:29 -06:00
parent b3c561161d
commit eccbda9b6a

View File

@ -15,10 +15,10 @@ func! vundle#rc()
endf
func! vundle#add_bundle(arg, ...)
let bundle = copy(s:bundle)
let bundle = s:parse_options(a:000)
call add(g:bundles, bundle)
call extend(bundle, s:parse_options(a:000))
call bundle.parse_name(a:arg)
call extend(bundle, s:parse_name(a:arg))
call extend(bundle, copy(s:bundle))
call bundle.require()
endf
@ -32,6 +32,29 @@ func! vundle#helptags()
for bundle in g:bundles | call bundle.helptags() | endfor
endf
func s:parse_options(opts)
" TODO: improve this
if len(a:opts) != 1 | return {} | endif
if type(a:opts[0]) == type({})
return a:opts[0]
else
return {'rev': a:opts[0]}
endif
endf
func! s:parse_name(arg)
let arg = a:arg
if arg =~ '^\s*\(git@\|git://\)\S\+' || arg =~ 'https\?://' || arg =~ '\.git\*$'
let uri = arg
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
else
let name = arg
let uri = 'http://github.com/vim-scripts/'.name.'.git'
endif
return {'name': name, 'uri': uri }
endf
let s:bundle = {}
func s:bundle.path()
@ -50,29 +73,6 @@ func s:bundle.require()
endif
endf
func s:parse_options(opts)
" TODO: improve this
if len(a:opts) == 1
if type(a:opts[0]) == type({})
return a:opts[0]
else
return {'rev': a:opts[0]}
endif
endif
return {}
endf
func! s:bundle.parse_name(arg)
let arg = a:arg
if arg =~ '^\s*\(git@\|git://\)\S\+' || arg =~ 'https\?://' || arg =~ '\.git\*$'
let self.uri = arg
let self.name = substitute(split(self.uri,'\/')[-1], '\.git\s*$','','i')
else
let self.name = arg
let self.uri = 'http://github.com/vim-scripts/'.self.name.'.git'
endif
endf
func! s:bundle.helptags()
let dir = self.rtpath()
if isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))