All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
11 :yields: ${1:arguments}
13 #!/usr/bin/env ruby -wKU
34 def test_${1:case_name}
62 snippet cla class .. end
63 class ${1:`substitute(Filename(), '^.', '\u&', '')`}
66 snippet cla class .. initialize .. end
67 class ${1:`substitute(Filename(), '^.', '\u&', '')`}
68 def initialize(${2:args})
74 snippet cla class .. < ParentClass .. initialize .. end
75 class ${1:`substitute(Filename(), '^.', '\u&', '')`} < ${2:ParentClass}
76 def initialize(${3:args})
82 snippet cla ClassName = Struct .. do .. end
83 ${1:`substitute(Filename(), '^.', '\u&', '')`} = Struct.new(:${2:attr_names}) do
90 snippet cla class BlankSlate .. initialize .. end
92 instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ }
93 snippet cla class << self .. end
97 # class .. < DelegateClass .. initialize .. end
99 class ${1:`substitute(Filename(), '^.', '\u&', '')`} < DelegateClass(${2:ParentClass})
100 def initialize(${3:args})
108 snippet mod module .. end
109 module ${1:`substitute(Filename(), '^.', '\u&', '')`}
112 snippet mod module .. module_function .. end
113 module ${1:`substitute(Filename(), '^.', '\u&', '')`}
118 snippet mod module .. ClassMethods .. end
119 module ${1:`substitute(Filename(), '^.', '\u&', '')`}
124 module InstanceMethods
128 def self.included(receiver)
129 receiver.extend ClassMethods
130 receiver.send :include, InstanceMethods
135 attr_reader :${1:attr_names}
138 attr_writer :${1:attr_names}
141 attr_accessor :${1:attr_names}
161 def self.${1:class_method_name}
166 def method_missing(meth, *args, &blk)
170 def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}
172 def_delegators :${1:@del_obj}, :${2:del_methods}
174 alias_method :${1:new_name}, :${2:old_name}
176 if __FILE__ == $PROGRAM_NAME
182 abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
187 abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${3}
190 Array.new(${1:10}) { |${2:i}| ${3} }
192 Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }
193 snippet file File.foreach() { |line| .. }
194 File.foreach(${1:"path/to/file"}) { |${2:line}| ${3} }
195 snippet file File.read()
196 File.read(${1:"path/to/file"})${2}
197 snippet Dir Dir.global() { |file| .. }
198 Dir.glob(${1:"dir/glob/*"}) { |${2:file}| ${3} }
199 snippet Dir Dir[".."]
200 Dir[${1:"glob/**/*.rb"}]${2}
202 Filename.dirname(__FILE__)
204 delete_if { |${1:e}| ${2} }
206 fill(${1:range}) { |${2:i}| ${3} }
209 inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}
211 zip(${1:enums}) { |${2:row}| ${3} }
212 # downto(0) { |n| .. }
214 downto(${1:0}) { |${2:n}| ${3} }
216 step(${1:2}) { |${2:n}| ${3} }
218 times { |${1:n}| ${2} }
220 upto(${1:1.0/0.0}) { |${2:n}| ${3} }
224 each { |${1:e}| ${2} }
226 each_byte { |${1:byte}| ${2} }
227 snippet eac- each_char { |chr| .. }
228 each_char { |${1:chr}| ${2} }
229 snippet eac- each_cons(..) { |group| .. }
230 each_cons(${1:2}) { |${2:group}| ${3} }
232 each_index { |${1:i}| ${2} }
234 each_key { |${1:key}| ${2} }
236 each_line { |${1:line}| ${2} }
238 each_pair { |${1:name}, ${2:val}| ${3} }
240 each_slice(${1:2}) { |${2:group}| ${3} }
242 each_value { |${1:val}| ${2} }
244 each_with_index { |${1:e}, ${2:i}| ${3} }
246 reverse_each { |${1:e}| ${2} }
248 inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }
250 map { |${1:e}| ${2} }
252 enum_with_index.map { |${1:e}, ${2:i}| ${3} }
256 sort_by { |${1:e}| ${2} }
260 all? { |${1:e}| ${2} }
262 any? { |${1:e}| ${2} }
264 classify { |${1:e}| ${2} }
266 collect { |${1:e}| ${2} }
268 detect { |${1:e}| ${2} }
270 fetch(${1:name}) { |${2:key}| ${3} }
272 find { |${1:e}| ${2} }
274 find_all { |${1:e}| ${2} }
276 grep(${1:/pattern/}) { |${2:match}| ${3} }
278 ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }
280 scan(${1:/pattern/}) { |${2:match}| ${3} }
286 partition { |${1:e}|, ${2} }
288 reject { |${1:e}|, ${2} }
290 select { |${1:e}|, ${2} }
292 lambda { |${1:args}| ${2} }
298 :${1:key} => ${2:"value"}${3}
300 open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
303 File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
306 ARGF.each_line${1} do |${2:line}|
313 options = {${1:default => "args"}}
315 ARGV.options do |opts|
316 opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}
318 opts.on( "-${1:o}", "--${2:long-option-name}", ${3:String},
319 "${4:Option description.}") do |${5:opt}|
325 require "${1:library_file_name}"
327 class Test${2:$1} < Test::Unit::TestCase
328 def test_${3:case_name}
335 require "tc_${1:test_case_file}"
336 require "tc_${2:test_case_file}"${3}
338 assert(${1:test}, "${2:Failure message.}")${3}
340 assert_equal(${1:expected}, ${2:actual})${3}
342 assert_not_equal(${1:unexpected}, ${2:actual})${3}
344 assert_in_delta(${1:expected_float}, ${2:actual_float}, ${3:2 ** -20})${4}
346 assert_instance_of(${1:ExpectedClass}, ${2:actual_instance})${3}
348 assert_kind_of(${1:ExpectedKind}, ${2:actual_instance})${3}
350 assert_nil(${1:instance})${2}
352 assert_not_nil(${1:instance})${2}
354 assert_match(/${1:expected_pattern}/, ${2:actual_string})${3}
356 assert_no_match(/${1:unexpected_pattern}/, ${2:actual_string})${3}
358 assert_operator(${1:left}, :${2:operator}, ${3:right})${4}
360 assert_raise(${1:Exception}) { ${2} }
362 assert_nothing_raised(${1:Exception}) { ${2} }
364 assert_respond_to(${1:object}, :${2:method})${3}
365 snippet ass assert_same(..)
366 assert_same(${1:expected}, ${2:actual})${3}
367 snippet ass assert_send(..)
368 assert_send([${1:object}, :${2:message}, ${3:args}])${4}
370 assert_not_same(${1:unexpected}, ${2:actual})${3}
372 assert_throws(:${1:expected}) { ${2} }
374 assert_nothing_thrown { ${1} }
376 flunk("${1:Failure message.}")${2}
377 # Benchmark.bmbm do .. end
380 Benchmark.bmbm do |results|
384 results.report("${1:name}:") { TESTS.times { ${2} }}
385 # Marshal.dump(.., file)
387 File.open(${1:"path/to/file.dump"}, "wb") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}
390 File.open(${1:"path/to/file.dump"}, "rb") { |${2:file}| Marshal.load($2) }${3}
393 Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}
395 PStore.new(${1:"file_name.pstore"})${2}
397 transaction(${1:true}) { ${2} }
400 REXML::Document.new(File.read(${1:"path/to/file"}))${2}
403 elements.each(${1:"//Xpath"}) do |${2:node}|
408 split("::").inject(Object) { |par, const| par.const_get(const) }
411 class << self; self end
413 namespace :${1:`Filename()`} do
417 desc "${1:Task description\}"
418 task :${2:task_name => [:dependent, :tasks]} do