BERT (Binary ERlang Term) serialization library for Ruby.
Перейти к файлу
Tom Preston-Werner a13f8746e6 switch to explicitly declaring tuples instead of lists 2009-10-08 15:47:51 -07:00
lib switch to explicitly declaring tuples instead of lists 2009-10-08 15:47:51 -07:00
test switch to explicitly declaring tuples instead of lists 2009-10-08 15:47:51 -07:00
.document Initial commit to bert. 2009-10-07 19:18:16 -07:00
.gitignore Initial commit to bert. 2009-10-07 19:18:16 -07:00
History.txt first solid state 2009-10-07 21:14:40 -07:00
LICENSE Initial commit to bert. 2009-10-07 19:18:16 -07:00
README.md switch to explicitly declaring tuples instead of lists 2009-10-08 15:47:51 -07:00
Rakefile more spec compliance 2009-10-08 00:17:46 -07:00

README.md

BERT

BERT is a BERT (Binary ERlang Term) serialization library for Ruby. It can encode Ruby objects into BERT format and decode BERT binaries into Ruby objects.

Instances of the following Ruby classes will be automatically converted to the proper simple BERT type:

  • Fixnum
  • Float
  • Symbol
  • Array
  • String

Instances of the following Ruby classes will be automatically converted to the proper complex BERT type:

  • NilClass
  • TrueClass
  • FalseClass
  • Hash
  • Time
  • Regexp

To designate tuples, simply prefix an Array literal with a t or use the BERT::Tuple class:

t[:foo, [1, 2, 3]]
BERT::Tuple.new([:foo, [1, 2, 3]])

Both of these will be converted to (in Erlang syntax):

{foo, [1, 2, 3]}

Installation

gem install bert -s http://gemcutter.org

Usage

require 'bert'

bert = BERT.encode([:user, {:name => 'TPW', :nick => 'mojombo'}])
# => "\203h\002d\000\004userh\003d\000\004dictl\000\000\000\002d
      \000\004nickm\000\000\000\amojombojl\000\000\000\002d\000
      \004namem\000\000\000\003TPWj"

BERT.decode(bert)
# => [:user, {:name => 'TPW', :nick => 'mojombo'}]

Note on Patches/Pull Requests

  • 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.

Copyright (c) 2009 Tom Preston-Werner. See LICENSE for details.