thrift-base64 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/lib/thrift/base64.rb +12 -0
- data/lib/thrift/base64/version.rb +1 -1
- data/test.thrift +5 -0
- data/test/acceptance_test.rb +10 -0
- data/vendor/gen-rb/test_types.rb +29 -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: 353e1b31954aceb268bf108ab4edc268fc6dc20b
|
4
|
+
data.tar.gz: fd80998b5498e748e381c207c0118150d1d6340b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c2795ff3536a4633e110bb1e3a20f7ff42293a4e6acb0d49b0a344115e32a07d5b9183e3683de7e327b33f1358e58c4588dd69f975383187a203925586e6b4f
|
7
|
+
data.tar.gz: 0aebced38795b1201bde45b6df48bb5a8dbd479ca70526d0ed659a8b91ea1186cb7693ee395a01519f90ba38b757aa0e7f399a56b873cb136e29be2bc7f9fc6c
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ protocols. Just check out the benchmarks below.
|
|
58
58
|
YAML/Binary: 6118.3 i/s - 5.96x slower
|
59
59
|
YAML/YAML String: 3636.5 i/s - 10.03x slower
|
60
60
|
|
61
|
-
These benchmarks are included in [benchmark/]
|
61
|
+
These benchmarks are included in [benchmark/](benchmark/).
|
62
62
|
|
63
63
|
## Installation
|
64
64
|
|
@@ -80,8 +80,7 @@ Or install it yourself as:
|
|
80
80
|
|
81
81
|
`thrift-base64` adds two classes to the `Thrift` module:
|
82
82
|
`Thrift::Base64Derserializer` & `Thrift::Base64Serializer`. They mimic the
|
83
|
-
interface of `Thirft::Deserializer` & `Thrift::Serializer
|
84
|
-
require no arguments to `initialize`. Here's an example:
|
83
|
+
interface of `Thirft::Deserializer` & `Thrift::Serializer`.
|
85
84
|
|
86
85
|
```ruby
|
87
86
|
require 'thrift-base64'
|
data/lib/thrift/base64.rb
CHANGED
@@ -49,4 +49,16 @@ module Thrift
|
|
49
49
|
to_base64 CompactProtocolFactory.new
|
50
50
|
end
|
51
51
|
end
|
52
|
+
|
53
|
+
class Union
|
54
|
+
extend Base64Extension::FromBase64
|
55
|
+
|
56
|
+
def to_base64(protocol = BinaryProtocolFactory.new)
|
57
|
+
Base64Serializer.new(protocol).serialize self
|
58
|
+
end
|
59
|
+
|
60
|
+
def to_compact_base64
|
61
|
+
to_base64 CompactProtocolFactory.new
|
62
|
+
end
|
63
|
+
end
|
52
64
|
end
|
data/test.thrift
CHANGED
data/test/acceptance_test.rb
CHANGED
@@ -52,6 +52,16 @@ class AcceptanceTest < MiniTest::Unit::TestCase
|
|
52
52
|
assert_equal struct.message, deserialized.message
|
53
53
|
end
|
54
54
|
|
55
|
+
def test_works_with_unions
|
56
|
+
union = SimpleUnion.new foo: 'set'
|
57
|
+
|
58
|
+
roundtripped = SimpleUnion.from_base64(union.to_base64)
|
59
|
+
assert_equal union.foo, roundtripped.foo
|
60
|
+
|
61
|
+
roundtripped = SimpleUnion.from_compact_base64(union.to_compact_base64)
|
62
|
+
assert_equal union.foo, roundtripped.foo
|
63
|
+
end
|
64
|
+
|
55
65
|
private
|
56
66
|
|
57
67
|
def assert_utf8(string)
|
data/vendor/gen-rb/test_types.rb
CHANGED
@@ -23,3 +23,32 @@ class SimpleStruct
|
|
23
23
|
::Thrift::Struct.generate_accessors self
|
24
24
|
end
|
25
25
|
|
26
|
+
class SimpleUnion < ::Thrift::Union
|
27
|
+
include ::Thrift::Struct_Union
|
28
|
+
class << self
|
29
|
+
def foo(val)
|
30
|
+
SimpleUnion.new(:foo, val)
|
31
|
+
end
|
32
|
+
|
33
|
+
def bar(val)
|
34
|
+
SimpleUnion.new(:bar, val)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
FOO = 1
|
39
|
+
BAR = 2
|
40
|
+
|
41
|
+
FIELDS = {
|
42
|
+
FOO => {:type => ::Thrift::Types::STRING, :name => 'foo'},
|
43
|
+
BAR => {:type => ::Thrift::Types::STRING, :name => 'bar'}
|
44
|
+
}
|
45
|
+
|
46
|
+
def struct_fields; FIELDS; end
|
47
|
+
|
48
|
+
def validate
|
49
|
+
raise(StandardError, 'Union fields are not set.') if get_set_field.nil? || get_value.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
::Thrift::Union.generate_accessors self
|
53
|
+
end
|
54
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrift-base64
|
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
|
- ahawkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thrift
|