2009-10-08 08:14:40 +04:00
|
|
|
BERT
|
|
|
|
====
|
2009-10-08 06:18:16 +04:00
|
|
|
|
2009-10-24 11:57:16 +04:00
|
|
|
A BERT (Binary ERlang Term) serialization library for Ruby. It can
|
2009-10-08 08:14:40 +04:00
|
|
|
encode Ruby objects into BERT format and decode BERT binaries into Ruby
|
|
|
|
objects.
|
|
|
|
|
2009-10-09 04:19:45 +04:00
|
|
|
See the BERT specification at [bert-rpc.org](http://bert-rpc.org).
|
2009-10-09 04:18:36 +04:00
|
|
|
|
2009-10-24 11:57:16 +04:00
|
|
|
Instances of the following Ruby classes will be automatically converted to the
|
|
|
|
proper simple BERT type:
|
2009-10-08 09:26:25 +04:00
|
|
|
|
|
|
|
* Fixnum
|
|
|
|
* Float
|
|
|
|
* Symbol
|
|
|
|
* Array
|
|
|
|
* String
|
|
|
|
|
2009-10-24 11:57:16 +04:00
|
|
|
Instances of the following Ruby classes will be automatically converted to the
|
|
|
|
proper complex BERT type:
|
2009-10-08 09:26:25 +04:00
|
|
|
|
|
|
|
* NilClass
|
|
|
|
* TrueClass
|
|
|
|
* FalseClass
|
|
|
|
* Hash
|
|
|
|
* Time
|
|
|
|
* Regexp
|
|
|
|
|
2009-10-24 11:57:16 +04:00
|
|
|
To designate tuples, simply prefix an Array literal with a `t` or use the
|
|
|
|
BERT::Tuple class:
|
2009-10-08 10:48:53 +04:00
|
|
|
|
2009-10-09 02:47:51 +04:00
|
|
|
t[:foo, [1, 2, 3]]
|
2009-10-24 11:57:16 +04:00
|
|
|
BERT::Tuple[:foo, [1, 2, 3]]
|
2009-10-08 10:48:53 +04:00
|
|
|
|
2009-10-09 02:47:51 +04:00
|
|
|
Both of these will be converted to (in Erlang syntax):
|
2009-10-08 10:48:53 +04:00
|
|
|
|
|
|
|
{foo, [1, 2, 3]}
|
|
|
|
|
2009-10-08 08:14:40 +04:00
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
|
|
|
gem install bert -s http://gemcutter.org
|
|
|
|
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
require 'bert'
|
|
|
|
|
2009-10-09 04:15:03 +04:00
|
|
|
bert = BERT.encode(t[:user, {:name => 'TPW', :nick => 'mojombo'}])
|
2010-10-05 14:36:04 +04:00
|
|
|
# => "\203h\002d\000\004userh\003d\000\004bertd\000\004dictl\000\000\
|
|
|
|
000\002h\002d\000\004namem\000\000\000\003TPWh\002d\000\004nickm\
|
|
|
|
000\000\000\amojomboj"
|
2009-10-08 08:43:52 +04:00
|
|
|
|
|
|
|
BERT.decode(bert)
|
2009-10-09 04:18:36 +04:00
|
|
|
# => t[:user, {:name=>"TPW", :nick=>"mojombo"}]
|
2009-10-08 08:43:52 +04:00
|
|
|
|
2009-10-08 08:14:40 +04:00
|
|
|
|
|
|
|
|
|
|
|
Note on Patches/Pull Requests
|
|
|
|
-----------------------------
|
2009-10-08 06:18:16 +04:00
|
|
|
|
|
|
|
* Fork the project.
|
|
|
|
* Make your feature addition or bug fix.
|
|
|
|
* Add tests for it. This is important so I don't break it in a
|
|
|
|
future version unintentionally.
|
|
|
|
* Commit, do not mess with rakefile, version, or history.
|
|
|
|
(if you want to have your own version, that is fine but
|
|
|
|
bump version in a commit by itself I can ignore when I pull)
|
|
|
|
* Send me a pull request. Bonus points for topic branches.
|
|
|
|
|
2009-10-08 08:14:40 +04:00
|
|
|
|
|
|
|
Copyright
|
|
|
|
---------
|
2009-10-08 06:18:16 +04:00
|
|
|
|
|
|
|
Copyright (c) 2009 Tom Preston-Werner. See LICENSE for details.
|