Module: FastIgnore::Builders::Shebang

Defined in:
lib/fast_ignore/builders/shebang.rb

Class Method Summary collapse

Class Method Details

.build(shebang, allow) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fast_ignore/builders/shebang.rb', line 6

def self.build(shebang, allow)
  shebang.strip!
  pattern = /\A#!.*\b#{::Regexp.escape(shebang)}\b/i
  rule = ::FastIgnore::Matchers::ShebangRegexp.new(pattern, allow)
  return rule unless allow

  # also allow all directories in case they include a file with the matching shebang file
  [::FastIgnore::Matchers::AllowAnyDir, rule]
end