Class: Codeowners::CodeownersFile

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

Overview

Parses a Codeowners file

Instance Method Summary collapse

Constructor Details

#initialize(codeowners_source = File.read('./.github/CODEOWNERS')) ⇒ CodeownersFile

Returns a new instance of CodeownersFile.

Parameters:

  • codeowners_source (String) (defaults to: File.read('./.github/CODEOWNERS'))

    A String containing the readlines from the CODEOWNERS file



20
21
22
# File 'lib/codeowners/codeowners_file.rb', line 20

def initialize(codeowners_source = File.read('./.github/CODEOWNERS'))
  @source = codeowners_source
end

Instance Method Details

#globsObject



32
33
34
# File 'lib/codeowners/codeowners_file.rb', line 32

def globs
  @globs ||= lines.map { |line| Glob.new(line.to_s.split.first) }
end

#ownershipsObject



28
29
30
# File 'lib/codeowners/codeowners_file.rb', line 28

def ownerships
  @ownerships ||= lines.map { |line| Ownership.new(*line.to_s.split) }
end

#ownerships_reversedObject



24
25
26
# File 'lib/codeowners/codeowners_file.rb', line 24

def ownerships_reversed
  @ownerships_reversed ||= ownerships.reverse
end