Class: Codeowners::Glob
- Inherits:
-
Object
- Object
- Codeowners::Glob
- Extended by:
- Forwardable
- Defined in:
- lib/codeowners/glob.rb
Instance Attribute Summary collapse
-
#pattern ⇒ String
readonly
The glob pattern this glob will match.
Instance Method Summary collapse
-
#initialize(string) ⇒ Glob
constructor
A new instance of Glob.
-
#match?(filepath) ⇒ Boolean
Does this glob match the given filepath?.
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
#pattern ⇒ String (readonly)
The glob pattern this glob will match
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?
34 35 36 |
# File 'lib/codeowners/glob.rb', line 34 def match?(filepath) fnmatch(pattern, filepath, File::FNM_DOTMATCH) end |