module Boss
Boss
protocol version 1.4 full implementation
Attentionn! Bzip2 compression was removed for the sake of compatibility.
1.4 Stream mode do not use caching anymore (not effective while slow).
Stream mode format is changed (removed unused parameters)
1.3.1 Stream mode added and fixed 1.3
1.2 version adds support for booelans and removes support for python __reduce__ - based objects
as absolutely non portable. It also introduces
1.1 version changes the way to store bignums in header, now it is
encoded <bytes_length> followed by the specified number of bytes LSB first
No object serialization yet, no callables and bound methods - these appear to be non portable between platoforms.
Please note that most of this code was developed in 2008 so it is kind of old ;) though working.
Constants
- Bignum
- DMINUSONE
- DONE
- DZERO
Extra types:
- FMINUSONE
- FONE
- FZERO
- Fixnum
- TCOMPRESSED
- TDOUBLE
- TFALSE
- TFLOAT
- TFUNCTION
- TGLOBREF
- TMETHOD
- TOBJECT
- TTIME
- TTRUE
- TYPE_BIN
- TYPE_CREF
- TYPE_DICT
- TYPE_EXTRA
- TYPE_INT
Basic types
- TYPE_LIST
- TYPE_NINT
- TYPE_TEXT
- VERSION
- XT_STREAM_MODE
Public Class Methods
convert all arguments into successive BOSS encoeded object, so all them will share same global reference cache.
# File lib/boss-protocol.rb, line 537 def Boss.dump(*roots) f = f = Formatter.new roots.each { |r| f << r } f.string end
Just like Boss.dump
but automatically use proper compression depending on the data size. Boss.load
or Boss.load_all
will automatically decompress the data
# File lib/boss-protocol.rb, line 547 def Boss.dump_compressed(*roots) f = f = Formatter.new roots.each { |r| f.put_compressed r } f.string end
If block is given, yields all objects from the src (that can be either string or IO), passes it to the block and stores what block returns in the array, unless block returns nil. The array is then returned.
Otherwise, reads and return first object from src
# File lib/boss-protocol.rb, line 514 def Boss.load(src) p = Parser.new(src) if block_given? res = [] res << yield(p.get) while !p.eof? res else p.get end end
Load all objects from the src and return them as an array
# File lib/boss-protocol.rb, line 526 def Boss.load_all src p = Parser.new(src) res = [] res << p.get while !p.eof? res end
Pack object to the BOSS binary (same as Boss#dump)
# File lib/boss-protocol.rb, line 559 def Boss.pack object Boss.dump object end
Pack object into compressed Boss
representation
# File lib/boss-protocol.rb, line 554 def Boss.pack_compress(object) dump_compressed object end
Unpack object from the BOSS binary (same as Boss#load(src))
# File lib/boss-protocol.rb, line 564 def Boss.unpack object Boss.load object end
Public Instance Methods
# File lib/boss-protocol.rb, line 104 def checkArg(cond, msg=nil) raise ArgumentError, msg unless cond end