Class: PathList::Matchers::IgnorePathRegexp

Inherits:
Object
  • Object
show all
Defined in:
lib/path_list/matchers/ignore_path_regexp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule, anchored, dir_only) ⇒ IgnorePathRegexp

Returns a new instance of IgnorePathRegexp.



13
14
15
16
17
18
19
20
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 13

def initialize(rule, anchored, dir_only)
  @rule = rule
  @dir_only = dir_only
  @anchored = anchored
  @squash_id = anchored ? :ignore : object_id

  freeze
end

Instance Attribute Details

#dir_onlyObject (readonly) Also known as: dir_only?

Returns the value of attribute dir_only.



6
7
8
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 6

def dir_only
  @dir_only
end

#ruleObject (readonly)

Returns the value of attribute rule.



11
12
13
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 11

def rule
  @rule
end

#squash_idObject (readonly)

Returns the value of attribute squash_id.



10
11
12
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 10

def squash_id
  @squash_id
end

Instance Method Details

#file_only?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 26

def file_only?
  false
end

#inspectObject

:nocov:



35
36
37
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 35

def inspect
  "#<IgnorePathRegexp #{'dir_only ' if @dir_only}#{@rule.inspect}>"
end

#match?(candidate) ⇒ Boolean

:nocov:

Returns:

  • (Boolean)


40
41
42
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 40

def match?(candidate)
  :ignore if @rule.match?(candidate.relative_path)
end

#shebang?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 30

def shebang?
  false
end

#squash(list) ⇒ Object



22
23
24
# File 'lib/path_list/matchers/ignore_path_regexp.rb', line 22

def squash(list)
  self.class.new(::Regexp.union(list.map(&:rule)), @anchored, @dir_only)
end