module FastIgnore::RuleBuilder

Public Class Methods

build(rule, allow, expand_path_with, file_root) click to toggle source

:nocov:

# File lib/fast_ignore/rule_builder.rb, line 10
def build(rule, allow, expand_path_with, file_root)
  if rule.delete_prefix!('#!:')
    shebang_rules(rule, allow, file_root)
  else
    gitignore_rules(rule, allow, file_root, expand_path_with)
  end
end

Private Class Methods

gitignore_rules(rule, allow, file_root, expand_path_with = nil) click to toggle source
# File lib/fast_ignore/rule_builder.rb, line 32
def gitignore_rules(rule, allow, file_root, expand_path_with = nil)
  if allow
    ::FastIgnore::GitignoreIncludeRuleBuilder.new(rule, file_root, expand_path_with).build
  else
    ::FastIgnore::GitignoreRuleBuilder.new(rule, file_root).build
  end
end
shebang_rules(shebang, allow, file_root) click to toggle source
# File lib/fast_ignore/rule_builder.rb, line 20
def shebang_rules(shebang, allow, file_root)
  shebang.strip!
  pattern = /\A#!.*\b#{::Regexp.escape(shebang)}\b/i
  rule = ::FastIgnore::ShebangRule.new(pattern, allow, file_root&.shebang_path_pattern)
  return rule unless allow

  rules = gitignore_rules('*/'.dup, allow, file_root)
  rules.pop # don't want the include all children one.
  rules << rule
  rules
end