4 syms.flatten.each do |sym|
5 class_eval "def #{sym}(&block);block.call(@#{sym}) if block_given?;@#{sym};end"
12 def relative_path_from(dir)
13 Pathname.new(File.expand_path(self)).relative_path_from(Pathname.new(File.expand_path(dir))).to_s
17 relative_path_from(Dir.pwd)
20 # Compatible with 1.9 on 1.8
21 unless (sprintf("%{a}", :a => 1) rescue false)
26 str.gsub!("%{#{k}}") { v }
30 if params.is_a?(Array)
31 sprintf(self, *params)
41 # Compatible with 1.9 on 1.8
42 unless method_defined?(:to_proc)
44 proc { |obj, *args| obj.send(self, *args) }
50 # Compatible with 1.9 on 1.8
51 unless method_defined?(:each_with_object)
52 def each_with_object(memo)
53 return to_enum :each_with_object, memo unless block_given?
54 each { |obj| yield obj, memo }
63 if Rake.respond_to?(:verbose) && !Rake.verbose.nil?
64 if Rake.verbose.class == TrueClass
65 # verbose message logging
72 # could not identify rake version
76 $pp_show = false if $verbose
79 def _pp(cmd, src, tgt=nil, options={})
80 return unless $pp_show
83 template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s"
84 puts template % [cmd, src, tgt ? "-> #{tgt}" : nil]