Sha256: b3fab5ffefde1fc46c67abcdef137499a1f4087fb709b7de3a28ac3b252bd244
Contents?: true
Size: 754 Bytes
Versions: 1
Compression:
Stored size: 754 Bytes
Contents
module Owners # Parses an OWNERS file and returns an array of owners # that have subscribed to a specified file path. # # @api private class Config def initialize(file) @contents = file.read @root = file.dirname.to_s end def owners(path) if path.start_with?(@root) relative = path.sub("#{@root}/", "") search do |subscription, results| owner, pattern = subscription.split(/\s+/, 2) regex = Regexp.new(pattern || ".*") results << owner if regex =~ relative end end end private def search(&block) subscriptions.each_with_object([], &block) end def subscriptions @contents.split("\n").reject(&:empty?) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
owners-0.0.3 | lib/owners/config.rb |