From 19d4dee646c501fbb735de714942c41b6eaeb03e Mon Sep 17 00:00:00 2001 From: jimi Date: Fri, 20 Aug 2010 00:26:02 -0500 Subject: [PATCH] Update ruby snippets for Rails models and rspec - attr snippet with menu for selecting: accessible, protected, etc... - validates snippet with key => value pairs - rspec loop and other shortcuts --- ftplugin/ruby/ruby.xpt.vim | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/ftplugin/ruby/ruby.xpt.vim b/ftplugin/ruby/ruby.xpt.vim index 670a2a1..b0a4ddb 100644 --- a/ftplugin/ruby/ruby.xpt.vim +++ b/ftplugin/ruby/ruby.xpt.vim @@ -8,6 +8,18 @@ def `method^` `action^ end +XPT attr " attr_** +XSET what=Choose(["accessible","protected","accessor","reader","writer"]) +XSET attr*|post=ExpandIfNotEmpty(', :', 'attr*') +attr`_`what^ :`attr*^ + +XPT validates " validates :attr ... +validates :`attr^, `^ + +XPT :presence synonym=:uniqueness|:acceptance|:confirmation|:numericallity " $_xSnipName => true +XSET bool=true`^ +`:key({ 'val' : 'bool' }):^ + " eRuby attribute snippets XPT key hidden " $_xSnipName => val @@ -34,20 +46,34 @@ XSET val={ `html^ } XPT :media alias=key XSET val='`screen^' +XPT image_tag synonym=imt " image_tag... +image_tag('`filename^'`, `opt?^) + " RSpec snippets -XPT loop " loop do .. end -`loop^` `arg^ do - `cursor^ +XPT loop " $_xSnipName args? do .. end +XSET content=Echo('') +`$_xSnipName^` `args^ do +` `content^ end -XPT describe " describe .. do -XSET name=describe -`:loop({ 'loop' : 'name' }):^ +XPT describe synonym=it alias=loop +XSET args="`^" -XPT it " it .. do -XSET name=it -`:loop({ 'loop' : 'name' }):^ +XPT resp +response. XPT :content " $_xSnipName => "val" `:key:^ + +XPT shd abbr " should ... +should `^ + +XPT shn abbr " should_not ... +should_not `^ + +XPT shb abbr " should be_ +should be_ + +XPT shnb abbr " should_not be_ +should_not be_