<commit_before>require 'omniauth/basic'

module OmniAuth
  module Strategies
    class Basecamp < HttpBasic
      def initialize(app)
        require 'json'
        super(app, :basecamp, nil)
      end
      
      def endpoint
        "http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.basecamphq.com/me.xml"
      end
      
      def perform_authentication(endpoint)
        super(endpoint) rescue super(endpoint.sub('http','https'))
      end
      
      def auth_hash
        doc = Nokogiri::XML.parse(@response.body)
        OmniAuth::Utils.deep_merge(super, {
          'uid' => doc.xpath('person/id').text,
          'user_info' => user_info(doc),
          'credentials' => {
            'token' => doc.xpath('person/token').text
          }
        })
      end
      
      def user_info(doc)
        hash = {
          'nickname' => request.params['user'],
          'first_name' => doc.xpath('person/first-name').text,
          'last_name' => doc.xpath('person/last-name').text,
          'email' => doc.xpath('person/email-address').text,
          'image' => doc.xpath('person/avatar-url').text
        }
        
        hash['name'] = [hash['first_name'], hash['last_name']].join(' ').strip
        
        hash.delete('image') if hash['image'].include?('missing/avatar.png')
        
        hash
      end
      
      def get_credentials
        OmniAuth::Form.build('Basecamp Authentication') do
          text_field 'Subdomain', 'subdomain'
          text_field 'Username', 'user'
          password_field 'Password', 'password'
        end.to_response
      end
    end
  end
end
<commit_msg>Basecamp doesn't require JSON; it requires Nokogiri<commit_after>require 'omniauth/basic'
require 'nokogiri'

module OmniAuth
  module Strategies
    class Basecamp < HttpBasic
      def initialize(app)
        super(app, :basecamp, nil)
      end
      
      def endpoint
        "http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.basecamphq.com/me.xml"
      end
      
      def perform_authentication(endpoint)
        super(endpoint) rescue super(endpoint.sub('http','https'))
      end
      
      def auth_hash
        doc = Nokogiri::XML.parse(@response.body)
        OmniAuth::Utils.deep_merge(super, {
          'uid' => doc.xpath('person/id').text,
          'user_info' => user_info(doc),
          'credentials' => {
            'token' => doc.xpath('person/token').text
          }
        })
      end
      
      def user_info(doc)
        hash = {
          'nickname' => request.params['user'],
          'first_name' => doc.xpath('person/first-name').text,
          'last_name' => doc.xpath('person/last-name').text,
          'email' => doc.xpath('person/email-address').text,
          'image' => doc.xpath('person/avatar-url').text
        }
        
        hash['name'] = [hash['first_name'], hash['last_name']].join(' ').strip
        
        hash.delete('image') if hash['image'].include?('missing/avatar.png')
        
        hash
      end
      
      def get_credentials
        OmniAuth::Form.build('Basecamp Authentication') do
          text_field 'Subdomain', 'subdomain'
          text_field 'Username', 'user'
          password_field 'Password', 'password'
        end.to_response
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.14651578320428826, 'fraction_numerical': 0.0, 'mean_word_length': 2.1363211951447245, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5890592', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1022, 'n_words': 168}