- not_needed = @defaults.has_key?($3.intern)
- s = "#{not_needed ? "(?:" : ""}#{$1}(#{$2 == ":" ? "\\S+" : ".*"})#{ not_needed ? ")?" : ""}"
+ whites = $1
+ is_single = $2 == ":"
+ name = $3.intern
+
+ not_needed = @defaults.has_key?(name)
+
+ has_req = @requirements[name]
+ debug "Requirements for #{name}: #{has_req.inspect}"
+ case has_req
+ when nil
+ sub = is_single ? "\\S+" : ".*"
+ when Regexp
+ # Remove the ^ and $ placed around requirement regexp at times
+ # They were unnecessary first, and are dangerous now
+ sub = has_req.source.sub(/^\^/,'').sub(/\$$/,'')
+ when String
+ sub = Regexp.escape(has_req)
+ else
+ warning "Odd requirement #{has_req.inspect} of class #{has_req.class} for parameter '#{name}'"
+ sub = Regexp.escape(has_req.to_s) rescue "\\S+"
+ end
+ debug "Regexp for #{name}: #{sub.inspect}"
+ s = "#{not_needed ? "(?:" : ""}#{whites}(#{sub})#{ not_needed ? ")?" : ""}"