Class: PathList::RuleGroups
- Inherits:
-
Object
- Object
- PathList::RuleGroups
- Defined in:
- lib/path_list/rule_groups.rb
Instance Method Summary collapse
- #add_gitignore(dir) ⇒ Object
- #add_gitignore_to_root(path) ⇒ Object
- #allowed_recursive?(candidate) ⇒ Boolean
- #allowed_unrecursive?(candidate) ⇒ Boolean
-
#initialize(root:, ignore_rules: nil, ignore_files: nil, gitignore: true, include_rules: nil, include_files: nil, argv_rules: nil) ⇒ RuleGroups
constructor
:nocov:.
Constructor Details
#initialize(root:, ignore_rules: nil, ignore_files: nil, gitignore: true, include_rules: nil, include_files: nil, argv_rules: nil) ⇒ RuleGroups
:nocov:
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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.(f, root) @array << ::PathList::RuleGroup.new(::PathList::Patterns.new(from_file: path), false).freeze end Array(include_files).each do |f| path = ::File.(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 |
Instance Method Details
#add_gitignore(dir) ⇒ Object
51 52 53 |
# 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) ⇒ Object
55 56 57 |
# 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) ⇒ Boolean
43 44 45 |
# File 'lib/path_list/rule_groups.rb', line 43 def allowed_recursive?(candidate) @array.all? { |r| r.allowed_recursive?(candidate) } end |
#allowed_unrecursive?(candidate) ⇒ Boolean
47 48 49 |
# File 'lib/path_list/rule_groups.rb', line 47 def allowed_unrecursive?(candidate) @array.all? { |r| r.allowed_unrecursive?(candidate) } end |