Class: PathList::GitignoreRuleGroup
- Defined in:
- lib/path_list/gitignore_rule_group.rb
Instance Method Summary collapse
- #add_gitignore(dir) ⇒ Object
- #add_gitignore_to_root(path) ⇒ Object
-
#initialize(root) ⇒ GitignoreRuleGroup
constructor
A new instance of GitignoreRuleGroup.
Methods inherited from RuleGroup
#allowed_recursive?, #allowed_unrecursive?, #empty?, #freeze, #weight
Constructor Details
#initialize(root) ⇒ GitignoreRuleGroup
Returns a new instance of GitignoreRuleGroup.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/path_list/gitignore_rule_group.rb', line 7 def initialize(root) @root = root @loaded_paths = Set[root] super([ ::PathList::Patterns.new('.git', root: '/'), ::PathList::Patterns.new(from_file: ::PathList::GlobalGitignore.path(root: root), root: root), ::PathList::Patterns.new(from_file: "#{root}.git/info/exclude", root: root), ::PathList::Patterns.new(from_file: "#{root}.gitignore", root: root) ], false) end |
Instance Method Details
#add_gitignore(dir) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/path_list/gitignore_rule_group.rb', line 19 def add_gitignore(dir) return if @loaded_paths.include?(dir) @loaded_paths << dir matcher = ::PathList::Patterns.new(from_file: "#{dir}.gitignore").build_matchers(include: false) @matchers += matcher unless !matcher || matcher.empty? end |
#add_gitignore_to_root(path) ⇒ Object
27 28 29 |
# File 'lib/path_list/gitignore_rule_group.rb', line 27 def add_gitignore_to_root(path) add_gitignore(path) until @loaded_paths.include?(path = "#{::File.dirname(path)}/") end |