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