Sha256: ee020c26965457a5a81e7bc911c71f72b80ff9222e21262be213b1f6451960fc

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

require 'pathspec'

module Codeowners
  class Checker
    # Manage CODEOWNERS_WHITELIST file reading
    class Whitelist
      def initialize(filename)
        @filename = filename
      end

      def exist?
        File.exist?(@filename)
      end

      def whitelisted?(filename)
        pathspec.match(filename)
      end

      def to_proc
        proc { |item| whitelisted?(item) }
      end

      private

      def pathspec
        @pathspec = if File.exist?(@filename)
                      PathSpec.from_filename(@filename)
                    else
                      PathSpec.new([])
                    end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codeowners-checker-1.1.2 lib/codeowners/checker/whitelist.rb