lib/ryodo/rule_set.rb in ryodo-0.2.7 vs lib/ryodo/rule_set.rb in ryodo-0.3.0

- old
+ new

@@ -1,37 +1,29 @@ -# coding: utf-8 - module Ryodo class RuleSet - def initialize @tree = {} build! end def build! Ryodo::SuffixList.list.each do |line| - line.each.with_index do |node_name, idx| - - stopOK = node_name == line.last + stop_ok = node_name == line.last exception = node_name[0] == "!" node_name = node_name[1..-1] if exception children = {} - node = Ryodo::Rule.new(exception, stopOK, children) + node = Ryodo::Rule.new(exception, stop_ok, children) if idx > 0 end_idx = idx - 1 - parent = select_rule(line[0..end_idx]) + parent = select_rule(line[0..end_idx]) parent.children[node_name] = node unless parent.children[node_name] - else @tree[node_name] = node unless @tree[node_name] end - end - end end def select_rule(rule_path) if rule_path[-1] @@ -58,8 +50,7 @@ # only if match has no children with domain and domain is present if match && domain[0] && !match.children.keys.include?(domain[0]) [ suffix, [domain.shift], domain ] end end - end end