Sha256: 203ecf05f7f397d52a83833ad9296631dff97d7e592c227a9735e103d8cb1496
Contents?: true
Size: 922 Bytes
Versions: 5
Compression:
Stored size: 922 Bytes
Contents
require 'zlib' require 'digest' module NFAgent class Chunk attr_reader :created_at ::DEFAULT_TIME_OUT = 60 def initialize(max_size = 500) @max_size = max_size @created_at = Time.now @array = [] @submitter = Submitter.new(Config.client_key) end def <<(line) @array << line end def full? @array.size >= @max_size end def expired? (Time.now - @created_at > ::DEFAULT_TIME_OUT) && !@array.empty? end # TODO: Is this the right place for compression, encoding and check summing? Perhaps it should go into the submitter to that it can be deferred def dump Payload.new do |payload| payload.data = Encoder.encode64url(Zlib::Deflate.deflate(@array.join("\n"), Zlib::BEST_COMPRESSION)) payload.checksum = Digest::SHA1.hexdigest(payload.data) end end def clear @array.clear end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
nfagent-0.9.10 | lib/nfagent/chunk.rb |
nfagent-0.9.9 | lib/nfagent/chunk.rb |
nfagent-0.9.8 | lib/nfagent/chunk.rb |
nfagent-0.9.6 | lib/nfagent/chunk.rb |
nfagent-0.9.5 | lib/nfagent/chunk.rb |