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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e4a5fe649e623f7058b7e081b03710bb11a16dc
4
- data.tar.gz: f1a19bd39b9d269f72ca11d22deb1f12abbb859a
3
+ metadata.gz: a0a89dc8e168dfd539d8c8c6e2280f84d44fbf46
4
+ data.tar.gz: 4f32d7cd11b02e312fce9ea333fb98f247e251c4
5
5
  SHA512:
6
- metadata.gz: d5f773dac8f19d1409d5febdac6cb94f2360b7fb21962fcafa59c662725b955804594ccf93d802e02df950ae5a3e24423268b0cf97c59d10dcaeabc3d5179685
7
- data.tar.gz: 716bfbe002718eac3ea92b3803e8a3426e788d3d882405d1862afd62cd0cec33a3fc4a21671cf22bd6d4d42fcaabf167662c85f857a22aeacbe52a02fbaa432d
6
+ metadata.gz: b2325cff13c80b3b2ef4961c117f574904ee468ff1f04cceb3a47ea10edad9a0d2460065c5934fa4458ab38ed1b82d27e78dbb4f7f129e278413f167e9385146
7
+ data.tar.gz: 21fe2903654904c946c2e422637bfe959fbb37c2fc0114acb25ab4ab78f7cfe32685895f44f882162e3e551b6ae19ccbb5b8970bcd1444c58e57ba38ec72f252
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rencoder.gemspec
4
4
  gemspec
5
-
6
- gem 'rencode-ruby'
data/README.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Rencoder
2
2
 
3
- Rencoder is pure Ruby implementation of Rencoder serialization format encoding/decoding.
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
- Rencode.dump("Hello World") # Strings
21
+ Rencoder.dump("Hello World") # Strings
15
22
 
16
- Rencode.dump(100) # Integer
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
@@ -10,7 +10,7 @@ module Rencoder
10
10
  def decode(buffer)
11
11
  buffer = StringIO.new(buffer) unless buffer.respond_to?(:read) # IO object
12
12
 
13
- type = buffer.getbyte
13
+ type = buffer.readbyte
14
14
 
15
15
  case type
16
16
  when STR_HEADER, STR_FIXED
@@ -1,3 +1,3 @@
1
1
  module Rencoder
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -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.0
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-12 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler