require 'fakeweb'

FakeWeb.allow_net_connect = false

def fake(routes)
  routes.map { |k, v|
    # Ghetto globbing
    if k[1].is_a?(String)
      k[1].gsub!("*", "[^/]*")
      k[1] = Regexp.new("^#{k[1]}$")
    end
    [k, v]
  }.each do |url, filename|
    file = File.join("test", "fixtures", "#{filename}.response")
    FakeWeb.register_uri(url[0], url[1], :response => file)
  end
end

require 'fakeweb'

FakeWeb.allow_net_connect = %r[^https?://codeclimate.com/]

def fake(routes)
  routes.map { |k, v|
    # Ghetto globbing
    if k[1].is_a?(String)
      k[1].gsub!("*", "[^/]*")
      k[1] = Regexp.new("^#{k[1]}$")
    end
    [k, v]
  }.each do |url, filename|
    file = File.join("test", "fixtures", "#{filename}.response")
    FakeWeb.register_uri(url[0], url[1], :response => file)
  end
end

Allow FakeWeb to connection to CodeClimate.
Allow FakeWeb to connection to CodeClimate.
