Class: Codeowners::Checker::Group::Pattern
- Defined in:
- lib/codeowners/checker/group/pattern.rb
Overview
Defines and manages line type pattern.
Instance Attribute Summary collapse
-
#owners ⇒ Object
Returns the value of attribute owners.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
Attributes inherited from Line
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(line) ⇒ Pattern
constructor
A new instance of Pattern.
- #match_file?(file) ⇒ Boolean
- #owner ⇒ Object
- #parse(line) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Line
#<=>, #==, build, #normalize_path, #pattern?, #remove!, subclasses, #suggest_files_for_pattern, #to_content, #to_tree
Constructor Details
#initialize(line) ⇒ Pattern
Returns a new instance of Pattern.
17 18 19 20 |
# File 'lib/codeowners/checker/group/pattern.rb', line 17 def initialize(line) super parse(line) end |
Instance Attribute Details
#owners ⇒ Object
Returns the value of attribute owners.
10 11 12 |
# File 'lib/codeowners/checker/group/pattern.rb', line 10 def owners @owners end |
#pattern ⇒ Object
Returns the value of attribute pattern.
10 11 12 |
# File 'lib/codeowners/checker/group/pattern.rb', line 10 def pattern @pattern end |
Class Method Details
.match?(line) ⇒ Boolean
12 13 14 15 |
# File 'lib/codeowners/checker/group/pattern.rb', line 12 def self.match?(line) _pattern, *owners = line.split(/\s+/) owners.any? && owners.all? { |owner| owner.include?('@') } end |
Instance Method Details
#match_file?(file) ⇒ Boolean
30 31 32 |
# File 'lib/codeowners/checker/group/pattern.rb', line 30 def match_file?(file) regex.match(file) end |
#owner ⇒ Object
22 23 24 |
# File 'lib/codeowners/checker/group/pattern.rb', line 22 def owner owners.first end |
#parse(line) ⇒ Object
26 27 28 |
# File 'lib/codeowners/checker/group/pattern.rb', line 26 def parse(line) @pattern, *@owners = line.split(/\s+/) end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/codeowners/checker/group/pattern.rb', line 34 def to_s [@pattern, @owners].join(' ') end |