<commit_before>$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'rubygems'
require 'spec'
require 'weary'

def get_fixture(filename)
  open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
end

def mock_response(request_method = :get, code=200, header={}, body=nil)
  response_class = Net::HTTPResponse::CODE_TO_OBJ[code.to_s]
  message = case code
    when 200
      "OK"
    when 301
      "Moved Permanently"
    when 302
      "Moved Temporarily"
    when 400
      "Bad Request"
    when 401
      "Unauthorized"
    when 403
      "Forbidden"
    when 404
      "Not Found"
    when 405
      "Method Not Allowed"
    when 409
      "Conflict"
    when 422
      "Unprocessable Entity"
    when 401...500
      "Client Error"
    when 500...600
      "Server Error"
    else
      "Unknown"
  end
  response = response_class.new("1.1", code, "Hello World!")
  response.initialize_http_header(header)
  response.stub!(:body).and_return(body)
  response.stub!(:message).and_return(message)
  
  response
end

def mock_request(url, method = :get, options={}, mock_header={}, mock_body=nil)
  request = Weary::Request.new(url, method, options)
  http_response = mock_response(method, 200, mock_header, mock_body)
  request.stub!(:perform).and_return Weary::Response.new(http_response, method)
  
  request
end<commit_msg>Using FakeWeb<commit_after>$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'weary'
require 'rubygems'
require 'spec'
require 'fakeweb'

def get_fixture(filename)
  open(File.join(File.dirname(__FILE__), 'fixtures', "#{filename.to_s}")).read
end

def http_status_message(code)
  message = case code.to_i
    when 200
      "OK"
    when 301
      "Moved Permanently"
    when 302
      "Moved Temporarily"
    when 400
      "Bad Request"
    when 401
      "Unauthorized"
    when 403
      "Forbidden"
    when 404
      "Not Found"
    when 405
      "Method Not Allowed"
    when 409
      "Conflict"
    when 422
      "Unprocessable Entity"
    when 401...500
      "Client Error"
    when 500...600
      "Server Error"
    else
      "Unknown"
  end
  [code.to_s,message]
end
{'fraction_non_alphanumeric': 0.11953089760938204, 'fraction_numerical': 0.04149751917004962, 'mean_word_length': 3.1074074074074076, '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': '7444666', 'n_tokens_mistral': 837, 'n_tokens_neox': 753, 'n_words': 177}