class PathList::Matchers::ShebangRegexp

Attributes

rule[R]
squash_id[R]

Public Class Methods

new(rule, negation) click to toggle source
# File lib/path_list/matchers/shebang_regexp.rb, line 9
def initialize(rule, negation)
  @rule = rule
  @return_value = negation ? :allow : :ignore
  @squash_id = negation ? :allow_shebang : :ignore_shebang

  freeze
end

Public Instance Methods

dir_only?() click to toggle source
# File lib/path_list/matchers/shebang_regexp.rb, line 25
def dir_only?
  false
end
file_only?() click to toggle source
# File lib/path_list/matchers/shebang_regexp.rb, line 21
def file_only?
  true
end
inspect() click to toggle source

:nocov:

# File lib/path_list/matchers/shebang_regexp.rb, line 30
def inspect
  "#<ShebangRegexp #{@return_value} /#{@rule.to_s[26..-4]}/>"
end
match?(candidate) click to toggle source

:nocov:

# File lib/path_list/matchers/shebang_regexp.rb, line 35
def match?(candidate)
  return false if candidate.filename.include?('.')

  @return_value if candidate.first_line&.match?(@rule)
end
shebang?() click to toggle source
# File lib/path_list/matchers/shebang_regexp.rb, line 41
def shebang?
  true
end
squash(list) click to toggle source
# File lib/path_list/matchers/shebang_regexp.rb, line 17
def squash(list)
  self.class.new(::Regexp.union(list.map(&:rule)), @return_value == :allow)
end