<commit_before>module Warden
  module OAuth

    module Manager

      def self.included(base)
        base.extend(ClassMethods)
      end

      def oauth(service, &block)
        config = Warden::OAuth::Config.new
        yield config
        config.check_requirements
        config.provider_name = service
        Warden::OAuth::Strategy.build(service, config)
        #@config[:oauth_services][service] = config
      end

      module ClassMethods

        def access_token_user_finder(oauth_service, &block)
          raise Warden::OAuth::AccessTokenFinderMissing.new("You need to specify a block for Warden::Manager.acess_token_user_finder") unless block_given?
          raise Warden::OAuth::AccessTokenFinderMissing.new("You need to specify a block for Warden::Manager.access_token_user_finder, this must receive one parameter") if block.arity != 1
          @find_user_by_access_token ||= {}
          @find_user_by_access_token[oauth_service] = block
        end

        def find_user_by_access_token(oauth_service, access_token)
          raise Warden::OAuth::AccessTokenFinderMissing.new("You need to specify a block for Warden::Manager.acess_token_user_finder") if @find_user_by_access_token.nil?
          @find_user_by_access_token[oauth_service].call(access_token)
        end

      end
    
    end

  end
end

Warden::Manager.send(:include, Warden::OAuth::Manager)<commit_msg>Making the config API more flexible<commit_after>module Warden
  module OAuth

    module Manager

      def self.included(base)
        base.extend(ClassMethods)
      end

      def oauth(service, &block)
        config = Warden::OAuth::Config.new
        if block_given?
          if block.arity == 1 
            yield config 
          else
            config.instance_eval(&block)
          end
        end
        config.check_requirements
        config.provider_name = service
        Warden::OAuth::Strategy.build(service, config)
      end

      module ClassMethods

        def access_token_user_finder(oauth_service, &block)
          raise Warden::OAuth::AccessTokenFinderMissing.new("You need to specify a block for Warden::Manager.acess_token_user_finder") unless block_given?
          raise Warden::OAuth::AccessTokenFinderMissing.new("You need to specify a block for Warden::Manager.access_token_user_finder, this must receive one parameter") if block.arity != 1
          @find_user_by_access_token ||= {}
          @find_user_by_access_token[oauth_service] = block
        end

        def find_user_by_access_token(oauth_service, access_token)
          raise Warden::OAuth::AccessTokenFinderMissing.new("You need to specify a block for Warden::Manager.acess_token_user_finder") if @find_user_by_access_token.nil?
          @find_user_by_access_token[oauth_service].call(access_token)
        end

      end
    
    end

  end
end

Warden::Manager.send(:include, Warden::OAuth::Manager)
{'fraction_non_alphanumeric': 0.07977991746905089, 'fraction_numerical': 0.0010316368638239339, 'mean_word_length': 3.1379800853485063, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1178657', 'n_tokens_mistral': 860, 'n_tokens_neox': 837, 'n_words': 179}