Updated ruby snippets by Aldis Berjoza

This commit is contained in:
Holger Rapp 2011-11-16 21:47:23 +01:00
parent 2c6d5bd070
commit 3094d79e61

View File

@ -145,7 +145,7 @@ endsnippet
snippet "([^ \t]+)\.delete_?if" ".delete_if do |<key>,<value>| <block> 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 <key>,<value>| <block> 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 { |<key>,<value>| <block> }" 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 <key>,<value>| <block> 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 { |<key>| <block> }" r
`!p snip.rv=match.group(1)`.reverse_each { |${1:key}| ${2:# TODO} }${3:$0}
snippet "([^ \t]+)\.Sort" ".sort { |<a>,<b>| <block> }" i
`!p snip.rv=match.group(1)`.sort { |${1:a},${2,b}| ${3:# TODO} }${4:$0}
endsnippet
snippet "([^ \t]+)\.reverse_?each" ".revere_each do |<key>| <block> end" r
`!p snip.rv=match.group(1)`.reverse_each do |${1:key}|
${2:# TODO}
end${3:$0}
endsnippet
snippet "([^ \t]+)\.Sort" ".sort { |<a>, <b>| <block> }" i
`!p snip.rv=match.group(1)`.sort { |${1:a}, ${2,b}| ${3:# TODO} }${4:$0}
endsnippet
snippet "([^ \t]+)\.sort" ".sort do |<a>, <b>| <block> end" r
snippet "([^ \t]+)\.sort" ".sort do |<a>,<b>| <block> 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 { |<element>| <block> }" 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 |<element>| <block> 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 { |<element>| <block> }" 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 |<element>| <block> 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 { |<element>| <block> }" 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 |<element>| <block> 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 { |<element>| <block> }" r
`!p snip.rv=match.group(1)`.each_index { |${1:element}| ${2:# TODO} }${3:$0}
snippet "([^ \t]+)\.Each_?index" ".each_index { |<index>| <block> }" r
`!p snip.rv=match.group(1)`.each_index { |${1:index}| ${2:# TODO} }${3:$0}
endsnippet
snippet "([^ \t]+)\.each_?index" ".each_index do |<element>| <block> end" r
`!p snip.rv=match.group(1)`.each_index do |${1:element}|
snippet "([^ \t]+)\.each_?index" ".each_index do |<index>| <block> 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 { |<key>, <value>| <block> }" r
`!p snip.rv=match.group(1)`.each_pair { |${1:key}, ${2:value}| ${3:# TODO} }${4:$0}
snippet "([^ \t]+)\.Each_?pair" ".each_pair { |<key>,<value>| <block> }" 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 |<key>, <value>| <block> end" r
`!p snip.rv=match.group(1)`.each_pair do |${1:key}, ${2:value}|
snippet "([^ \t]+)\.each_?pair" ".each_pair do |<key>,<value>| <block> 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 { |<key>| <block> }" r
`!p snip.rv=match.group(1)`.map { |${1:key}| ${2:code} }${3:$0}
endsnippet
snippet "([^ \t]+)\.map" ".map do |<key>| <block> end" r
`!p snip.rv=match.group(1)`.map do |${1:key}|
${2:code}
end${3:$0}
endsnippet
snippet "([^ \t]+)\.sub" ".sub(<expression>) { <block> }" 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(<expression>) { <block> }" 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 |<key>| ... end" i
do ${1:|${2:key}|}
${3:$0}
end
endsnippet
snippet Do "do ... end" i
do
${1:$0}