Class: Codeowners::Glob

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/codeowners/glob.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Glob

Returns a new instance of Glob.



21
22
23
# File 'lib/codeowners/glob.rb', line 21

def initialize(string)
  @pattern = normalize_string(string)
end

Instance Attribute Details

#patternString (readonly)

The glob pattern this glob will match

Returns:

  • (String)

See Also:



16
17
18
# File 'lib/codeowners/glob.rb', line 16

def pattern
  @pattern
end

Instance Method Details

#match?(filepath) ⇒ Boolean

Note:

Don’t use ‘FNM_CASEFOLD`, GitHub uses a case sensitive file system. Don’t use ‘FNM_EXTGLOB`, GitHub CODEOWNERS files don’t support it. Don’t use ‘FNM_PATHNAME`, we want to match `*` against ’/‘.

Does this glob match the given filepath?

Parameters:

  • filepath (String)

    to match against

Returns:

  • (Boolean)

See Also:



34
35
36
# File 'lib/codeowners/glob.rb', line 34

def match?(filepath)
  fnmatch(pattern, filepath, File::FNM_DOTMATCH)
end