Decodes Ruby's Marshal.dump gibberish into orthodox Erlang
Erlang Makefile
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
include
src
test
.gitignore
.travis.yml
LICENCE.txt
Makefile
README.md
rebar
rebar.config

README.md

RMarshal

Build Status semver

Introduction

This Erlang library deserialises Ruby objects dumped by Marshal.dump into Erlang terms. It's like Ruby's Marshal.load, but for Erlang. Currently, it doesn't support loading advanced objects like classes, but the bare minimum is supported. The list of supported objects includes:

  • Fixnum
  • Hash
  • Array
  • Bignum
  • Symbol
  • Float
  • String

Installation

Rebar3

%% rebar.config
{deps, [
  {rmarshal, {git, "git://github.com/kyrylo/rmarshal.git", {tag, "v0.0.4"}}}
]}.

Examples

Basic example

Dump some Ruby objects into a binary file:

# data.rb
data = Marshal.dump(hello: 'world')
File.open('data.dat', 'w') do |f|
  f.write(data)
end

Read the dumped data with Erlang and load it with help of the RMarshal library:

%% loader.erl
load_ruby_data() ->
    case file:read_file("data.dat") of
        {ok, BinaryData} -> rmarshal:load(BinaryData);
        Any -> Any
    end.

load_ruby_data()
%% Returns:
%% {ok, #{hello => "world"}}

API

rmarshal:load/1

Accepts binary string formatted according to the official Marshal Format. Returns a tuple with in the format {ok, rterm()}.

{ok, Decoded} = rmarshal:load(BinaryData).

Testing

Run the following command:

make test

Supported Erlang versions

  • ≥17.0

Contact

In case you have a problem, question or a bug report, feel free to:

Licence

The project uses the zlib License. See the LICENCE.txt file for more information.