Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
fakes3 / lib / fakes3 / rate_limitable_file.rb
Size: Mime:
module FakeS3
  class RateLimitableFile < File
    @@rate_limit = nil
    # Specify a rate limit in bytes per second
    def self.rate_limit
      @@rate_limit
    end

    def self.rate_limit=(rate_limit)
      @@rate_limit = rate_limit
    end

    def read(args)
      if @@rate_limit
        time_to_sleep = args / @@rate_limit
        sleep(time_to_sleep)
      end
      return super(args)
    end
  end
end