Sha256: fc04ec5514c9577227939a52f996c9c047d1332dbdce252d75c5748a1f8fc28d
Contents?: true
Size: 823 Bytes
Versions: 4
Compression:
Stored size: 823 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 = nil) @contents = contents || file.read @root = File.dirname(file.to_s) end def owners(path) if path =~ prefix relative = path.sub(prefix, "") search do |subscription, results| owner, pattern = subscription.split(/\s+/, 2) regex = Regexp.new(pattern || ".*") results << owner if regex =~ relative end end end private def prefix /\.?\/?#{@root}\// end def search(&block) subscriptions.each_with_object([], &block) end def subscriptions @contents.split("\n").reject(&:empty?) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
owners-0.0.7 | lib/owners/config.rb |
owners-0.0.6 | lib/owners/config.rb |
owners-0.0.5 | lib/owners/config.rb |
owners-0.0.4 | lib/owners/config.rb |