Revision 6ff3c72f
Added by Marc Dequènes about 13 years ago
- ID 6ff3c72f5b54d9724604f53008fd25cdba1bbc37
lib/cyborghood/cyborg/botnet/interface.rb | ||
---|---|---|
@parent_node = parent_node
|
||
@ldir = options[:dir]
|
||
@hidden = options[:hidden] || false
|
||
@case_insensitive = options[:case_insensitive] || false
|
||
|
||
# don't call super because we need defered loading
|
||
|
||
... | ... | |
@hidden
|
||
end
|
||
|
||
def case_insensitive?
|
||
@case_insensitive
|
||
end
|
||
|
||
def node_path
|
||
return '/' if root?
|
||
|
||
... | ... | |
|
||
@nodes.each_pair do |match, node|
|
||
found = if match.is_a? String
|
||
child_node == match
|
||
if node.case_insensitive?
|
||
child_node.downcase == match.downcase
|
||
else
|
||
child_node == match
|
||
end
|
||
elsif match.is_a? Regexp
|
||
child_node =~ Regexp.new(match)
|
||
regexp_options = (node.case_insensitive? ? Regexp::IGNORECASE : nil)
|
||
child_node =~ Regexp.new(match, regexp_options)
|
||
elsif match.is_a? Proc
|
||
match.call(session, env).include? child_node
|
||
list = match.call(session, env)
|
||
if node.case_insensitive?
|
||
list.collect!{|i| i.downcase }
|
||
list.include? child_node.downcase
|
||
else
|
||
list.include? child_node
|
||
end
|
||
end
|
||
return node if found
|
||
end
|
Also available in: Unified diff
[evol] Interface: added case insensitive node support