Sha256: dd264addda2836db65e648cf794915d5d60dde6529d7c87e391e1f272422ff0b
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module Owners # 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 class Config attr_reader :file, :root def self.for(configs) configs.map do |file, contents| new(file, contents) end end def initialize(file, contents = nil) @file = file.to_s @contents = contents || file.read @root = File.dirname(@file) end def subscriptions(path, shallow) search do |subscription, results| if subscription.subscribed?(path) results << subscription return results if shallow end end end private def search(&block) attempts .reject(&:metadata?) .each_with_object([], &block) end def attempts lines.map.with_index do |subscription, index| Subscription.new(subscription, index + 1, self) end end def lines @contents.split("\n") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
owners-0.1.1 | lib/owners/config.rb |
owners-0.1.0 | lib/owners/config.rb |