class Owners::Config
Represents a single OWNERS file.
It parses OWNERS files and returns an array of {Subscription} objects is returned for a specified file path.
@api private
Attributes
file[R]
root[R]
Public Class Methods
for(configs)
click to toggle source
# File lib/owners/config.rb 12 def self.for(configs) 13 configs.map do |file, contents| 14 new(file, contents) 15 end 16 end
new(file, contents = nil)
click to toggle source
# File lib/owners/config.rb 18 def initialize(file, contents = nil) 19 @file = file.to_s 20 @contents = contents || file.read 21 @root = File.dirname(@file) 22 end
Public Instance Methods
subscriptions(path, shallow)
click to toggle source
# File lib/owners/config.rb 24 def subscriptions(path, shallow) 25 search do |subscription, results| 26 if subscription.subscribed?(path) 27 results << subscription 28 return results if shallow 29 end 30 end 31 end
Private Instance Methods
attempts()
click to toggle source
# File lib/owners/config.rb 41 def attempts 42 lines.map.with_index do |subscription, index| 43 Subscription.new(subscription, index + 1, self) 44 end 45 end
lines()
click to toggle source
# File lib/owners/config.rb 47 def lines 48 @contents.split("\n") 49 end
search(&block)
click to toggle source
# File lib/owners/config.rb 35 def search(&block) 36 attempts 37 .reject(&:metadata?) 38 .each_with_object([], &block) 39 end