mochilo 1.1 → 1.2

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: cab1fe4d6e48774885abd85fccf875cd4a5c6e0c
4
- data.tar.gz: da30bd8b80d4f1814603ee79d3eb7e9a26fa471f
3
+ metadata.gz: 64991c41216b4fb7659230eb433f7cb6c3f4ffff
4
+ data.tar.gz: 21e5f81fdf2be02ad17303ca98636020fa2f8f78
5
5
  SHA512:
6
- metadata.gz: ea8c3721d85561ec7008a1bf5b06985dbae2829dcf6d1976bd21e4c82f47664735200915898490aaf2db1284d9654104a7718fcde0d95f119aa74268e87551b4
7
- data.tar.gz: 99d4ddc0bbe85b2c091b168a3f71057d5aa4b41c7e714ee9235d98e8eb9bb875818f5341b73da0b8c848aecd7b2b71be89486a138f72584b64c0645774b24555
6
+ metadata.gz: 8258d48406e1674370d61cf42562db462908a6239f8471f2033a157bc4547fe4e7793d74a516046f6326d4473e73162be9b467b35f4e6fe55f43aa09c763fec7
7
+ data.tar.gz: 4e44d9ab0960cadaa4b70c15c1da0b2b10447dfe3790f80189d6ee70f697966b52bdbb9ae9546b446f7bfa860274efb8cd212f80ca26c858ddc1ad8850fc1f66
@@ -2,6 +2,8 @@ language: ruby
2
2
  script:
3
3
  - bundle exec rake test
4
4
  rvm:
5
- - 1.9.3
5
+ - 2.3.0
6
+ - 2.2
7
+ - 2.1
6
8
  - 2.0.0
7
- - 2.1.2
9
+ - ruby-head
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mochilo (1.1)
4
+ mochilo (1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -28,3 +28,6 @@ DEPENDENCIES
28
28
  msgpack
29
29
  pry
30
30
  rake-compiler (>= 0.8.1)
31
+
32
+ BUNDLED WITH
33
+ 1.11.2
@@ -269,9 +269,14 @@ void mochilo_pack_one(mochilo_buf *buf, VALUE rb_object, int trusted)
269
269
  return;
270
270
 
271
271
  default:
272
- rb_raise(rb_eMochiloPackError,
273
- "Unsupported object type: %s", rb_obj_classname(rb_object));
272
+ if (rb_respond_to(rb_object, rb_intern("to_bpack"))) {
273
+ VALUE bpack = rb_funcall(rb_object, rb_intern("to_bpack"), 0);
274
+
275
+ mochilo_buf_put(buf, RSTRING_PTR(bpack), RSTRING_LEN(bpack));
276
+ } else {
277
+ rb_raise(rb_eMochiloPackError,
278
+ "Unsupported object type: %s", rb_obj_classname(rb_object));
279
+ }
274
280
  return;
275
281
  }
276
282
  }
277
-
@@ -1,3 +1,3 @@
1
1
  module Mochilo
2
- VERSION = "1.1"
2
+ VERSION = "1.2"
3
3
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.require_paths = ["lib"]
14
14
  s.rubygems_version = %q{1.4.2}
15
15
  s.summary = %q{A ruby library for BananaPack}
16
- s.test_files = `git ls-files spec`.split("\n")
16
+ s.test_files = `git ls-files test`.split("\n")
17
17
  s.required_ruby_version = ">= 1.9.3"
18
18
 
19
19
  # tests
@@ -164,6 +164,12 @@ class MochiloPackTest < MiniTest::Unit::TestCase
164
164
  # TODO: not sure how to test this without making a massive 66k item hash
165
165
  end
166
166
 
167
+ def test_pack_custom_type
168
+ obj = CustomType.new("custom")
169
+
170
+ assert_equal "\xA6custom", Mochilo.pack(obj)
171
+ end
172
+
167
173
  def test_pack_unsupported_type
168
174
  assert_raises Mochilo::PackError do
169
175
  Mochilo.pack(Object.new)
@@ -14,3 +14,12 @@ require 'minitest/autorun'
14
14
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
15
15
  $LOAD_PATH.unshift File.expand_path('..', __FILE__)
16
16
 
17
+ class CustomType
18
+ def initialize(str)
19
+ @str = str
20
+ end
21
+
22
+ def to_bpack
23
+ Mochilo.pack(@str)
24
+ end
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mochilo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vicent Martí
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-17 00:00:00.000000000 Z
12
+ date: 2016-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
@@ -111,8 +111,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.2.2
114
+ rubygems_version: 2.5.1
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: A ruby library for BananaPack
118
- test_files: []
118
+ test_files:
119
+ - test/assets/pulls.json
120
+ - test/pack_test.rb
121
+ - test/setup.rb
122
+ - test/unpack_test.rb