diff --git a/UltiSnips/ruby.snippets b/UltiSnips/ruby.snippets index ea03314..aaddac3 100644 --- a/UltiSnips/ruby.snippets +++ b/UltiSnips/ruby.snippets @@ -145,7 +145,7 @@ endsnippet snippet "([^ \t]+)\.delete_?if" ".delete_if do |,| end" r -`!p snip.rv=match.group(1)`.delete_if do |${1:key}, ${2:value}| +`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}| ${3:# TODO} end${4:$0} endsnippet @@ -159,7 +159,7 @@ endsnippet snippet "([^ \t]+)\.keep_?if" ".keep_if do ,| end" r -`!p snip.rv=match.group(1)`.keep_if do |${1:key}, ${2:value}| +`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}| ${3:# TODO} end${4:$0} endsnippet @@ -167,13 +167,13 @@ endsnippet snippet "([^ \t]+)\.Reject" ".reject { |,| }" r -`!p snip.rv=match.group(1)`.reject { |${1:key}, ${2:value}| ${3:# TODO} }${4:$0} +`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }${4:$0} endsnippet snippet "([^ \t]+)\.reject" ".reject do ,| end" r -`!p snip.rv=match.group(1)`.reject do |${1:key}, ${2:value}| +`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| ${3:# TODO} end${4:$0} endsnippet @@ -194,27 +194,13 @@ endsnippet -snippet "([^ \t]+)\.Reverse_?each" ".revere_each { || }" r -`!p snip.rv=match.group(1)`.reverse_each { |${1:key}| ${2:# TODO} }${3:$0} +snippet "([^ \t]+)\.Sort" ".sort { |,| }" i +`!p snip.rv=match.group(1)`.sort { |${1:a},${2,b}| ${3:# TODO} }${4:$0} endsnippet -snippet "([^ \t]+)\.reverse_?each" ".revere_each do || end" r -`!p snip.rv=match.group(1)`.reverse_each do |${1:key}| - ${2:# TODO} -end${3:$0} -endsnippet - - - -snippet "([^ \t]+)\.Sort" ".sort { |, | }" i -`!p snip.rv=match.group(1)`.sort { |${1:a}, ${2,b}| ${3:# TODO} }${4:$0} -endsnippet - - - -snippet "([^ \t]+)\.sort" ".sort do |, | end" r +snippet "([^ \t]+)\.sort" ".sort do |,| end" r `!p snip.rv=match.group(1)`.sort do |${1:a},${2,b}| ${3:# TODO} end${4:$0} @@ -264,78 +250,144 @@ endsnippet +snippet "([^ \t]+)\.Map" ".map { || }" r +`!p snip.rv=match.group(1)`.map { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2:# TODO} }${3:$0} +endsnippet + + + +snippet "([^ \t]+)\.map" ".map do || end" r +`!p snip.rv=match.group(1)`.map do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + ${2:# TODO} +end${3:$0} +endsnippet + + + +snippet "([^ \t]+)\.Reverse_?each" ".reverse_each { || }" r +`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2:# TODO} }${3:$0} +endsnippet + + + +snippet "([^ \t]+)\.reverse_?each" ".reverse_each do || end" r +`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + ${2:# TODO} +end${3:$0} +endsnippet + + + snippet "([^ \t]+)\.Each" ".each { || }" r -`!p snip.rv=match.group(1)`.each { |${1:element}| ${2:# TODO} }${3:$0} +`!p snip.rv=match.group(1)`.each { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2:# TODO} }${3:$0} endsnippet snippet "([^ \t]+)\.each" ".each do || end" r -`!p snip.rv=match.group(1)`.each do |${1:element}| +`!p snip.rv=match.group(1)`.each do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| ${2:# TODO} end${3:$0} endsnippet -snippet "([^ \t]+)\.Each_?index" ".each_index { || }" r -`!p snip.rv=match.group(1)`.each_index { |${1:element}| ${2:# TODO} }${3:$0} +snippet "([^ \t]+)\.Each_?index" ".each_index { || }" r +`!p snip.rv=match.group(1)`.each_index { |${1:index}| ${2:# TODO} }${3:$0} endsnippet -snippet "([^ \t]+)\.each_?index" ".each_index do || end" r -`!p snip.rv=match.group(1)`.each_index do |${1:element}| +snippet "([^ \t]+)\.each_?index" ".each_index do || end" r +`!p snip.rv=match.group(1)`.each_index do |${1:index}| ${2:# TODO} end${3:$0} endsnippet -snippet "([^ \t]+)\.Each_?pair" ".each_pair { |, | }" r -`!p snip.rv=match.group(1)`.each_pair { |${1:key}, ${2:value}| ${3:# TODO} }${4:$0} +snippet "([^ \t]+)\.Each_?pair" ".each_pair { |,| }" r +`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }${4:$0} endsnippet -snippet "([^ \t]+)\.each_?pair" ".each_pair do |, | end" r -`!p snip.rv=match.group(1)`.each_pair do |${1:key}, ${2:value}| +snippet "([^ \t]+)\.each_?pair" ".each_pair do |,| end" r +`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}| ${3:# TODO} end${4:$0} endsnippet -snippet "([^ \t]+)\.Map" ".map { || }" r -`!p snip.rv=match.group(1)`.map { |${1:key}| ${2:code} }${3:$0} -endsnippet - - - -snippet "([^ \t]+)\.map" ".map do || end" r -`!p snip.rv=match.group(1)`.map do |${1:key}| - ${2:code} -end${3:$0} -endsnippet - - - snippet "([^ \t]+)\.sub" ".sub() { }" r -`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"code"} }${3:$0} +`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} }${3:$0} endsnippet snippet "([^ \t]+)\.gsub" ".gsub() { }" r -`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"code"} }${3:$0} +`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} }${3:$0} endsnippet + + snippet do "do || ... end" i do ${1:|${2:key}|} ${3:$0} end endsnippet + + snippet Do "do ... end" i do ${1:$0}