xdr 3.0.0 → 3.0.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
  SHA256:
3
- metadata.gz: 0d5bbd8152326ee17057091ea8a9ec722f07ad88c74bf9717b16cdab900401e5
4
- data.tar.gz: 60dfea4235d890dc70553903b5130ed05e5c98e83bc3586ecf0bd7e447cb205e
3
+ metadata.gz: cf995b29e360c1ebdc82ee5c94ea470d7d8e87a577263f2faeb8fd3d7fce4a62
4
+ data.tar.gz: ad232ebcb97bef9e00e9fd1103a37cf87941171e5d6fdb89a38addef8ea1afa6
5
5
  SHA512:
6
- metadata.gz: d74217c94b1cbb5a7e0c6b1bcf14547c5b5d186b6bcabe6c078b5d941ac3953dd32ab652f151f8ed970c8c6fc92cbcee2e7608ab6c3b3d57e6d7de1080a780e6
7
- data.tar.gz: cf5d7fd46ef66e83c70860d52ef50dab523af310ab2aba5f7cc06543791adac5d8afbefd8480734f1a34259ecdd2da2c5921f30e90fc84113f89bb006ae5d7de
6
+ metadata.gz: 7026fd132281c4955332ae9acbd4757c1e0d61e29b900139cc24475e8e347381da3c77f04896ea3841a81b790972fc8bc4fa0c79c36922315283921b6c456836
7
+ data.tar.gz: 9db16c2e581691273a475f6044fcff536accc8a9531c195571b784aaee2534f47409593b54d2c9102072ba9eea8a7871348dbafb789a99eee34e17b3b958d28b
@@ -1,4 +1,4 @@
1
- # Changelog
1
+ # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this
4
4
  file. This project adheres to [Semantic Versioning](http://semver.org/).
@@ -6,12 +6,18 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
6
6
  As this project is pre 1.0, breaking changes may happen for minor version
7
7
  bumps. A breaking change will get clearly notified in this log.
8
8
 
9
- ## [Unreleased](https://github.com/stellar/ruby-stellar-base/compare/v1.0.0...master)
9
+ ## [Unreleased](https://github.com/stellar/ruby-xdr/compare/v3.0.1...master)
10
+
11
+ ## [3.0.1](https://github.com/stellar/ruby-xdr/compare/v3.0.0...v3.0.1)
12
+
13
+
14
+ ### Added
15
+ - Add encoding parameter to Union#to_xdr ((#7)[https://github.com/stellar/ruby-xdr/pull/7]).
10
16
 
11
17
  ### Fixed
12
18
  - Padding bytes are now properly validated when reading xdr values. According to the XDR spec, padding must be zeros.
13
19
 
14
- ## [1.0.0](https://github.com/stellar/ruby-stellar-base/compare/v0.1.0...v1.0.0)
20
+ ## [1.0.0](https://github.com/stellar/ruby-xdr/compare/v0.1.0...v1.0.0)
15
21
 
16
22
  ### Added
17
23
  - the `to_xdr` helpers can take a second parameter that will encode the resulting output to hex or base64 when requested.
@@ -45,7 +45,7 @@ module XDR::Concerns::ConvertsToXDR
45
45
  tap{|io| write(val, io)}.
46
46
  string.force_encoding("ASCII-8BIT")
47
47
 
48
- case encoding
48
+ case encoding.to_s
49
49
  when 'raw' ; raw
50
50
  when 'base64' ; Base64.strict_encode64(raw)
51
51
  when 'hex' ; raw.unpack("H*").first
@@ -75,8 +75,14 @@ class XDR::Union
75
75
  set(switch, value) unless switch == :__unset__
76
76
  end
77
77
 
78
- def to_xdr
79
- self.class.to_xdr self
78
+ #
79
+ # Serializes struct to xdr, return a string of bytes
80
+ #
81
+ # @param format=:raw [Symbol] The encoding used for the bytes produces, one of (:raw, :hex, :base64)
82
+ #
83
+ # @return [String] The encoded bytes of this struct
84
+ def to_xdr(format=:raw)
85
+ self.class.to_xdr(self, format)
80
86
  end
81
87
 
82
88
  def set(switch, value=:void)
@@ -1,3 +1,3 @@
1
1
  module XDR
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
@@ -186,6 +186,16 @@ describe XDR::Union, "#switch" do
186
186
  end
187
187
  end
188
188
 
189
+ describe XDR::Union, "#to_xdr" do
190
+ subject { UnionSpec::Result.new(:error, "spec error") }
191
+
192
+ context "with base64 encoding" do
193
+ it "returns base64 encoding of union's XDR" do
194
+ expect(subject.to_xdr(:base64)).to eq("AAAAAQAAAApzcGVjIGVycm9yAAA=")
195
+ end
196
+ end
197
+ end
198
+
189
199
  module UnionSpec
190
200
  class ResultType < XDR::Enum
191
201
  member :ok, 0
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_dependency "activesupport", ">= 5.2.0"
21
21
  spec.add_dependency "activemodel", ">= 5.2.0"
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "bundler", "~> 2.1.4"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.1"
26
26
  spec.add_development_dependency "guard-rspec"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xdr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-10 00:00:00.000000000 Z
11
+ date: 2020-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.7'
47
+ version: 2.1.4
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.7'
54
+ version: 2.1.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -209,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  - !ruby/object:Gem::Version
210
210
  version: '0'
211
211
  requirements: []
212
- rubyforge_project:
213
- rubygems_version: 2.7.6
212
+ rubygems_version: 3.0.3
214
213
  signing_key:
215
214
  specification_version: 4
216
215
  summary: XDR Helper Library