class Codeowners::Checker::CodeOwners
Manage CODEOWNERS file reading and re-writing.
Attributes
file_manager[R]
Public Class Methods
filename(repo_dir)
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 35 def self.filename(repo_dir) directories = ['', '.github', 'docs', '.gitlab'] paths = directories.map { |dir| File.join(repo_dir, dir, 'CODEOWNERS') } Dir.glob(paths).first || paths.first end
new(file_manager)
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 14 def initialize(file_manager) @file_manager = file_manager end
Public Instance Methods
each(&block)
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 27 def each(&block) main_group.each(&block) end
filename()
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 41 def filename @file_manager.filename end
main_group()
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 23 def main_group @main_group ||= Group.parse(list) end
persist!()
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 18 def persist! file_manager.content = main_group.to_file file_manager.persist! end
to_content()
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 31 def to_content main_group.to_content end
Private Instance Methods
build_line(line)
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 51 def build_line(line) Codeowners::Checker::Group::Line.build(line) end
list()
click to toggle source
# File lib/codeowners/checker/code_owners.rb, line 47 def list @list ||= @file_manager.content.flat_map { |line| build_line(line) }.compact end