Skip to content

kyrylo/rmarshal

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Decodes Ruby's Marshal.dump gibberish into orthodox Erlang

Resources

License

Stars

Watchers

Forks

Packages

No packages published