2012-08-16 23:41:25 -04:00
|
|
|
########################################
|
|
|
|
# Ruby snippets - for Rails, see below #
|
|
|
|
########################################
|
|
|
|
|
2013-04-13 13:45:21 -04:00
|
|
|
# encoding for Ruby 1.9
|
|
|
|
snippet enc
|
|
|
|
# encoding: utf-8
|
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
# #!/usr/bin/env ruby
|
|
|
|
snippet #!
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
# New Block
|
|
|
|
snippet =b
|
|
|
|
=begin rdoc
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
=end
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet prot
|
|
|
|
protected
|
|
|
|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet priv
|
|
|
|
private
|
|
|
|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet y
|
2013-11-16 14:45:48 -05:00
|
|
|
:yields: ${0:arguments}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rb
|
|
|
|
#!/usr/bin/env ruby -wKU
|
|
|
|
snippet beg
|
|
|
|
begin
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
rescue ${1:Exception} => ${2:e}
|
|
|
|
end
|
|
|
|
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet req require
|
2013-11-16 14:45:48 -05:00
|
|
|
require "${1}"
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet reqr
|
2013-11-16 14:45:48 -05:00
|
|
|
require_relative "${1}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet #
|
|
|
|
# =>
|
|
|
|
snippet end
|
|
|
|
__END__
|
|
|
|
snippet case
|
|
|
|
case ${1:object}
|
|
|
|
when ${2:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet when
|
|
|
|
when ${1:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet def
|
|
|
|
def ${1:method_name}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet deft
|
|
|
|
def test_${1:case_name}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
|
|
|
end
|
|
|
|
snippet descendants
|
|
|
|
class Class
|
|
|
|
def descendants
|
|
|
|
ObjectSpace.each_object(::Class).select {|klass| klass < self }
|
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet if
|
|
|
|
if ${1:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet ife
|
|
|
|
if ${1:condition}
|
|
|
|
${2}
|
|
|
|
else
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet eif
|
2012-08-16 23:41:25 -04:00
|
|
|
elsif ${1:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet unless
|
|
|
|
unless ${1:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
snippet wh
|
2012-08-16 23:41:25 -04:00
|
|
|
while ${1:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet for
|
|
|
|
for ${1:e} in ${2:c}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet until
|
|
|
|
until ${1:condition}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet cla class .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet cla class .. initialize .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
|
2012-08-16 23:41:25 -04:00
|
|
|
def initialize(${2:args})
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet cla class .. < ParentClass .. initialize .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass}
|
2012-08-16 23:41:25 -04:00
|
|
|
def initialize(${3:args})
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet cla ClassName = Struct .. do .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do
|
2012-08-16 23:41:25 -04:00
|
|
|
def ${3:method_name}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet cla class BlankSlate .. initialize .. end
|
2013-11-16 14:45:48 -05:00
|
|
|
class ${0:BlankSlate}
|
2012-08-16 23:41:25 -04:00
|
|
|
instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
|
|
|
|
end
|
|
|
|
snippet cla class << self .. end
|
|
|
|
class << ${1:self}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# class .. < DelegateClass .. initialize .. end
|
|
|
|
snippet cla-
|
2013-07-17 19:06:05 -04:00
|
|
|
class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < DelegateClass(${2:ParentClass})
|
2012-08-16 23:41:25 -04:00
|
|
|
def initialize(${3:args})
|
|
|
|
super(${4:del_obj})
|
|
|
|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet mod module .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet mod module .. module_function .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
|
2012-08-16 23:41:25 -04:00
|
|
|
module_function
|
|
|
|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet mod module .. ClassMethods .. end
|
2013-07-17 19:06:05 -04:00
|
|
|
module ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
|
2012-08-16 23:41:25 -04:00
|
|
|
module ClassMethods
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
module InstanceMethods
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.included(receiver)
|
|
|
|
receiver.extend ClassMethods
|
|
|
|
receiver.send :include, InstanceMethods
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# attr_reader
|
|
|
|
snippet r
|
2013-11-16 14:45:48 -05:00
|
|
|
attr_reader :${0:attr_names}
|
2012-08-16 23:41:25 -04:00
|
|
|
# attr_writer
|
|
|
|
snippet w
|
2013-11-16 14:45:48 -05:00
|
|
|
attr_writer :${0:attr_names}
|
2012-08-16 23:41:25 -04:00
|
|
|
# attr_accessor
|
|
|
|
snippet rw
|
2013-11-16 14:45:48 -05:00
|
|
|
attr_accessor :${0:attr_names}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet atp
|
2013-11-16 14:45:48 -05:00
|
|
|
attr_protected :${0:attr_names}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ata
|
2013-11-16 14:45:48 -05:00
|
|
|
attr_accessible :${0:attr_names}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ana
|
2013-11-16 14:45:48 -05:00
|
|
|
accepts_nested_attributes_for :${0:association}
|
2013-07-17 19:06:05 -04:00
|
|
|
# ivc == instance variable cache
|
|
|
|
snippet ivc
|
2013-11-16 14:45:48 -05:00
|
|
|
@${1:variable_name} ||= ${0:chached_value}
|
2012-08-16 23:41:25 -04:00
|
|
|
# include Enumerable
|
|
|
|
snippet Enum
|
|
|
|
include Enumerable
|
|
|
|
|
|
|
|
def each(&block)
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# include Comparable
|
|
|
|
snippet Comp
|
|
|
|
include Comparable
|
|
|
|
|
|
|
|
def <=>(other)
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# extend Forwardable
|
|
|
|
snippet Forw-
|
|
|
|
extend Forwardable
|
|
|
|
# def self
|
|
|
|
snippet defs
|
|
|
|
def self.${1:class_method_name}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
# def initialize
|
|
|
|
snippet definit
|
|
|
|
def initialize(${1:args})
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
# def method_missing
|
|
|
|
snippet defmm
|
|
|
|
def method_missing(meth, *args, &blk)
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet defd
|
2013-11-16 14:45:48 -05:00
|
|
|
def_delegator :${1:@del_obj}, :${2:del_meth}, :${0:new_name}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defds
|
2013-11-16 14:45:48 -05:00
|
|
|
def_delegators :${1:@del_obj}, :${0:del_methods}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet am
|
2013-11-16 14:45:48 -05:00
|
|
|
alias_method :${1:new_name}, :${0:old_name}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet app
|
|
|
|
if __FILE__ == $PROGRAM_NAME
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# usage_if()
|
|
|
|
snippet usai
|
|
|
|
if ARGV.${1}
|
2013-11-16 14:45:48 -05:00
|
|
|
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# usage_unless()
|
|
|
|
snippet usau
|
|
|
|
unless ARGV.${1}
|
2013-11-16 14:45:48 -05:00
|
|
|
abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet array
|
2013-11-16 14:45:48 -05:00
|
|
|
Array.new(${1:10}) { |${2:i}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet hash
|
2013-11-16 14:45:48 -05:00
|
|
|
Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet file File.foreach() { |line| .. }
|
2013-11-16 14:45:48 -05:00
|
|
|
File.foreach(${1:"path/to/file"}) { |${2:line}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet file File.read()
|
2013-11-16 14:45:48 -05:00
|
|
|
File.read(${1:"path/to/file"})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet Dir Dir.global() { |file| .. }
|
2013-11-16 14:45:48 -05:00
|
|
|
Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet Dir Dir[".."]
|
2013-11-16 14:45:48 -05:00
|
|
|
Dir[${1:"glob/**/*.rb"}]
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet dir
|
|
|
|
Filename.dirname(__FILE__)
|
|
|
|
snippet deli
|
2013-11-16 14:45:48 -05:00
|
|
|
delete_if { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet fil
|
2013-11-16 14:45:48 -05:00
|
|
|
fill(${1:range}) { |${2:i}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
# flatten_once()
|
|
|
|
snippet flao
|
2013-11-16 14:45:48 -05:00
|
|
|
inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet zip
|
2013-11-16 14:45:48 -05:00
|
|
|
zip(${1:enums}) { |${2:row}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
# downto(0) { |n| .. }
|
|
|
|
snippet dow
|
2013-11-16 14:45:48 -05:00
|
|
|
downto(${1:0}) { |${2:n}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ste
|
2013-11-16 14:45:48 -05:00
|
|
|
step(${1:2}) { |${2:n}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet tim
|
2013-11-16 14:45:48 -05:00
|
|
|
times { |${1:n}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet upt
|
2013-11-16 14:45:48 -05:00
|
|
|
upto(${1:1.0/0.0}) { |${2:n}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet loo
|
2013-11-16 14:45:48 -05:00
|
|
|
loop { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ea
|
2013-11-16 14:45:48 -05:00
|
|
|
each { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ead
|
|
|
|
each do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eab
|
2013-11-16 14:45:48 -05:00
|
|
|
each_byte { |${1:byte}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eac- each_char { |chr| .. }
|
2013-11-16 14:45:48 -05:00
|
|
|
each_char { |${1:chr}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eac- each_cons(..) { |group| .. }
|
2013-11-16 14:45:48 -05:00
|
|
|
each_cons(${1:2}) { |${2:group}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eai
|
2013-11-16 14:45:48 -05:00
|
|
|
each_index { |${1:i}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eaid
|
|
|
|
each_index do |${1:i}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eak
|
2013-11-16 14:45:48 -05:00
|
|
|
each_key { |${1:key}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eakd
|
|
|
|
each_key do |${1:key}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eal
|
2013-11-16 14:45:48 -05:00
|
|
|
each_line { |${1:line}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eald
|
|
|
|
each_line do |${1:line}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eap
|
2013-11-16 14:45:48 -05:00
|
|
|
each_pair { |${1:name}, ${2:val}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eapd
|
|
|
|
each_pair do |${1:name}, ${2:val}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eas-
|
2013-11-16 14:45:48 -05:00
|
|
|
each_slice(${1:2}) { |${2:group}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet easd-
|
|
|
|
each_slice(${1:2}) do |${2:group}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eav
|
2013-11-16 14:45:48 -05:00
|
|
|
each_value { |${1:val}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eavd
|
|
|
|
each_value do |${1:val}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet eawi
|
2013-11-16 14:45:48 -05:00
|
|
|
each_with_index { |${1:e}, ${2:i}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet eawid
|
2013-04-13 13:45:21 -04:00
|
|
|
each_with_index do |${1:e}, ${2:i}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet eawo
|
2013-11-16 14:45:48 -05:00
|
|
|
each_with_object(${1:init}) { |${2:e}, ${3:var}| ${0} }
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet eawod
|
|
|
|
each_with_object(${1:init}) do |${2:e}, ${3:var}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-04-13 13:45:21 -04:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet reve
|
2013-11-16 14:45:48 -05:00
|
|
|
reverse_each { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet reved
|
|
|
|
reverse_each do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet inj
|
2013-11-16 14:45:48 -05:00
|
|
|
inject(${1:init}) { |${2:mem}, ${3:var}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet injd
|
|
|
|
inject(${1:init}) do |${2:mem}, ${3:var}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet red
|
2013-11-16 14:45:48 -05:00
|
|
|
reduce(${1:init}) { |${2:mem}, ${3:var}| ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet redd
|
|
|
|
reduce(${1:init}) do |${2:mem}, ${3:var}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet map
|
2013-11-16 14:45:48 -05:00
|
|
|
map { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mapd
|
|
|
|
map do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet mapwi-
|
2013-11-16 14:45:48 -05:00
|
|
|
enum_with_index.map { |${1:e}, ${2:i}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sor
|
2013-11-16 14:45:48 -05:00
|
|
|
sort { |a, b| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sorb
|
2013-11-16 14:45:48 -05:00
|
|
|
sort_by { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ran
|
|
|
|
sort_by { rand }
|
|
|
|
snippet all
|
2013-11-16 14:45:48 -05:00
|
|
|
all? { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet any
|
2013-11-16 14:45:48 -05:00
|
|
|
any? { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet cl
|
2013-11-16 14:45:48 -05:00
|
|
|
classify { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet col
|
2013-11-16 14:45:48 -05:00
|
|
|
collect { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet cold
|
|
|
|
collect do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet det
|
2013-11-16 14:45:48 -05:00
|
|
|
detect { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet detd
|
|
|
|
detect do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet fet
|
2013-11-16 14:45:48 -05:00
|
|
|
fetch(${1:name}) { |${2:key}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet fin
|
2013-11-16 14:45:48 -05:00
|
|
|
find { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet find
|
|
|
|
find do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet fina
|
2013-11-16 14:45:48 -05:00
|
|
|
find_all { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet finad
|
|
|
|
find_all do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet gre
|
2013-11-16 14:45:48 -05:00
|
|
|
grep(${1:/pattern/}) { |${2:match}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sub
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:g}sub(${2:/pattern/}) { |${3:match}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sca
|
2013-11-16 14:45:48 -05:00
|
|
|
scan(${1:/pattern/}) { |${2:match}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet scad
|
|
|
|
scan(${1:/pattern/}) do |${2:match}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet max
|
2013-11-16 14:45:48 -05:00
|
|
|
max { |a, b| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet min
|
2013-11-16 14:45:48 -05:00
|
|
|
min { |a, b| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet par
|
2013-11-16 14:45:48 -05:00
|
|
|
partition { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet pard
|
|
|
|
partition do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet rej
|
2013-11-16 14:45:48 -05:00
|
|
|
reject { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rejd
|
|
|
|
reject do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet sel
|
2013-11-16 14:45:48 -05:00
|
|
|
select { |${1:e}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet seld
|
|
|
|
select do |${1:e}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet lam
|
2013-11-16 14:45:48 -05:00
|
|
|
lambda { |${1:args}| ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
# I'm pretty sure that ruby users expect do to expand to do .. end
|
|
|
|
snippet do
|
2012-08-16 23:41:25 -04:00
|
|
|
do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
# this is for one or more variables. typing a ", " is that cheap that it may
|
|
|
|
# not be worth adding another snippet. should 0/1 placeholders change order?
|
|
|
|
# its a good idea to think about the var name, so use it first
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet dov
|
2013-11-16 14:45:48 -05:00
|
|
|
do |${1:v}|
|
|
|
|
${2}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet :
|
2013-11-16 14:45:48 -05:00
|
|
|
:${1:key} => ${2:"value"}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ope
|
2013-11-16 14:45:48 -05:00
|
|
|
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
# path_from_here()
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet fpath
|
2013-11-16 14:45:48 -05:00
|
|
|
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])
|
2012-08-16 23:41:25 -04:00
|
|
|
# unix_filter {}
|
|
|
|
snippet unif
|
|
|
|
ARGF.each_line${1} do |${2:line}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# option_parse {}
|
|
|
|
snippet optp
|
|
|
|
require "optparse"
|
|
|
|
|
2013-11-16 14:45:48 -05:00
|
|
|
options = {${0:default => "args"}}
|
2012-08-16 23:41:25 -04:00
|
|
|
|
|
|
|
ARGV.options do |opts|
|
|
|
|
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
|
|
|
|
snippet opt
|
|
|
|
opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
|
|
|
|
"${4:Option description.}") do |${5:opt}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet tc
|
|
|
|
require "test/unit"
|
|
|
|
|
|
|
|
require "${1:library_file_name}"
|
|
|
|
|
|
|
|
class Test${2:$1} < Test::Unit::TestCase
|
|
|
|
def test_${3:case_name}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet ts
|
|
|
|
require "test/unit"
|
|
|
|
|
|
|
|
require "tc_${1:test_case_file}"
|
2013-11-16 14:45:48 -05:00
|
|
|
require "tc_${2:test_case_file}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet as
|
2013-11-16 14:45:48 -05:00
|
|
|
assert ${1:test}, "${2:Failure message.}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ase
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_equal ${1:expected}, ${2:actual}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asne
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_not_equal ${1:unexpected}, ${2:actual}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asid
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2 ** -20}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asio
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_instance_of ${1:ExpectedClass}, ${2:actual_instance}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asko
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_kind_of ${1:ExpectedKind}, ${2:actual_instance}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asn
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_nil ${1:instance}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asnn
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_not_nil ${1:instance}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asm
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_match /${1:expected_pattern}/, ${2:actual_string}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asnm
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_no_match /${1:unexpected_pattern}/, ${2:actual_string}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet aso
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_operator ${1:left}, :${2:operator}, ${3:right}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asr
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_raise ${1:Exception} { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asrd
|
|
|
|
assert_raise ${1:Exception} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet asnr
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_nothing_raised ${1:Exception} { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asnrd
|
|
|
|
assert_nothing_raised ${1:Exception} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet asrt
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_respond_to ${1:object}, :${2:method}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ass assert_same(..)
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_same ${1:expected}, ${2:actual}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ass assert_send(..)
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_send [${1:object}, :${2:message}, ${3:args}]
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asns
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_not_same ${1:unexpected}, ${2:actual}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ast
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_throws :${1:expected} { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet astd
|
|
|
|
assert_throws :${1:expected} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet asnt
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_nothing_thrown { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asntd
|
|
|
|
assert_nothing_thrown do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet fl
|
2013-11-16 14:45:48 -05:00
|
|
|
flunk "${1:Failure message.}"
|
2012-08-16 23:41:25 -04:00
|
|
|
# Benchmark.bmbm do .. end
|
|
|
|
snippet bm-
|
|
|
|
TESTS = ${1:10_000}
|
|
|
|
Benchmark.bmbm do |results|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet rep
|
2013-11-16 14:45:48 -05:00
|
|
|
results.report("${1:name}:") { TESTS.times { ${0} }}
|
2012-08-16 23:41:25 -04:00
|
|
|
# Marshal.dump(.., file)
|
|
|
|
snippet Md
|
2013-11-16 14:45:48 -05:00
|
|
|
File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }
|
2012-08-16 23:41:25 -04:00
|
|
|
# Mashal.load(obj)
|
|
|
|
snippet Ml
|
2013-11-16 14:45:48 -05:00
|
|
|
File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }
|
2012-08-16 23:41:25 -04:00
|
|
|
# deep_copy(..)
|
|
|
|
snippet deec
|
2013-11-16 14:45:48 -05:00
|
|
|
Marshal.load(Marshal.dump(${1:obj_to_copy}))
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet Pn-
|
2013-11-16 14:45:48 -05:00
|
|
|
PStore.new(${1:"file_name.pstore"})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet tra
|
2013-11-16 14:45:48 -05:00
|
|
|
transaction(${1:true}) { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
# xmlread(..)
|
|
|
|
snippet xml-
|
2013-11-16 14:45:48 -05:00
|
|
|
REXML::Document.new(File.read(${1:"path/to/file"}))
|
2012-08-16 23:41:25 -04:00
|
|
|
# xpath(..) { .. }
|
|
|
|
snippet xpa
|
|
|
|
elements.each(${1:"//Xpath"}) do |${2:node}|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# class_from_name()
|
|
|
|
snippet clafn
|
|
|
|
split("::").inject(Object) { |par, const| par.const_get(const) }
|
|
|
|
# singleton_class()
|
|
|
|
snippet sinc
|
|
|
|
class << self; self end
|
|
|
|
snippet nam
|
2013-07-17 19:06:05 -04:00
|
|
|
namespace :${1:`vim_snippets#Filename()`} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet tas
|
|
|
|
desc "${1:Task description}"
|
|
|
|
task :${2:task_name => [:dependent, :tasks]} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
# block
|
|
|
|
snippet b
|
2013-11-16 14:45:48 -05:00
|
|
|
{ |${1:var}| ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet begin
|
|
|
|
begin
|
|
|
|
raise 'A test exception.'
|
|
|
|
rescue Exception => e
|
|
|
|
puts e.message
|
|
|
|
puts e.backtrace.inspect
|
|
|
|
else
|
|
|
|
# other exception
|
|
|
|
ensure
|
|
|
|
# always executed
|
|
|
|
end
|
|
|
|
|
|
|
|
#debugging
|
|
|
|
snippet debug
|
|
|
|
require 'ruby-debug'; debugger; true;
|
|
|
|
snippet pry
|
|
|
|
require 'pry'; binding.pry
|
2013-11-16 14:45:48 -05:00
|
|
|
snippet strf
|
|
|
|
strftime("${1:%Y-%m-%d %H:%M:%S %z}")${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
#############################################
|
|
|
|
# Rails snippets - for pure Ruby, see above #
|
|
|
|
#############################################
|
|
|
|
snippet art
|
|
|
|
assert_redirected_to ${1::action => "${2:index}"}
|
|
|
|
snippet artnp
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_redirected_to ${1:parent}_${2:child}_path(${3:@$1}, ${0:@$2})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet artnpp
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_redirected_to ${1:parent}_${2:child}_path(${0:@$1})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet artp
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_redirected_to ${1:model}_path(${0:@$1})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet artpp
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_redirected_to ${0:model}s_path
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asd
|
2013-07-17 19:06:05 -04:00
|
|
|
assert_difference "${1:Model}.${2:count}", ${3:1} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet asnd
|
|
|
|
assert_no_difference "${1:Model}.${2:count}" do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet asre
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_response :${1:success}, @response.body
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet asrj
|
2013-11-16 14:45:48 -05:00
|
|
|
assert_rjs :${1:replace}, "${0:dom id}"
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet ass assert_select(..)
|
2012-08-16 23:41:25 -04:00
|
|
|
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
|
|
|
|
snippet bf
|
2013-11-16 14:45:48 -05:00
|
|
|
before_filter :${0:method}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet bt
|
2013-11-16 14:45:48 -05:00
|
|
|
belongs_to :${0:association}
|
2013-05-04 16:32:47 -04:00
|
|
|
snippet btp
|
2013-11-16 14:45:48 -05:00
|
|
|
belongs_to :${1:association}, :polymorphic => true
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet crw
|
2013-11-16 14:45:48 -05:00
|
|
|
cattr_accessor :${0:attr_names}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defcreate
|
|
|
|
def create
|
|
|
|
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
2012-08-16 23:41:25 -04:00
|
|
|
if @$1.save
|
|
|
|
flash[:notice] = '$2 was successfully created.'
|
2013-07-17 19:06:05 -04:00
|
|
|
format.html { redirect_to(@$1) }
|
|
|
|
format.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
2012-08-16 23:41:25 -04:00
|
|
|
else
|
2013-07-17 19:06:05 -04:00
|
|
|
format.html { render :action => "new" }
|
|
|
|
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defdestroy
|
|
|
|
def destroy
|
|
|
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
|
|
|
@$1.destroy
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to($1s_url) }
|
|
|
|
format.xml { head :ok }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defedit
|
|
|
|
def edit
|
2013-11-16 14:45:48 -05:00
|
|
|
@${1:model_class_name} = ${0:ModelClassName}.find(params[:id])
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet defindex
|
|
|
|
def index
|
|
|
|
@${1:model_class_name} = ${2:ModelClassName}.all
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html # index.html.erb
|
|
|
|
format.xml { render :xml => @$1s }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defnew
|
|
|
|
def new
|
|
|
|
@${1:model_class_name} = ${2:ModelClassName}.new
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html # new.html.erb
|
|
|
|
format.xml { render :xml => @$1 }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defshow
|
|
|
|
def show
|
|
|
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html # show.html.erb
|
|
|
|
format.xml { render :xml => @$1 }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defupdate
|
|
|
|
def update
|
|
|
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
2012-08-16 23:41:25 -04:00
|
|
|
if @$1.update_attributes(params[:$1])
|
|
|
|
flash[:notice] = '$2 was successfully updated.'
|
2013-07-17 19:06:05 -04:00
|
|
|
format.html { redirect_to(@$1) }
|
|
|
|
format.xml { head :ok }
|
2012-08-16 23:41:25 -04:00
|
|
|
else
|
2013-07-17 19:06:05 -04:00
|
|
|
format.html { render :action => "edit" }
|
|
|
|
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
2013-11-16 14:45:48 -05:00
|
|
|
end
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet dele delegate .. to
|
2013-11-16 14:45:48 -05:00
|
|
|
delegate :${1:methods}, :to => :${0:object}
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet dele delegate .. to .. prefix .. allow_nil
|
2013-11-16 14:45:48 -05:00
|
|
|
delegate :${1:methods}, :to => :${2:object}, :prefix => :${3:prefix}, :allow_nil => ${0:allow_nil}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet flash
|
2013-11-16 14:45:48 -05:00
|
|
|
flash[:${1:notice}] = "${0}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet habtm
|
2013-11-16 14:45:48 -05:00
|
|
|
has_and_belongs_to_many :${1:object}, :join_table => "${2:table_name}", :foreign_key => "${3}_id"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet hm
|
2013-11-16 14:45:48 -05:00
|
|
|
has_many :${0:object}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet hmd
|
2013-11-16 14:45:48 -05:00
|
|
|
has_many :${1:other}s, :class_name => "${2:$1}", :foreign_key => "${3:$1}_id", :dependent => :destroy
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet hmt
|
2013-11-16 14:45:48 -05:00
|
|
|
has_many :${1:object}, :through => :${0:object}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ho
|
2013-11-16 14:45:48 -05:00
|
|
|
has_one :${0:object}
|
2013-05-25 20:31:29 -04:00
|
|
|
snippet hod
|
2013-11-16 14:45:48 -05:00
|
|
|
has_one :${1:object}, dependent: :${0:destroy}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet i18
|
2013-11-16 14:45:48 -05:00
|
|
|
I18n.t('${1:type.key}')
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ist
|
2013-11-16 14:45:48 -05:00
|
|
|
<%= image_submit_tag("${1:agree.png}", :id => "${2:id}"${0} %>
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet log
|
2013-11-16 14:45:48 -05:00
|
|
|
Rails.logger.${1:debug} ${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet log2
|
2013-11-16 14:45:48 -05:00
|
|
|
RAILS_DEFAULT_LOGGER.${1:debug} ${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet logd
|
2013-11-16 14:45:48 -05:00
|
|
|
logger.debug { "${1:message}" }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet loge
|
2013-11-16 14:45:48 -05:00
|
|
|
logger.error { "${1:message}" }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet logf
|
2013-11-16 14:45:48 -05:00
|
|
|
logger.fatal { "${1:message}" }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet logi
|
2013-11-16 14:45:48 -05:00
|
|
|
logger.info { "${1:message}" }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet logw
|
2013-11-16 14:45:48 -05:00
|
|
|
logger.warn { "${1:message}" }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mapc
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:map}.${2:connect} '${0:controller/:action/:id}'
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mapca
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mapr
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:map}.resource :${0:resource}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet maprs
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:map}.resources :${0:resource}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mapwo
|
|
|
|
${1:map}.with_options :${2:controller} => '${3:thing}' do |$3|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet mbs
|
2013-11-16 14:45:48 -05:00
|
|
|
before_save :${0:method}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mcht
|
|
|
|
change_table :${1:table_name} do |t|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet mp
|
2013-11-16 14:45:48 -05:00
|
|
|
map(&:${0:id})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mrw
|
2013-11-16 14:45:48 -05:00
|
|
|
mattr_accessor :${0:attr_names}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet oa
|
2013-11-16 14:45:48 -05:00
|
|
|
order("${0:field}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet od
|
2013-11-16 14:45:48 -05:00
|
|
|
order("${0:field} DESC")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet pa
|
2013-11-16 14:45:48 -05:00
|
|
|
params[:${1:id}]
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ra
|
2013-11-16 14:45:48 -05:00
|
|
|
render :action => "${0:action}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ral
|
2013-11-16 14:45:48 -05:00
|
|
|
render :action => "${1:action}", :layout => "${0:layoutname}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rest
|
2013-07-17 19:06:05 -04:00
|
|
|
respond_to do |format|
|
2013-11-16 14:45:48 -05:00
|
|
|
format.${1:html} { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet rf
|
2013-11-16 14:45:48 -05:00
|
|
|
render :file => "${0:filepath}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rfu
|
2013-11-16 14:45:48 -05:00
|
|
|
render :file => "${1:filepath}", :use_full_path => ${0:false}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ri
|
2013-11-16 14:45:48 -05:00
|
|
|
render :inline => "${0:<%= 'hello' %>}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ril
|
2013-11-16 14:45:48 -05:00
|
|
|
render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rit
|
2013-11-16 14:45:48 -05:00
|
|
|
render :inline => "${1:<%= 'hello' %>}", :type => ${0::rxml}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rjson
|
2013-11-16 14:45:48 -05:00
|
|
|
render :json => ${0:text to render}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rl
|
2013-11-16 14:45:48 -05:00
|
|
|
render :layout => "${0:layoutname}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rn
|
2013-11-16 14:45:48 -05:00
|
|
|
render :nothing => ${0:true}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rns
|
2013-11-16 14:45:48 -05:00
|
|
|
render :nothing => ${1:true}, :status => ${0:401}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rp
|
2013-11-16 14:45:48 -05:00
|
|
|
render :partial => "${0:item}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rpc
|
2013-11-16 14:45:48 -05:00
|
|
|
render :partial => "${1:item}", :collection => ${0:@$1s}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rpl
|
2013-11-16 14:45:48 -05:00
|
|
|
render :partial => "${1:item}", :locals => { :${2:$1} => ${0:@$1}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rpo
|
2013-11-16 14:45:48 -05:00
|
|
|
render :partial => "${1:item}", :object => ${0:@$1}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rps
|
2013-11-16 14:45:48 -05:00
|
|
|
render :partial => "${1:item}", :status => ${0:500}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rt
|
2013-11-16 14:45:48 -05:00
|
|
|
render :text => "${0:text to render}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rtl
|
2013-11-16 14:45:48 -05:00
|
|
|
render :text => "${1:text to render}", :layout => "${0:layoutname}"
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rtlt
|
2013-11-16 14:45:48 -05:00
|
|
|
render :text => "${1:text to render}", :layout => ${0:true}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet rts
|
2013-11-16 14:45:48 -05:00
|
|
|
render :text => "${1:text to render}", :status => ${0:401}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ru
|
|
|
|
render :update do |${1:page}|
|
2013-11-16 14:45:48 -05:00
|
|
|
$1.${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet rxml
|
2013-11-16 14:45:48 -05:00
|
|
|
render :xml => ${0:text to render}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sc
|
2013-11-16 14:45:48 -05:00
|
|
|
scope :${1:name}, -> { where(${2:field}: ${0:value}) }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sl
|
|
|
|
scope :${1:name}, lambda do |${2:value}|
|
2013-11-16 14:45:48 -05:00
|
|
|
where("${3:field = ?}", ${0:bind var})
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet sha1
|
2013-11-16 14:45:48 -05:00
|
|
|
Digest::SHA1.hexdigest(${0:string})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet sweeper
|
|
|
|
class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper
|
|
|
|
observe $1
|
|
|
|
|
2013-11-16 14:45:48 -05:00
|
|
|
def after_save(${0:model_class_name})
|
2012-08-16 23:41:25 -04:00
|
|
|
expire_cache($2)
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_destroy($2)
|
|
|
|
expire_cache($2)
|
|
|
|
end
|
|
|
|
|
|
|
|
def expire_cache($2)
|
|
|
|
expire_page
|
|
|
|
end
|
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet va validates_associated
|
2013-11-16 14:45:48 -05:00
|
|
|
validates_associated :${0:attribute}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet va validates .., :acceptance => true
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${0:terms}, :acceptance => true
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vc
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${0:attribute}, :confirmation => true
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet ve
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${1:attribute}, :exclusion => { :in => ${0:%w( mov avi )} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vf
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${1:attribute}, :format => { :with => /${0:regex}/ }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vi
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${1:attribute}, :inclusion => { :in => %w(${0: mov avi }) }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vl
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${1:attribute}, :length => { :in => ${2:3}..${0:20} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vn
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${0:attribute}, :numericality => true
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet vp
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${0:attribute}, :presence => true
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet vu
|
2013-11-16 14:45:48 -05:00
|
|
|
validates :${0:attribute}, :uniqueness => true
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet format
|
2013-11-16 14:45:48 -05:00
|
|
|
format.${1:js|xml|html} { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet wc
|
2013-11-16 14:45:48 -05:00
|
|
|
where(${1:"conditions"}${0:, bind_var})
|
|
|
|
snippet wf
|
|
|
|
where(${1:field} => ${0:value})
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet xdelete
|
2013-11-16 14:45:48 -05:00
|
|
|
xhr :delete, :${1:destroy}, :id => ${2:1}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet xget
|
2013-11-16 14:45:48 -05:00
|
|
|
xhr :get, :${1:show}, :id => ${2:1}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet xpost
|
2013-11-16 14:45:48 -05:00
|
|
|
xhr :post, :${1:create}, :${2:object} => { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet xput
|
2013-11-16 14:45:48 -05:00
|
|
|
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet test
|
|
|
|
test "should ${1:do something}" do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
###########################
|
|
|
|
# migrations snippets #
|
|
|
|
###########################
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mac
|
2013-11-16 14:45:48 -05:00
|
|
|
add_column :${1:table_name}, :${2:column_name}, :${0:data_type}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet mai
|
2013-11-16 14:45:48 -05:00
|
|
|
add_index :${1:table_name}, :${0:column_name}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mrc
|
2013-11-16 14:45:48 -05:00
|
|
|
remove_column :${1:table_name}, :${0:column_name}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mrnc
|
2013-11-16 14:45:48 -05:00
|
|
|
rename_column :${1:table_name}, :${2:old_column_name}, :${0:new_column_name}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mcc
|
2013-11-16 14:45:48 -05:00
|
|
|
change_column :${1:table}, :${2:column}, :${0:type}
|
2013-05-04 16:32:47 -04:00
|
|
|
snippet mnc
|
2013-11-16 14:45:48 -05:00
|
|
|
t.${1:string} :${2:title}${3:, null: false}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet mct
|
|
|
|
create_table :${1:table_name} do |t|
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-05-04 16:32:47 -04:00
|
|
|
snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end
|
2012-08-16 23:41:25 -04:00
|
|
|
class ${1:class_name} < ActiveRecord::Migration
|
2013-05-04 16:32:47 -04:00
|
|
|
def up
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
|
2013-05-04 16:32:47 -04:00
|
|
|
def down
|
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet migration class .. < ActiveRecord::Migration .. def change .. end
|
|
|
|
class ${1:class_name} < ActiveRecord::Migration
|
|
|
|
def change
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
snippet trc
|
2013-11-16 14:45:48 -05:00
|
|
|
t.remove :${0:column}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet tre
|
|
|
|
t.rename :${1:old_column_name}, :${2:new_column_name}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet tref
|
2013-11-16 14:45:48 -05:00
|
|
|
t.references :${0:model}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcb
|
|
|
|
t.boolean :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcbi
|
|
|
|
t.binary :${1:title}, :limit => ${2:2}.megabytes
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcd
|
|
|
|
t.decimal :${1:title}, :precision => ${2:10}, :scale => ${3:2}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcda
|
|
|
|
t.date :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcdt
|
|
|
|
t.datetime :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcf
|
|
|
|
t.float :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tch
|
|
|
|
t.change :${1:name}, :${2:string}, :${3:limit} => ${4:80}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tci
|
|
|
|
t.integer :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcl
|
|
|
|
t.integer :lock_version, :null => false, :default => 0
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcr
|
|
|
|
t.references :${1:taggable}, :polymorphic => { :default => '${2:Photo}' }
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcs
|
|
|
|
t.string :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tct
|
|
|
|
t.text :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcti
|
|
|
|
t.time :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tcts
|
|
|
|
t.timestamp :${1:title}
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet tctss
|
|
|
|
t.timestamps
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
##########################
|
|
|
|
# Rspec snippets #
|
|
|
|
##########################
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet desc
|
2013-11-16 14:45:48 -05:00
|
|
|
describe ${1:`substitute(substitute(vim_snippets#Filename(), '_spec$', '', ''), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
|
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet descm
|
|
|
|
describe "${1:#method}" do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0:pending "Not implemented"}
|
2013-07-17 19:06:05 -04:00
|
|
|
end
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet cont
|
|
|
|
context "${1:message}" do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet bef
|
|
|
|
before :${1:each} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
|
|
|
snippet aft
|
|
|
|
after :${1:each} do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
end
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet let
|
2013-11-16 14:45:48 -05:00
|
|
|
let(:${1:object}) ${0}
|
2013-05-04 16:32:47 -04:00
|
|
|
snippet let!
|
2013-11-16 14:45:48 -05:00
|
|
|
let!(:${1:object}) ${0}
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet subj
|
2013-11-16 14:45:48 -05:00
|
|
|
subject { ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet s.
|
2013-11-16 14:45:48 -05:00
|
|
|
subject.${0:method}
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet spec
|
2013-11-16 14:45:48 -05:00
|
|
|
specify { subject.${0} }
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet exp
|
2013-11-16 14:45:48 -05:00
|
|
|
expect(${1:object}).to ${0}
|
|
|
|
snippet expb
|
|
|
|
expect { ${1:object} }.to ${0}
|
|
|
|
snippet experr
|
|
|
|
expect { ${1:object} }.to raise_error ${2:StandardError}, /${0:message_regex}/
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet shared
|
2013-11-16 14:45:48 -05:00
|
|
|
shared_examples ${0:"shared examples name"}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ibl
|
2013-11-16 14:45:48 -05:00
|
|
|
it_behaves_like ${0:"shared examples name"}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet it
|
|
|
|
it "${1:spec_name}" do
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
end
|
|
|
|
snippet its
|
2013-11-16 14:45:48 -05:00
|
|
|
its(:${1:method}) { should ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet is
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isn
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should_not ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
#ShouldaMatchers#ActionController
|
|
|
|
snippet isfp
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should filter_param :${0:key} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isrt
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should redirect_to ${0:url} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isrtp
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should render_template ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isrwl
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should render_with_layout ${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isrf
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should rescue_from ${0:exception} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isrw
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should respond_with ${0:status} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isr
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should route(:${1:method}, '${0:path}') }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isss
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should set_session :${0:key} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet issf
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should set_the_flash('${0}') }
|
2013-07-17 19:06:05 -04:00
|
|
|
#ShouldaMatchers#ActiveModel
|
|
|
|
snippet isama
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should allow_mass_assignment_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isav
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should allow_value(${1}).for :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isee
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should ensure_exclusion_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isei
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should ensure_inclusion_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isel
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should ensure_length_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isva
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should validate_acceptance_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isvc
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should validate_confirmation_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isvn
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should validate_numericality_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isvp
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should validate_presence_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isvu
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should validate_uniqueness_of :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
#ShouldaMatchers#ActiveRecord
|
|
|
|
snippet isana
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should accept_nested_attributes_for :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isbt
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should belong_to :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isbtcc
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should belong_to(:${1}).counter_cache ${0:true} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ishbtm
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_and_belong_to_many :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isbv
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should be_valid }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ishc
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_db_column :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ishi
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_db_index :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ishm
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_many :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ishmt
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_many(:${1}).through :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isho
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_one :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet ishro
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should have_readonly_attribute :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet iss
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should serialize :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isres
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should respond_to :${0} }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet isresw
|
2013-11-16 14:45:48 -05:00
|
|
|
it { should respond_to(:${1}).with(${0}).arguments }
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet super_call
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:super_class}.instance_method(:${0:method}).bind(self).call
|