<commit_before># encoding: utf-8
require "octokit"

module OpenSesame
  class Member

    def self.organization_name
      OpenSesame.organization_name
    end

    def self.find(member_login)
      return nil unless member_login.present?
      return unless member?(member_login)
      member = find_member(member_login) # Sawyer::Resource
      return unless member # may have been an API error
      members << member
      new(member.attrs)
    end

    def self.find_member(member_login)
      members.detect { |m| m.login == member_login } || begin
        client.user(member_login)
      rescue Octokit::Error => ek
        OpenSesame.logger.info e
      end
    end

    def self.member?(member_login)
      member_logins.include?(member_login) || begin
        client.organization_member?(organization_name, member_login)
      rescue Octokit::ServerError => e
        OpenSesame.logger.info e
      end
    end

    # memoized list of accepted member
    def self.members
      @members ||= []
    end

    def self.member_logins
      members.map(&:login)
    end

    def self.client
      @client ||= begin
        require "faraday-http-cache"
        stack = Faraday::Builder.new do |builder|
          builder.response :logger, OpenSesame.logger
          builder.use Faraday::HttpCache unless OpenSesame.debug?<commit_msg>update Faraday::Builder => Faraday::RackBuilder<commit_after># encoding: utf-8
require "octokit"

module OpenSesame
  class Member

    def self.organization_name
      OpenSesame.organization_name
    end

    def self.find(member_login)
      return nil unless member_login.present?
      return unless member?(member_login)
      member = find_member(member_login) # Sawyer::Resource
      return unless member # may have been an API error
      members << member
      new(member.attrs)
    end

    def self.find_member(member_login)
      members.detect { |m| m.login == member_login } || begin
        client.user(member_login)
      rescue Octokit::Error => ek
        OpenSesame.logger.info e
      end
    end

    def self.member?(member_login)
      member_logins.include?(member_login) || begin
        client.organization_member?(organization_name, member_login)
      rescue Octokit::ServerError => e
        OpenSesame.logger.info e
      end
    end

    # memoized list of accepted member
    def self.members
      @members ||= []
    end

    def self.member_logins
      members.map(&:login)
    end

    def self.client
      @client ||= begin
        require "faraday-http-cache"
        stack = Faraday::RackBuilder.new do |builder|
          builder.response :logger, OpenSesame.logger
          builder.use Faraday::HttpCache unless OpenSesame.debug?
{'fraction_non_alphanumeric': 0.08400884303610906, 'fraction_numerical': 0.0007369196757553427, 'mean_word_length': 2.6590296495956873, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5597929', 'n_tokens_mistral': 814, 'n_tokens_neox': 795, 'n_words': 193}