lib/hx.rb in hx-0.14.0 vs lib/hx.rb in hx-0.15.0

- old
+ new

@@ -156,13 +156,11 @@ def initialize(input, options) @input = input @prefix = options[:prefix] @suffix = options[:suffix] - prefix = Regexp.quote(@prefix.to_s) - suffix = Regexp.quote(@suffix.to_s) - @regexp = Regexp.new("^#{prefix}(.*)#{suffix}$") + @regexp = Path.make_circumfix_re(@prefix, @suffix) end private def add_circumfix(path) "#{@prefix}#{path}#{@suffix}" @@ -182,13 +180,13 @@ @input.edit_entry(path, prototype) { |text| yield text } self end def each_entry_path(selector) - @input.each_entry_path(Path::ALL) do |path| - path = add_circumfix(path) - yield path if selector.accept_path? path + selector = selector.assume_circumfix(@prefix, @suffix) + @input.each_entry_path(selector) do |path| + yield add_circumfix(path) end self end def get_entry(path) @@ -206,12 +204,12 @@ @input.edit_entry(path, prototype) { |text| yield text } self end def each_entry_path(selector) - @input.each_entry_path(Path::ALL) do |path| - path = strip_circumfix(path) - yield path if path and selector.accept_path? path + selector = selector.elide_circumfix(@prefix, @suffix) + @input.each_entry_path(selector) do |path| + yield strip_circumfix(path) end self end def get_entry(path)