Class: GitlabCodeownersChecker::Pattern
- Inherits:
-
Object
- Object
- GitlabCodeownersChecker::Pattern
- Defined in:
- lib/gitab_codeowners_checker/pattern.rb
Instance Attribute Summary collapse
-
#owners ⇒ Object
readonly
Returns the value of attribute owners.
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pattern, owners) ⇒ Pattern
constructor
A new instance of Pattern.
- #match?(str) ⇒ Boolean
Constructor Details
#initialize(pattern, owners) ⇒ Pattern
Returns a new instance of Pattern.
11 12 13 14 |
# File 'lib/gitab_codeowners_checker/pattern.rb', line 11 def initialize(pattern, owners) @pattern = pattern @owners = owners end |
Instance Attribute Details
#owners ⇒ Object (readonly)
Returns the value of attribute owners.
15 16 17 |
# File 'lib/gitab_codeowners_checker/pattern.rb', line 15 def owners @owners end |
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
15 16 17 |
# File 'lib/gitab_codeowners_checker/pattern.rb', line 15 def pattern @pattern end |
Class Method Details
.from_file_line(str) ⇒ Object
5 6 7 8 9 |
# File 'lib/gitab_codeowners_checker/pattern.rb', line 5 def self.from_file_line(str) path, *owners = str.split(' ') pattern = path[-1] == '/' ? /\A#{Regexp.escape(path)}.+/ : path new(pattern, owners) end |
Instance Method Details
#match?(str) ⇒ Boolean
17 18 19 |
# File 'lib/gitab_codeowners_checker/pattern.rb', line 17 def match?(str) @pattern.is_a?(Regexp) ? @pattern.match?(str) : str == @pattern end |