lib/ryodo/rule_set.rb in ryodo-0.2.4.1 vs lib/ryodo/rule_set.rb in ryodo-0.2.5
- old
+ new
@@ -11,17 +11,16 @@
def build!
Ryodo::SuffixList.list.each do |line|
line.each.with_index do |node_name, idx|
- stopOK = node_name == line.last
+ stopOK = node_name == line.last
exception = node_name[0] == "!"
node_name = node_name[1..-1] if exception
- children = {}
+ children = {}
+ node = Ryodo::Rule.new(exception, stopOK, children)
- node = Ryodo::Rule.new(exception, stopOK, children)
-
if idx > 0
end_idx = idx - 1
parent = select_rule(line[0..end_idx])
parent.children[node_name] = node unless parent.children[node_name]
@@ -46,19 +45,19 @@
def match(path)
suffix, domain, match = [], [], nil
until match || path.empty?
- match = select_rule(path) || select_rule(path.dup.fill("*",-1))
- match = nil if match && !match.is_suffix?
+ match = select_rule(path) || select_rule(path.dup.fill("*",-1))
+ match = nil if match && !match.is_suffix?
domain.unshift path.pop
suffix = path
end
suffix.push(domain.shift) if match && !match.exception
# only if match has no children with domain and domain is present
- if match && !match.children.keys.include?(domain[0]) && domain[0]
+ if match && domain[0] && !match.children.keys.include?(domain[0])
[ suffix, [domain.shift], domain ]
end
end
end