rencoder 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/README.md +28 -5
- data/lib/rencoder/decoder.rb +1 -1
- data/lib/rencoder/version.rb +1 -1
- data/spec/rencoder/decoder_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a89dc8e168dfd539d8c8c6e2280f84d44fbf46
|
4
|
+
data.tar.gz: 4f32d7cd11b02e312fce9ea333fb98f247e251c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2325cff13c80b3b2ef4961c117f574904ee468ff1f04cceb3a47ea10edad9a0d2460065c5934fa4458ab38ed1b82d27e78dbb4f7f129e278413f167e9385146
|
7
|
+
data.tar.gz: 21fe2903654904c946c2e422637bfe959fbb37c2fc0114acb25ab4ab78f7cfe32685895f44f882162e3e551b6ae19ccbb5b8970bcd1444c58e57ba38ec72f252
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
# Rencoder
|
2
2
|
|
3
|
-
Rencoder is pure Ruby implementation of
|
3
|
+
Rencoder is pure Ruby implementation of Rencode serialization format encoding/decoding.
|
4
4
|
|
5
5
|
Rencoder is *FULLY* compliant with Python implementation, and uses all optimizations (by-type-offset integers, strings, arrays, hashes) both in encoding and decoding.
|
6
6
|
|
7
|
+
Rencoder has no runtime dependencies. Everything done in a pure Ruby.
|
8
|
+
|
9
|
+
More about Rencode format:
|
10
|
+
- <https://github.com/aresch/rencode>
|
11
|
+
- <http://barnesc.blogspot.ru/2006/01/rencode-reduced-length-encodings.html>
|
12
|
+
- <https://mail.python.org/pipermail/python-announce-list/2006-January/004643.html>
|
13
|
+
|
7
14
|
## Usage
|
8
15
|
|
9
16
|
### Serialization
|
@@ -11,9 +18,9 @@ Rencoder is *FULLY* compliant with Python implementation, and uses all optimizat
|
|
11
18
|
```ruby
|
12
19
|
require 'rencoder'
|
13
20
|
|
14
|
-
|
21
|
+
Rencoder.dump("Hello World") # Strings
|
15
22
|
|
16
|
-
|
23
|
+
Rencoder.dump(100) # Integer
|
17
24
|
|
18
25
|
Rencoder.dump(1.0001) # Floats
|
19
26
|
|
@@ -25,7 +32,7 @@ Rencoder.dump(["hello", :world, 123]) # Arrays
|
|
25
32
|
**Float precion notice**
|
26
33
|
Rencoder uses 64-bit precision by default.
|
27
34
|
It's highly recommended to stay that way.
|
28
|
-
If there is strong reason to use 32-bit precision, then please specify
|
35
|
+
If there is strong reason to use 32-bit precision, then please specify
|
29
36
|
``float32: true`` option for ``Rencoder.dump``:
|
30
37
|
|
31
38
|
```ruby
|
@@ -43,8 +50,24 @@ Rencoder.load(hash_data)
|
|
43
50
|
|
44
51
|
Rencoder.load(string_data)
|
45
52
|
# => "Hello World"
|
53
|
+
```
|
54
|
+
|
55
|
+
**Rencoder can read data from any IO object directly without using any buffers**
|
56
|
+
```ruby
|
57
|
+
socket = TCPSocket.new('example.com', 8814)
|
58
|
+
Rendcoder.load(socket)
|
59
|
+
# => "Example!"
|
60
|
+
```
|
61
|
+
|
62
|
+
### ActiveRecord
|
63
|
+
|
64
|
+
Rencoder is compliant with ActiveSupport ``serialize`` interface:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
class MyModel < ActiveRecord::Base
|
68
|
+
serialize :data, Rencoder
|
69
|
+
end
|
46
70
|
|
47
|
-
# etc
|
48
71
|
```
|
49
72
|
|
50
73
|
## Installation
|
data/lib/rencoder/decoder.rb
CHANGED
data/lib/rencoder/version.rb
CHANGED
@@ -6,6 +6,12 @@ describe Rencoder::Decoder do
|
|
6
6
|
subject { Rencoder::Coder.new }
|
7
7
|
|
8
8
|
describe '#decode' do
|
9
|
+
it 'raises EOFError on EOF' do
|
10
|
+
expect {
|
11
|
+
subject.decode(StringIO.new)
|
12
|
+
}.to raise_error(EOFError)
|
13
|
+
end
|
14
|
+
|
9
15
|
describe 'string' do
|
10
16
|
it 'decode string' do
|
11
17
|
expect(subject.decode(serialized_string)).to eq('Test')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rencoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Yamolov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|