Skip to content
/ rencoder Public
forked from t3hk0d3/rencoder

Rencoder is pure Ruby implementation of Rencoder serialization format encoding/decoding.

License

Notifications You must be signed in to change notification settings

r6e/rencoder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rencoder

Rencoder is pure Ruby implementation of Rencode serialization format encoding/decoding.

Rencoder is FULLY compliant with Python implementation, and uses all optimizations (by-type-offset integers, strings, arrays, hashes) both for encoding and decoding.

Rencoder has no runtime dependencies. Everything done in a pure Ruby.

More about Rencode format:

Usage

Serialization

require 'rencoder'

Rencoder.dump("Hello World") # Strings

Rencoder.dump(100) # Integer

Rencoder.dump(1.0001) # Floats

Rencoder.dump({ hello: "world" }) # Hashes

Rencoder.dump(["hello", :world, 123]) # Arrays

Float precion notice Rencoder uses 64-bit precision by default. It's highly recommended to stay that way. If there is strong reason to use 32-bit precision, then please specify float32: true option for Rencoder.dump:

Rencoder.dump(1.000001, float32: true)

Using 32-bit precision is highly NOT recommended

Deserialization

require 'rencoder'

Rencoder.load(hash_data)
# => { 'hello': 'world' }

Rencoder.load(string_data)
# => "Hello World"

Rencoder can read data from any IO object directly without using any buffers

socket = TCPSocket.new('example.com', 8814)
Rendcoder.load(socket)
# => "Example!"

ActiveRecord

Rencoder is compliant with ActiveSupport serialize interface:

class MyModel < ActiveRecord::Base
    serialize :data, Rencoder
end

Installation

Add this line to your application's Gemfile:

gem 'rencoder'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rencoder

About

Rencoder is pure Ruby implementation of Rencoder serialization format encoding/decoding.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%