Sha256: 1c2929451b3441d8f768dce0533d6358dd1b2496a7d1196411f48fa3285ca212

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 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
      else
        :label
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owners-0.1.1 lib/owners/owner.rb