require "highline" module Kernel def warn_with_color(message) warn_without_color HighLine.new.color(message.to_s, :red) end alias_method_chain :warn, :color end module Buildr module Attributes def self.included(mod) mod.extend(self) end # An inherited attribute gets it value from an instance variable # with the same name. If the value is not set it will defer to the # parent object. If there is no parent object, it will use the # default value; with a block, it evaluates the block by calling # instance_eval on the object. # # For example: # inherited_attr :version # inherited_attr :src_dir, "src" # inherited_attr :java_src_dir do src_dir + "/main/java" def inherited_attr(symbol, default = nil, &block) block ||= proc { default } define_method symbol do instance_variable_get("@#{symbol}") || (parent ? parent.send(symbol) : self.instance_eval(&block)) end define_method "#{symbol}=" do |value| instance_variable_set("@#{symbol}", value) end end end end