class PathList::RuleGroups

Public Class Methods

new( root:, ignore_rules: nil, ignore_files: nil, gitignore: true, include_rules: nil, include_files: nil, argv_rules: nil ) click to toggle source

:nocov:

# File lib/path_list/rule_groups.rb, line 9
def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/MethodLength
  root:,
  ignore_rules: nil,
  ignore_files: nil,
  gitignore: true,
  include_rules: nil,
  include_files: nil,
  argv_rules: nil
)
  @array = []
  if gitignore
    @gitignore_rule_group = ::PathList::GitignoreRuleGroup.new(root)
    @array << @gitignore_rule_group
  end
  @array << ::PathList::RuleGroup.new(::PathList::Patterns.new(ignore_rules, root: root), false).freeze
  @array << ::PathList::RuleGroup.new(::PathList::Patterns.new(include_rules, root: root), true).freeze
  @array << ::PathList::RuleGroup.new(
    ::PathList::Patterns.new(argv_rules, root: root, format: :expand_path),
    true
  ).freeze

  Array(ignore_files).each do |f|
    path = ::File.expand_path(f, root)
    @array << ::PathList::RuleGroup.new(::PathList::Patterns.new(from_file: path), false).freeze
  end
  Array(include_files).each do |f|
    path = ::File.expand_path(f, root)
    @array << ::PathList::RuleGroup.new(::PathList::Patterns.new(from_file: path), true).freeze
  end
  @array.reject!(&:empty?)
  @array.sort_by!(&:weight)
  @array.freeze
end

Public Instance Methods

add_gitignore(dir) click to toggle source
# File lib/path_list/rule_groups.rb, line 51
def add_gitignore(dir)
  @gitignore_rule_group.add_gitignore(dir)
end
add_gitignore_to_root(path) click to toggle source
# File lib/path_list/rule_groups.rb, line 55
def add_gitignore_to_root(path)
  @gitignore_rule_group.add_gitignore_to_root(path)
end
allowed_recursive?(candidate) click to toggle source
# File lib/path_list/rule_groups.rb, line 43
def allowed_recursive?(candidate)
  @array.all? { |r| r.allowed_recursive?(candidate) }
end
allowed_unrecursive?(candidate) click to toggle source
# File lib/path_list/rule_groups.rb, line 47
def allowed_unrecursive?(candidate)
  @array.all? { |r| r.allowed_unrecursive?(candidate) }
end