BERT (Binary ERlang Term) serialization library for Ruby.
Перейти к файлу
Laura Radville f3b2e729cb
Merge pull request #17 from github/radville/prepare-frozen-strings
Prepare for frozen strings: mark strings as mutable to allow us to set --enable-frozen-string-literal globally
2024-09-05 11:04:50 -04:00
bench mochilo v1 == bert v3, mochilo v2 == bert v4 2017-05-30 12:32:32 -04:00
ext/bert/c decode: do not keep a reference to classes across calls 2020-10-30 09:25:10 +01:00
gemfiles brianmario/mochilo#20 is merged 2017-06-06 16:37:02 -04:00
lib marks strings as mutable 2024-09-05 10:11:32 -04:00
test mochilo v1 == bert v3, mochilo v2 == bert v4 2017-05-30 12:32:32 -04:00
.document Initial commit to bert. 2009-10-07 19:18:16 -07:00
.gitignore Bundlerize 2016-05-19 19:08:33 +02:00
.travis.yml Use a varying mochilo version in CI 2017-05-30 09:47:15 -04:00
Gemfile Update dependencies so that a new enough mochilo is used 2017-06-06 16:08:36 -04:00
Gemfile.lock Upgrade yajl-ruby and rake. 2021-03-17 14:46:58 -05:00
History.txt bert 1.1.6 2012-05-25 15:03:29 -07:00
LICENSE Initial commit to bert. 2009-10-07 19:18:16 -07:00
README.md replace Fixnum and Bignum with Integer 2017-01-11 15:00:27 +11:00
Rakefile Use rake-compiler 2016-05-23 15:33:07 +02:00
VERSION Bump version to 1.1.10 2016-05-23 11:00:48 +02:00
bert.gemspec Update dependencies so that a new enough mochilo is used 2017-06-06 16:08:36 -04:00

README.md

BERT

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

See the BERT specification at bert-rpc.org.

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

  • Integer
  • 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[: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(t[:user, {:name => 'TPW', :nick => 'mojombo'}])
# => "\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"

BERT.decode(bert)
# => t[: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.