class PathList::RuleGroup

Public Class Methods

new(patterns, allow) click to toggle source
# File lib/path_list/rule_group.rb, line 5
def initialize(patterns, allow)
  @matchers = Array(patterns).flat_map { |x| x.build_matchers(include: allow) }.compact
  @allow = allow
  @allowed_recursive = { '/' => true }
end

Public Instance Methods

allowed_recursive?(root_candidate) click to toggle source
# File lib/path_list/rule_group.rb, line 25
def allowed_recursive?(root_candidate)
  @allowed_recursive.fetch(root_candidate.full_path) do
    @allowed_recursive[root_candidate.full_path] =
      allowed_recursive?(root_candidate.parent) &&
      allowed_unrecursive?(root_candidate)
  end
end
allowed_unrecursive?(root_candidate) click to toggle source
# File lib/path_list/rule_group.rb, line 33
def allowed_unrecursive?(root_candidate)
  @matchers.reverse_each do |matcher|
    val = matcher.match?(root_candidate)
    return val == :allow if val
  end

  not @allow
end
empty?() click to toggle source
# File lib/path_list/rule_group.rb, line 11
def empty?
  @matchers.empty? || @matchers.all?(&:empty?)
end
freeze() click to toggle source
Calls superclass method
# File lib/path_list/rule_group.rb, line 19
def freeze
  @matchers.freeze

  super
end
weight() click to toggle source
# File lib/path_list/rule_group.rb, line 15
def weight
  @matchers.sum(&:weight)
end