hoodwink.d enhanced

Tue Nov 14

Avoid cluttering built in classes by using just in time convenience methods

namespace :todo do class << TODOS = IO.read('TODO') def items split("\n").grep(/^\[\s|X\]/) end def completed find_items_matching(/^\[X\]/) end def uncompleted find_items_matching(/^\[\s\]/) end def find_items_matching(regexp) items.grep(regexp).instance_eval do def display puts map do |item| "* #{item.sub(/^\[[^\]]\]\s/, '')}" end end self end end end desc 'Completed todo items' task :completed do TODOS.completed.display end desc 'Incomplete todo items' task :uncompleted do TODOS.uncompleted.display end end # % rake todo:completed # * Remote ACL tests # * ACL requesting and parsing