Project

General

Profile

« Previous | Next » 

Revision 6ff3c72f

Added by Marc Dequènes over 13 years ago

  • ID 6ff3c72f5b54d9724604f53008fd25cdba1bbc37

[evol] Interface: added case insensitive node support

View differences:

lib/cyborghood-clerk/interface/_commands/0_base.rb
node 'DNS', :dir => '_dns'
node 'DNS', :dir => '_dns', :case_insensitive => true
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