<commit_before>require 'spec'
require 'open-uri'

current_directory = File.dirname(__FILE__)
require "#{current_directory}/../lib/fog"
require "#{current_directory}/../lib/fog/bin"

if ENV["FOG_MOCK"] == "true"
  Fog.mock!
end

unless defined?(LOADED_SPEC_OPTS)
  # inlined spec.opts
  require "#{current_directory}/compact_progress_bar_formatter"
  Spec::Runner.options.parse_format("Spec::Runner::Formatter::CompactProgressBarFormatter")
  Spec::Runner.options.loadby  = 'mtime'
  Spec::Runner.options.reverse = true
  LOADED_SPEC_OPTS = true
end


module AWS
  class << self
    def [](service)
      @@connections ||= Hash.new do |hash, key|
        credentials = Fog.credentials.reject do |k, v|
          ![:aws_access_key_id, :aws_secret_access_key].include?(k)
        end
        hash[key] = case key
        when :ec2
          Fog::AWS::EC2.new(credentials)
        when :eu_s3
          Fog::AWS::S3.new(credentials.merge!(:host => 's3-external-3.amazonaws.com'))
        when :sdb
          Fog::AWS::SimpleDB.new(credentials)
        when :s3
          Fog::AWS::S3.new(credentials)
        end
      end
      @@connections[service]
    end
  end
end

module Rackspace
  class << self
    def [](service)
      @@connections ||= Hash.new do |hash, key|
        credentials = Fog.credentials.reject do |k, v|
          ![:rackspace_api_key, :rackspace_username].include?(k)
        end
        hash[key] = case key
        when :files
          Fog::Rackspace::Files.new(credentials)
        when :servers
          Fog::Rackspace::Servers.new(credentials)
        end
      end
      @@connections[service]
    end
  end
end

module Slicehost
  class << self
    def [](service)
      @@connections ||= Hash.new do |hash, key|
        credentials = Fog.credentials.reject do |k, v|
          ![:slicehost_password].include?(k)
        end
        hash[key] = case key
        when :slices
          Fog::Slicehost.new(credentials)
        end
      end
      @@connections[service]
    end
  end
end



def eventually(max_delay = 16, &block)
  delays = [0]
  delay_step = 1
  total = 0
  while true
    delay = 1
    delay_step.times do
      delay *= 2
    end
    delays << delay
    delay_step += 1
    break if delay >= max_delay
  end
  delays.each do |delay|
    begin
      sleep(delay)
      yield
      break
    rescue => error
      raise error if delay >= max_delay
    end
  end
end

def wait_for(timeout = 600, &block)
  start = Time.now
  until instance_eval(&block)
    if Time.now - start > timeout
      break
    end
    sleep(1)
  end
end

unless defined?(GENTOO_AMI)
  GENTOO_AMI = 'ami-5ee70037'
end

def lorem_file
  File.open(File.dirname(__FILE__) + '/lorem.txt', 'r')
end<commit_msg>use standard formatter for now, progressbar mucks with ci<commit_after>require 'spec'
require 'open-uri'

current_directory = File.dirname(__FILE__)
require "#{current_directory}/../lib/fog"
require "#{current_directory}/../lib/fog/bin"

if ENV["FOG_MOCK"] == "true"
  Fog.mock!
end

# unless defined?(LOADED_SPEC_OPTS)
#   # inlined spec.opts
#   require "#{current_directory}/compact_progress_bar_formatter"
#   Spec::Runner.options.parse_format("Spec::Runner::Formatter::CompactProgressBarFormatter")
#   Spec::Runner.options.loadby  = 'mtime'
#   Spec::Runner.options.reverse = true
#   LOADED_SPEC_OPTS = true
# end


module AWS
  class << self
    def [](service)
      @@connections ||= Hash.new do |hash, key|
        credentials = Fog.credentials.reject do |k, v|
          ![:aws_access_key_id, :aws_secret_access_key].include?(k)
        end
        hash[key] = case key
        when :ec2
          Fog::AWS::EC2.new(credentials)
        when :eu_s3
          Fog::AWS::S3.new(credentials.merge!(:host => 's3-external-3.amazonaws.com'))
        when :sdb
          Fog::AWS::SimpleDB.new(credentials)
        when :s3
          Fog::AWS::S3.new(credentials)
        end
      end
      @@connections[service]
    end
  end
end

module Rackspace
  class << self
    def [](service)
      @@connections ||= Hash.new do |hash, key|
        credentials = Fog.credentials.reject do |k, v|
          ![:rackspace_api_key, :rackspace_username].include?(k)
        end
        hash[key] = case key
        when :files
          Fog::Rackspace::Files.new(credentials)
        when :servers
          Fog::Rackspace::Servers.new(credentials)
        end
      end
      @@connections[service]
    end
  end
end

module Slicehost
  class << self
    def [](service)
      @@connections ||= Hash.new do |hash, key|
        credentials = Fog.credentials.reject do |k, v|
          ![:slicehost_password].include?(k)
        end
        hash[key] = case key
        when :slices
          Fog::Slicehost.new(credentials)
        end
      end
      @@connections[service]
    end
  end
end



def eventually(max_delay = 16, &block)
  delays = [0]
  delay_step = 1
  total = 0
  while true
    delay = 1
    delay_step.times do
      delay *= 2
    end
    delays << delay
    delay_step += 1
    break if delay >= max_delay
  end
  delays.each do |delay|
    begin
      sleep(delay)
      yield
      break
    rescue => error
      raise error if delay >= max_delay
    end
  end
end

def wait_for(timeout = 600, &block)
  start = Time.now
  until instance_eval(&block)
    if Time.now - start > timeout
      break
    end
    sleep(1)
  end
end

unless defined?(GENTOO_AMI)
  GENTOO_AMI = 'ami-5ee70037'
end

def lorem_file
  File.open(File.dirname(__FILE__) + '/lorem.txt', 'r')
end
{'fraction_non_alphanumeric': 0.11964415395787945, 'fraction_numerical': 0.00944081336238199, 'mean_word_length': 2.5111536010197577, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, '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': '4697098', 'n_tokens_mistral': 1926, 'n_tokens_neox': 1872, 'n_words': 421}