Sha256: c6be5dd1470e49e0b7b505ec32cfbbdda3494bd58127a1e3845e1683cef7cfda

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

module Owners
  class Path
    CONFIG = 'OWNERS'

    def initialize(file)
      @file = file
    end

    def owners
      configs.each_with_object([]) do |config, owners|
        path = @file.sub("#{config.root}/", '')

        config.owners.each do |owner, regexes|
          regexes.each do |regex|
            if path =~ regex
              owners << owner
            end
          end
        end
      end
    end

    private

    def configs
      configs = []
      file = @file

      until ['.', '/'].include?(file)
        file = File.dirname(file)
        config = File.join(file, CONFIG)

        if File.exists?(config) && !File.directory?(config)
          configs << Config.new(config)
        end
      end

      configs
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owners-0.0.0 lib/owners/path.rb