lib/usher/node.rb in joshbuddy-usher-0.4.3 vs lib/usher/node.rb in joshbuddy-usher-0.4.5
- old
+ new
@@ -1,8 +1,8 @@
$:.unshift File.dirname(__FILE__)
-require 'fuzzy_hash'
+require '/Users/josh/Development/fuzzy_hash/lib/fuzzy_hash'
class Usher
class Node
@@ -87,14 +87,14 @@
current_node.terminates = path
end
route
end
- def find(request, path, params = [])
+ def find(usher, request, path, params = [])
if exclusive_type
[lookup[request.send(exclusive_type)], lookup[nil]].each do |n|
- if n && (ret = n.find(request, path.dup, params.dup))
+ if n && (ret = n.find(usher, request, path.dup, params.dup))
return ret
end
end
elsif path.size.zero? && terminates?
Response.new(terminates, params)
@@ -103,35 +103,35 @@
when Route::Variable
case next_part.value.type
when :*
params << [next_part.value.name, []] unless params.last && params.last.first == next_part.value.name
loop do
- if (next_part.value.look_ahead === part || (!part.is_a?(Symbol) && next_part.value.regex_matcher && !next_part.value.regex_matcher.match(part)))
+ if (next_part.value.look_ahead === part || (!usher.splitter.delimiter_chars.include?(part[0]) && next_part.value.regex_matcher && !next_part.value.regex_matcher.match(part)))
path.unshift(part)
- path.unshift(next_part.parent.value) if next_part.parent.value.is_a?(Symbol)
+ path.unshift(next_part.parent.value) if usher.splitter.delimiter_chars.include?(next_part.parent.value[0])
break
- else
- unless part.is_a?(Symbol) && !next_part.value.globs_capture_separators
- next_part.value.valid!(part)
- params.last.last << part
- end
+ elsif next_part.value.globs_capture_separators
+ params.last.last << part
+ elsif !usher.splitter.delimiter_chars.include?(part[0])
+ next_part.value.valid!(part)
+ params.last.last << part
end
if path.size.zero?
break
else
part = path.shift
end
end
when :':'
- next_part.value.valid!(part)
var = next_part.value
- params << [next_part.value.name, part]
- until (path.first == var.look_ahead) || path.empty?
- params.last.last << path.shift.to_s
+ var.valid!(part)
+ params << [var.name, part]
+ until (var.look_ahead === path.first) || path.empty?
+ params.last.last << path.shift
end
end
end
- next_part.find(request, path, params)
+ next_part.find(usher, request, path, params)
else
nil
end
end