Sha256: c327ee673367204b4fe3f02c4195b97b36dbbd5d9e3c609a9a92b7724bf02f28
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module Owners # Represents a single line of an OWNERS file. # # It contains some useful methods for inspecting the # subscriptions themselves like the file, line, and # filter, and subscribers. # # @api public class Subscription include Comparable COMMENT = /^\s*\/\// WILDCARD = /.*/ attr_reader :file, :line, :root, :subscription def initialize(subscription, line, config) @subscribers, @filter = subscription.split(/\s+/, 2) @subscription = subscription @line = line @file = config.file.sub("./", "") @root = config.root end def <=>(other) location <=> other.location end def filter Regexp.new(@filter || WILDCARD) end def location [file, line].join(":") end def metadata? comment? || empty? end def source filter.source end def subscribed?(path) path =~ prefix && relative(path) =~ filter end def subscribers @subscribers.split(",").reject(&:empty?) end def to_s [source, location].join(" ") end private def comment? subscription =~ COMMENT end def empty? subscription.strip.empty? end def prefix /\.?\/?#{root}\// end def relative(path) path.sub(prefix, "") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
owners-0.1.1 | lib/owners/subscription.rb |