# # File 'taskconfig.rb' created on 29 feb 2008 at 07:50:50. # # See 'dokkit.rb' or +LICENSE+ for licence information. # # (C) 2008 Andrea Fazzi (and contributors). # require 'ostruct' module Dokkit class TaskConfig < OpenStruct STRIP_SLASHES = /^\/?(.*?)\/*$/ attr_reader :config, :directories def initialize(hash = nil) super(hash) @directories = { } yield self if block_given? strip_slashes_from_dir end def directories methods.each do |meth| @directories[meth.to_sym] = send(meth.to_sym) if (meth =~ /\_dir$/) end @directories end private def strip_slashes_from_dir directories.each do |meth, dir| stripped_dir = send(meth)[STRIP_SLASHES, 1] send((meth.to_s + '=').to_sym, stripped_dir) end end end end