lib/chef_fs/file_pattern.rb
def could_match_children?(path)
      return false if path == '' # Empty string is not a path

      argument_is_absolute = !!(path =~ /^#{ChefFS::PathUtils::regexp_path_separator}/)
      return false if is_absolute != argument_is_absolute
      path = path[1,path.length-1] if argument_is_absolute

      path_parts = ChefFS::PathUtils::split(path)
      # If the pattern is shorter than the path (or same size), children will be larger than the pattern, and will not match.
      return false if regexp_parts.length <= path_parts.length && !has_double_star
      # If the path doesn't match up to this point, children won't match either.
      return false if path_parts.zip(regexp_parts).any? { |part,regexp| !regexp.nil? && !regexp.match(part) }
      # Otherwise, it's possible we could match: the path matches to this point, and the pattern is longer than the path.
      # TODO There is one edge case where the double star comes after some characters like abc**def--we could check whether the next
      # bit of path starts with abc in that case.
      return true
    end
def could_match_children?(path)
      return false if path == '' # Empty string is not a path

      argument_is_absolute = !!(path =~ /^#{ChefFS::PathUtils::regexp_path_separator}/)
      return false if is_absolute != argument_is_absolute
      path = path[1,path.length-1] if argument_is_absolute

      path_parts = ChefFS::PathUtils::split(path)
      # If the pattern is shorter than the path (or same size), children will be larger than the pattern, and will not match.
      return false if regexp_parts.length <= path_parts.length && !has_double_star
      # If the path doesn't match up to this point, children won't match either.
      return false if path_parts.zip(regexp_parts).any? { |part,regexp| !regexp.nil? && !regexp.match(part) }
      # Otherwise, it's possible we could match: the path matches to this point, and the pattern is longer than the path.
      # TODO There is one edge case where the double star comes after some characters like abc**def--we could check whether the next
      # bit of path starts with abc in that case.
      return true
    end
def could_match_children? ( path ) return false if path == '' # Empty string is not a path argument_is_absolute = ! ! ( path =~ / #{ ChefFS :: PathUtils :: regexp_path_separator } / ) return false if is_absolute != argument_is_absolute path = path [ 1 , path . length - 1 ] if argument_is_absolute path_parts = ChefFS :: PathUtils :: split ( path ) # If the pattern is shorter than the path (or same size), children will be larger than the pattern, and will not match. return false if regexp_parts . length <= path_parts . length && ! has_double_star # If the path doesn't match up to this point, children won't match either. return false if path_parts . zip ( regexp_parts ) . any? { | part , regexp | ! regexp . nil? && ! regexp . match ( part ) } # Otherwise, it's possible we could match: the path matches to this point, and the pattern is longer than the path. # TODO There is one edge case where the double star comes after some characters like abc**def--we could check whether the next # bit of path starts with abc in that case. return true end
Reports whether this pattern could match children of <tt>path</tt>.
 If the pattern doesn't match the path up to this point or
 if it matches and doesn't allow further children, this will
 return <tt>false</tt>.

 ==== Attributes

 * +path+ - a path to check

 ==== Examples

   abc/def.could_match_children?('abc') == true
   abc.could_match_children?('abc') == false
   abc/def.could_match_children?('x') == false
   a**z.could_match_children?('ab/cd') == true
Reports whether this pattern could match children of <tt > path< / tt > . If the pattern doesn t match the path up to this point or if it matches and doesn t allow further children this will return <tt > false< / tt > .