<commit_before>require 'omniauth-github'

module OmniAuth
  module Strategies
    class GitHubTeamMember < OmniAuth::Strategies::GitHub
      credentials do
        options['teams'].inject({}) do |base, key_value_pair|
          method_name, team_id = key_value_pair
          base[booleanize_method_name(method_name)] = team_member?(team_id)
          base
        end
      end

      def team_member?(team_id)
        response = access_token.get("/teams/#{team_id}/memberships/#{raw_info['login']}")
        response.status == 200 && response.state == "active"
      rescue ::OAuth2::Error
        false
      end

      def booleanize_method_name(method_name)
        return method_name if method_name =~ /\?$/<commit_msg>Pick out state properly from parsed body<commit_after>require 'omniauth-github'

module OmniAuth
  module Strategies
    class GitHubTeamMember < OmniAuth::Strategies::GitHub
      credentials do
        options['teams'].inject({}) do |base, key_value_pair|
          method_name, team_id = key_value_pair
          base[booleanize_method_name(method_name)] = team_member?(team_id)
          base
        end
      end

      def team_member?(team_id)
        response = access_token.get("/teams/#{team_id}/memberships/#{raw_info['login']}")
        response.status == 200 && response.parsed["state"] == "active"
      rescue ::OAuth2::Error
        false
      end

      def booleanize_method_name(method_name)
        return method_name if method_name =~ /\?$/
{'fraction_non_alphanumeric': 0.10879785090664876, 'fraction_numerical': 0.005372733378106112, 'mean_word_length': 2.973333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6192942', 'n_tokens_mistral': 461, 'n_tokens_neox': 448, 'n_words': 88}