vox-etf 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: cd3946973c5609f6a44d6f1bc0ea10d3f5ed7095dd0009ddaaa64593c90de538
4
- data.tar.gz: 6e50761784880810734201a0d6e4684c2def7b6f4e7de0464ac8e42491768a12
3
+ metadata.gz: 20430b5c79bc96dd01b89eb8a15e4f18ad5387d2da0401a32757207a8e4bb997
4
+ data.tar.gz: 030dfda27dbe590878dd76514f151afb2d0ef275dfa1d3056f8712ecd514efda
5
5
  SHA512:
6
- metadata.gz: 111a3cc908087690d58e0ac939c3b3d1576d05bfc50fdb457e55eaa0ee54b71f1ae29bfb804e234c98bae047c8809803f5268ab1fddb5808cfff81ed5a492007
7
- data.tar.gz: c176eb3b67e1d83d6972eb50e5263f57286a37c1093b47ad3c92f3513f4e1c2902ec4b218dce4e813f004cd4e6d8e8917cdef223f40d1650db4e115c78a85fb6
6
+ metadata.gz: 8abe290ea1d4816ec4c9db1e408bc0540d54ebb8659d1e6f617c6524adfd2ce010013bf20d25eca76bd5ad9fd284343219b9d22c14cfc81de57d1ef663e73e4b
7
+ data.tar.gz: f1c124d99a11e882a2351b95937ce8b341e25322d057111be055b229cb44ea4f1d21c1fc0aa6f5fe638ec1f6369851f1957f3f812bada7fcb4bf5fd4980ee68c
@@ -4,6 +4,33 @@
4
4
  #include "erlpack/sysdep.h"
5
5
  #include "erlpack/constants.h"
6
6
 
7
+ /* This code is highly derivative of discord's erlpack decoder
8
+ * targeting Javascript.
9
+ *
10
+ *
11
+ * MIT License
12
+ *
13
+ * Copyright (c) 2017 Discord
14
+ *
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ * of this software and associated documentation files (the "Software"), to deal
17
+ * in the Software without restriction, including without limitation the rights
18
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ * copies of the Software, and to permit persons to whom the Software is
20
+ * furnished to do so, subject to the following conditions:
21
+ *
22
+ * The above copyright notice and this permission notice shall be included in all
23
+ * copies or substantial portions of the Software.
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ * SOFTWARE.
32
+ */
33
+
7
34
  namespace etf
8
35
  {
9
36
  class decoder
@@ -131,12 +158,12 @@ namespace etf
131
158
  return val;
132
159
  }
133
160
 
134
- VALUE decode_small_integer(void)
161
+ VALUE decode_small_integer()
135
162
  {
136
163
  return INT2FIX(read8());
137
164
  }
138
165
 
139
- VALUE decode_integer(void)
166
+ VALUE decode_integer()
140
167
  {
141
168
  return INT2NUM(read32());
142
169
  }
@@ -57,13 +57,23 @@ namespace etf
57
57
  encode_hash(input);
58
58
  break;
59
59
  default:
60
- rb_raise(rb_eArgError, "Unsupported serialization type");
60
+ if (rb_respond_to(input, rb_intern("to_hash")))
61
+ {
62
+ VALUE hash = rb_funcall(input, rb_intern("to_hash"), 0);
63
+ Check_Type(hash, T_HASH);
64
+ encode_hash(hash);
65
+ }
66
+ else
67
+ {
68
+ rb_raise(rb_eArgError, "Unsupported serialization type");
69
+ }
70
+
61
71
  break;
62
72
  }
63
73
  }
64
74
 
65
75
  VALUE
66
- r_string(void)
76
+ r_string()
67
77
  {
68
78
  return rb_str_new(erl_buff->buf, erl_buff->length);
69
79
  }
@@ -3,10 +3,6 @@
3
3
  #include "decoder.hpp"
4
4
  #include "etf.hpp"
5
5
 
6
- // Decode an ETF term from a ruby string
7
- // @param self [Object] Vox::ETF
8
- // @param input [Rice::String] The ETF term to be decoded.
9
- // @return [Rice::Object] Whatever the term is, as a ruby object.
10
6
  VALUE decode(VALUE self, VALUE input)
11
7
  {
12
8
  Check_Type(input, T_STRING);
@@ -1,7 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Container for Vox components.
3
4
  module Vox
5
+ # Default ETF adapter for vox's gateway component.
4
6
  module ETF
5
- VERSION = '0.1.2'
7
+ # @!parse [ruby]
8
+ # # Encode an object to an ETF term. This method accepts, `Integer`, `Float`,
9
+ # # `String`, `Symbol`, `Hash`, `Array`, `nil`, `true`, and `false` objects.
10
+ # # It also allows any object that responds to `#to_hash => Hash`.
11
+ # # @param input [Object, #to_hash] The object to be encoded as an ETF term.
12
+ # # @return [String] The ETF term encoded as a packed string.
13
+ # def self.encode(input)
14
+ # end
15
+
16
+ # @!parse [ruby]
17
+ # # Decode an ETF term from a string.
18
+ # # @param input [String] The ETF term to be decoded.
19
+ # # @return [Object] The ETF term decoded to an object.
20
+ # def self.decode(input)
21
+ # end
22
+
23
+ # Gem version
24
+ VERSION = '0.1.3'
6
25
  end
7
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vox-etf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Carey