Sha256: d2fd909b493315dd1cd3e0a26b5139542e298d593864527fb751466c1763bade

Contents?: true

Size: 723 Bytes

Versions: 2

Compression:

Stored size: 723 Bytes

Contents

module Owners
  # Represents a unique "owner" across any number of OWNERS files.
  #
  # It is a simple wrapper around a {String} with some useful
  # methods for inspecting an owner's type and subscriptions.
  #
  # @api public
  class Owner < SimpleDelegator
    def paths
      subscriptions.keys
    end

    def subscriptions
      @subscriptions ||= Hash.new { |hash, key| hash[key] = [] }
    end

    def type
      case to_s
      when /^!/
        :alert
      when /^[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+$/i
        :email
      when /^@.+\/[^@]+$/
        :group
      when /^@/
        :mention
      when /^#/
        :tag
      when /\//
        :path
      else
        :label
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
owners-0.1.0 lib/owners/owner.rb
owners-0.0.9 lib/owners/owner.rb