Moved functions to autoload
Added functions/settings for template/snippets directory Now uses templates for new Spec/SpecHelper.js files
This commit is contained in:
parent
481e7f4a85
commit
5191a7336a
|
@ -29,6 +29,11 @@ This plugin is pretty basic right now. It currently:
|
||||||
** matcher: matcher block for SpecHelper.js
|
** matcher: matcher block for SpecHelper.js
|
||||||
** expect: expect..to line
|
** expect: expect..to line
|
||||||
** spy: spyOn method
|
** spy: spyOn method
|
||||||
|
* Uses templates for new Spec/SpecHelper buffers
|
||||||
|
|
||||||
|
You can disable templating by setting g:jasmine_use_templates=""
|
||||||
|
|
||||||
|
By default, the plugin assumes the templates are in bundle/jasmine/template and the snippets are in bundle/jasmine/snippets. You can override those by setting g:jasmine_snippets_directory and g:jasmine_templates_directory in your vimrc
|
||||||
|
|
||||||
h2. TODO
|
h2. TODO
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
if exists("g:loaded_autoloadjasmine") || &cp
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:loaded_autoloadjasmine=1
|
||||||
|
|
||||||
|
if !exists("g:jasmine_use_templates")
|
||||||
|
let g:jasmine_use_templates = 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
function jasmine#directory()
|
||||||
|
if !exists("g:jasmine_directory")
|
||||||
|
for directory in pathogen#split(&rtp)
|
||||||
|
if directory =~ "jasmine$"
|
||||||
|
let g:jasmine_directory = directory
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
|
||||||
|
return g:jasmine_directory
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function jasmine#snippets_directory()
|
||||||
|
if !exists("g:jasmine_snippets_directory")
|
||||||
|
let g:jasmine_snippets_directory = jasmine#directory() . "/snippets"
|
||||||
|
endif
|
||||||
|
|
||||||
|
return g:jasmine_snippets_directory
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function jasmine#templates_directory()
|
||||||
|
if !exists("g:jasmine_templates_directory")
|
||||||
|
let g:jasmine_templates_directory = jasmine#directory() . "/templates"
|
||||||
|
endif
|
||||||
|
|
||||||
|
return g:jasmine_templates_directory
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function jasmine#load_snippets()
|
||||||
|
if !exists("s:loaded_snippets")
|
||||||
|
if exists("*ExtractSnips")
|
||||||
|
call ExtractSnips(jasmine#snippets_directory(), "jasmine")
|
||||||
|
end
|
||||||
|
|
||||||
|
let s:loaded_snippets = 1
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function jasmine#configure_templates()
|
||||||
|
if g:jasmine_use_templates && !exists("g:configured_templates")
|
||||||
|
autocmd BufNewFile *Spec.js execute "0r".jasmine#templates_directory()."/Spec.js"
|
||||||
|
autocmd BufNewFile *SpecHelper.js execute "0r".jasmine#templates_directory()."/SpecHelper.js"
|
||||||
|
let g:configured_templates=1
|
||||||
|
endif
|
||||||
|
endfunction
|
|
@ -1,2 +1 @@
|
||||||
au BufNewFile,BufRead,BufWritePost *[Ss]pec.js set filetype=jasmine.javascript syntax=jasmine
|
autocmd BufNewFile,BufRead,BufWritePost *Spec.js,*SpecHelper.js set filetype=jasmine.javascript syntax=jasmine
|
||||||
au BufNewFile,BufRead,BufWritePost *[Ss]pec[Hh]elper.js set filetype=jasmine.javascript syntax=jasmine
|
|
||||||
|
|
|
@ -1,23 +1,7 @@
|
||||||
if exists("b:did_ftplugin")
|
if exists("b:did_ftplugin") || &cp
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists("g:loaded_jasmine_snippets")
|
|
||||||
if exists("g:loaded_pathogen")
|
|
||||||
|
|
||||||
if !exists("g:jasmine_snippets_dir")
|
|
||||||
for dir in pathogen#split(&rtp)
|
|
||||||
if dir =~ "jasmine$" && isdirectory(dir."/snippets")
|
|
||||||
let g:jasmine_snippets_dir = dir."/snippets"
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
endif
|
|
||||||
|
|
||||||
call ExtractSnips(g:jasmine_snippets_dir, "jasmine")
|
|
||||||
end
|
|
||||||
|
|
||||||
let g:loaded_jasmine_snippets = 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:did_ftplugin = 1
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
|
call jasmine#load_snippets()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
if exists("g:loaded_jasmine")
|
if exists("g:loaded_jasmine") || &cp
|
||||||
finish
|
finish
|
||||||
endif
|
end
|
||||||
|
|
||||||
let g:loaded_jasmine=1
|
let g:loaded_jasmine=1
|
||||||
|
|
||||||
|
call jasmine#configure_templates()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
describe('', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should...', function () {
|
||||||
|
expect(condition).toEqual();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
beforeEach(function() {
|
||||||
|
this.addMatchers({
|
||||||
|
|
||||||
|
toHaveSomething: function() {
|
||||||
|
var summary = this.actual;
|
||||||
|
this.actual = summary.clone().wrap('<div>').parent().html();
|
||||||
|
|
||||||
|
// Magical matcher work goes here.
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
});
|
Loading…
Reference in New Issue