         # File lib/rake.rb, line 200
    200:     def pathmap(spec=nil, &block)
    201:       return self if spec.nil?
    202:       result = ''
    203:       spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
    204:         case frag
    205:         when '%f'
    206:           result << File.basename(self)
    207:         when '%n'
    208:           result << File.basename(self).ext
    209:         when '%d'
    210:           result << File.dirname(self)
    211:         when '%x'
    212:           result << File.extname(self)
    213:         when '%X'
    214:           result << self.ext
    215:         when '%p'
    216:           result << self
    217:         when '%s'
    218:           result << (File::ALT_SEPARATOR || File::SEPARATOR)
    219:         when '%-'
    220:           # do nothing
    221:         when '%%'
    222:           result << "%"
    223:         when /%(-?\d+)d/
    224:           result << pathmap_partial($1.to_i)
    225:         when /^%\{([^}]*)\}(\d*[dpfnxX])/
    226:           patterns, operator = $1, $2
    227:           result << pathmap('%' + operator).pathmap_replace(patterns, &block)
    228:         when /^%/
    229:           fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
    230:         else
    231:           result << frag
    232:         end
    233:       end
    234:       result
    235:     end