# File lib/rake/ext/string.rb, line 129
129:     def pathmap(spec=nil, &block)
130:       return self if spec.nil?
131:       result = ''
132:       spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
133:         case frag
134:         when '%f'
135:           result << File.basename(self)
136:         when '%n'
137:           result << File.basename(self).ext
138:         when '%d'
139:           result << File.dirname(self)
140:         when '%x'
141:           result << File.extname(self)
142:         when '%X'
143:           result << self.ext
144:         when '%p'
145:           result << self
146:         when '%s'
147:           result << (File::ALT_SEPARATOR || File::SEPARATOR)
148:         when '%-'
149:           # do nothing
150:         when '%%'
151:           result << "%"
152:         when /%(-?\d+)d/
153:           result << pathmap_partial($1.to_i)
154:         when /^%\{([^}]*)\}(\d*[dpfnxX])/
155:           patterns, operator = $1, $2
156:           result << pathmap('%' + operator).pathmap_replace(patterns, &block)
157:         when /^%/
158:           fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
159:         else
160:           result << frag
161:         end
162:       end
163:       result
164:     end