xdr 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -9
  3. data/README.md +4 -2
  4. data/lib/xdr/concerns/converts_to_xdr.rb +30 -31
  5. data/lib/xdr/union.rb +7 -4
  6. data/lib/xdr/version.rb +1 -1
  7. metadata +43 -114
  8. data/.gitignore +0 -15
  9. data/.travis.yml +0 -9
  10. data/.yardopts +0 -7
  11. data/Gemfile +0 -4
  12. data/Guardfile +0 -5
  13. data/Rakefile +0 -9
  14. data/examples/enum.rb +0 -30
  15. data/examples/struct.rb +0 -24
  16. data/examples/union.rb +0 -29
  17. data/spec/lib/xdr/array_spec.rb +0 -73
  18. data/spec/lib/xdr/bool_spec.rb +0 -43
  19. data/spec/lib/xdr/concerns/converts_to_xdr_spec.rb +0 -88
  20. data/spec/lib/xdr/concerns/reads_bytes_spec.rb +0 -57
  21. data/spec/lib/xdr/double_spec.rb +0 -38
  22. data/spec/lib/xdr/dsl/enum_spec.rb +0 -44
  23. data/spec/lib/xdr/dsl/struct_spec.rb +0 -29
  24. data/spec/lib/xdr/dsl/union_spec.rb +0 -69
  25. data/spec/lib/xdr/enum_spec.rb +0 -70
  26. data/spec/lib/xdr/float_spec.rb +0 -37
  27. data/spec/lib/xdr/hyper_spec.rb +0 -40
  28. data/spec/lib/xdr/int_spec.rb +0 -40
  29. data/spec/lib/xdr/opaque_spec.rb +0 -40
  30. data/spec/lib/xdr/option_spec.rb +0 -36
  31. data/spec/lib/xdr/quadruple_spec.rb +0 -14
  32. data/spec/lib/xdr/rpc/record_reader_spec.rb +0 -27
  33. data/spec/lib/xdr/string_spec.rb +0 -47
  34. data/spec/lib/xdr/struct_spec.rb +0 -101
  35. data/spec/lib/xdr/union_spec.rb +0 -258
  36. data/spec/lib/xdr/unsigned_hyper_spec.rb +0 -36
  37. data/spec/lib/xdr/unsigned_int_spec.rb +0 -36
  38. data/spec/lib/xdr/var_array_spec.rb +0 -71
  39. data/spec/lib/xdr/var_opaque_spec.rb +0 -50
  40. data/spec/lib/xdr/void_spec.rb +0 -46
  41. data/spec/spec_helper.rb +0 -15
  42. data/spec/support/matchers/eq_bytes.rb +0 -6
  43. data/xdr.gemspec +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf995b29e360c1ebdc82ee5c94ea470d7d8e87a577263f2faeb8fd3d7fce4a62
4
- data.tar.gz: ad232ebcb97bef9e00e9fd1103a37cf87941171e5d6fdb89a38addef8ea1afa6
3
+ metadata.gz: 1f0a7d79379430aafb61eed9de69792863eae9f09d6879b9c45a6dfdf4899423
4
+ data.tar.gz: 4077d91ba3482d12749dfebfd8af588c8ed8a71ed0ffbc84328752f18bc6099c
5
5
  SHA512:
6
- metadata.gz: 7026fd132281c4955332ae9acbd4757c1e0d61e29b900139cc24475e8e347381da3c77f04896ea3841a81b790972fc8bc4fa0c79c36922315283921b6c456836
7
- data.tar.gz: 9db16c2e581691273a475f6044fcff536accc8a9531c195571b784aaee2534f47409593b54d2c9102072ba9eea8a7871348dbafb789a99eee34e17b3b958d28b
6
+ metadata.gz: '087033c3d5e43816556e6265b76892f64c193764af9342eec0e15e1ff615c2f1bed2ef1900d02fc6cd54afb3e158fe081b1a4b966fba019275d48e6c66cb14ac'
7
+ data.tar.gz: 01b99345355417827e4087075724186082f713c807612a4ac481a9d84bfefeb6bac31abc9819f0c807ce0d31296f2854dd055f03b4b17c1257c27feb0151e442
@@ -1,28 +1,31 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this
4
- file. This project adheres to [Semantic Versioning](http://semver.org/).
3
+ All notable changes to this project will be documented in this file.
5
4
 
6
- As this project is pre 1.0, breaking changes may happen for minor version
7
- bumps. A breaking change will get clearly notified in this log.
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
7
 
9
- ## [Unreleased](https://github.com/stellar/ruby-xdr/compare/v3.0.1...master)
8
+ ## [Unreleased](https://github.com/stellar/ruby-xdr/compare/v3.0.2...master)
10
9
 
11
- ## [3.0.1](https://github.com/stellar/ruby-xdr/compare/v3.0.0...v3.0.1)
10
+ ## [3.0.2](https://github.com/stellar/ruby-xdr/compare/v3.0.1...v3.0.2) - 2020-10-20
11
+ ### Changed
12
+ - Relax lower bound for ActiveSupport dependency to support usage in Rails 4.2 ((#12)[https://github.com/stellar/ruby-xdr/pull/12])
12
13
 
14
+ ### Fixed
15
+ - Fix non-bang arm accessors for XDR::Union ((#13)[https://github.com/stellar/ruby-xdr/pull/13])
16
+ - Fix .from_xdr encoding param to accept symbols ((#14)[https://github.com/stellar/ruby-xdr/pull/14])
13
17
 
18
+ ## [3.0.1](https://github.com/stellar/ruby-xdr/compare/v3.0.0...v3.0.1) - 2020-06-10
14
19
  ### Added
15
20
  - Add encoding parameter to Union#to_xdr ((#7)[https://github.com/stellar/ruby-xdr/pull/7]).
16
21
 
17
22
  ### Fixed
18
23
  - Padding bytes are now properly validated when reading xdr values. According to the XDR spec, padding must be zeros.
19
24
 
20
- ## [1.0.0](https://github.com/stellar/ruby-xdr/compare/v0.1.0...v1.0.0)
21
-
25
+ ## [1.0.0](https://github.com/stellar/ruby-xdr/compare/v0.1.0...v1.0.0) - 2015-10-02
22
26
  ### Added
23
27
  - the `to_xdr` helpers can take a second parameter that will encode the resulting output to hex or base64 when requested.
24
28
  - the `from_xdr` helpers can take a second parameter that will trigger a decode from hex or base64 of the provided string before decoding from xdr.
25
29
 
26
30
  ### Changed
27
-
28
31
  - `from_xdr` raises an ArgumentError when the input data is not fully consumed
data/README.md CHANGED
@@ -95,9 +95,11 @@ all of it's children by calling `load_all!` on the module.
95
95
 
96
96
  ## Code generation
97
97
 
98
- ruby-xdr by itself does not have any ability to parse XDR IDL files and produce a parser for your custom data types. Instead, that is the responsibility of [xdrgen](http://github.com/stellar/xdrgen). xdrgen will take your .x files and produce a set of ruby files that target this library to allow for your own custom types.
98
+ ruby-xdr by itself does not have any ability to parse XDR IDL files and produce a parser for your custom
99
+ data types. Instead, that is the responsibility of [xdrgen](http://github.com/stellar/xdrgen). `xdrgen` will
100
+ take your `.x` files and produce a set of ruby files that target this library to allow for your own custom types.
99
101
 
100
- See [ruby-stellar-base](http://github.com/stellar/ruby-stellar-base) for an example (check out the generated directory)
102
+ See [ruby-stellar-base](http://github.com/astroband/ruby-stellar-sdk/tree/master/base/generated) for an example.
101
103
 
102
104
  ## Contributing
103
105
 
@@ -5,68 +5,66 @@ module XDR::Concerns::ConvertsToXDR
5
5
 
6
6
  #
7
7
  # Serialized the provided `val` to xdr and writes it to `io`
8
- #
8
+ #
9
+ # @abstract
9
10
  # @param val [Object] The object to serialize
10
- # @param io [IO] an IO object to write to
11
- #
11
+ # @param io [#write] an IO object to write to
12
+ # @return [void]
12
13
  def write(val, io)
13
14
  raise NotImplementedError, "implement in including class"
14
15
  end
15
16
 
16
17
  #
17
18
  # Reads from the provided IO an instance of the implementing class
18
- # @param io [IO] the io to read from
19
- #
19
+ #
20
+ # @abstract
21
+ # @param io [#read] the io to read from
20
22
  # @return [Object] the deserialized value
21
23
  def read(io)
22
24
  raise NotImplementedError, "implement in including class"
23
25
  end
24
26
 
25
- #
26
27
  # Returns true if the value provided is compatible with this serializer class
27
- #
28
+ #
29
+ # @abstract
28
30
  # @param value [Object] the value to test
29
- #
30
31
  # @return [Boolean] true if valid, false otherwise
31
32
  def valid?(value)
32
33
  raise NotImplementedError, "implement in including class"
33
34
  end
34
-
35
- #
35
+
36
36
  # Serialized the provided val to xdr, returning a string
37
37
  # of the serialized data
38
38
  #
39
39
  # @param val [Object] the value to serialize
40
- #
40
+ # @param encoding [:raw|:hex|:base64] encode the result with specified codec
41
41
  # @return [String] the produced bytes
42
- def to_xdr(val, encoding='raw')
43
- raw = StringIO.
44
- new.
45
- tap{|io| write(val, io)}.
46
- string.force_encoding("ASCII-8BIT")
42
+ def to_xdr(val, encoding = "raw")
43
+ io = StringIO.new
44
+ write(val, io)
45
+ raw = io.string.force_encoding("ASCII-8BIT")
47
46
 
48
- case encoding.to_s
49
- when 'raw' ; raw
50
- when 'base64' ; Base64.strict_encode64(raw)
51
- when 'hex' ; raw.unpack("H*").first
47
+ case String(encoding)
48
+ when "raw" then raw
49
+ when "hex" then raw.unpack("H*").first
50
+ when "base64" then Base64.strict_encode64(raw)
52
51
  else
53
- raise ArgumentError, "Invalid encoding #{encoding.inspect}: must be 'raw', 'base64', or 'hex'"
52
+ raise ArgumentError, "Invalid encoding #{encoding.inspect}: must be 'raw', 'base64', or 'hex'"
54
53
  end
55
54
  end
56
-
57
- #
55
+
58
56
  # Deserializes an object from the provided string of bytes
59
- #
57
+ #
60
58
  # @param string [String] the bytes to read from
61
- #
59
+ # @param encoding [:raw|:hex|:base64] decode the input before deserialization
62
60
  # @return [Object] the deserialized value
63
- def from_xdr(string, encoding='raw')
64
- raw = case encoding
65
- when 'raw' ; string
66
- when 'base64' ; Base64.strict_decode64(string)
67
- when 'hex' ; [string].pack("H*")
61
+ def from_xdr(string, encoding = "raw")
62
+ raw = case String(encoding)
63
+ when "raw" then string
64
+ when "hex" then [string].pack("H*")
65
+ when "base64" then Base64.strict_decode64(string)
68
66
  else
69
- raise ArgumentError, "Invalid encoding #{encoding.inspect}: must be 'raw', 'base64', or 'hex'"
67
+ raise ArgumentError, "Invalid encoding #{encoding.inspect}: must be 'raw', 'base64', or 'hex'"
70
68
  end
71
69
 
72
70
  io = StringIO.new(raw)
@@ -80,6 +78,7 @@ module XDR::Concerns::ConvertsToXDR
80
78
  end
81
79
 
82
80
  private
81
+
83
82
  def padding_for(length)
84
83
  case length % 4
85
84
  when 0 ; 0
@@ -102,14 +102,17 @@ class XDR::Union
102
102
 
103
103
  alias get value
104
104
 
105
- def attribute!(attr)
106
- if @arm.to_s != attr
107
- raise XDR::ArmNotSetError, "#{attr} is not the set arm"
108
- end
105
+ def attribute(attr)
106
+ return nil unless @arm.to_s == attr
109
107
 
110
108
  get
111
109
  end
112
110
 
111
+ def attribute!(attr)
112
+ raise XDR::ArmNotSetError, "#{attr} is not the set arm" unless @arm.to_s == attr
113
+
114
+ get
115
+ end
113
116
 
114
117
  #
115
118
  # Compares two unions for equality
@@ -1,3 +1,3 @@
1
1
  module XDR
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
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.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Fleckenstein
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,117 +16,95 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: '4.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 5.2.0
29
+ version: '4.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activemodel
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 5.2.0
39
+ version: '4.2'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '7.0'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: 5.2.0
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 2.1.4
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
49
+ version: '4.2'
50
+ - - "<"
53
51
  - !ruby/object:Gem::Version
54
- version: 2.1.4
52
+ version: '7.0'
55
53
  - !ruby/object:Gem::Dependency
56
54
  name: rake
57
55
  requirement: !ruby/object:Gem::Requirement
58
56
  requirements:
59
57
  - - "~>"
60
58
  - !ruby/object:Gem::Version
61
- version: '10.0'
59
+ version: '13.0'
62
60
  type: :development
63
61
  prerelease: false
64
62
  version_requirements: !ruby/object:Gem::Requirement
65
63
  requirements:
66
64
  - - "~>"
67
65
  - !ruby/object:Gem::Version
68
- version: '10.0'
66
+ version: '13.0'
69
67
  - !ruby/object:Gem::Dependency
70
68
  name: rspec
71
69
  requirement: !ruby/object:Gem::Requirement
72
70
  requirements:
73
71
  - - "~>"
74
72
  - !ruby/object:Gem::Version
75
- version: '3.1'
73
+ version: '3.0'
76
74
  type: :development
77
75
  prerelease: false
78
76
  version_requirements: !ruby/object:Gem::Requirement
79
77
  requirements:
80
78
  - - "~>"
81
79
  - !ruby/object:Gem::Version
82
- version: '3.1'
83
- - !ruby/object:Gem::Dependency
84
- name: guard-rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
80
+ version: '3.0'
97
81
  - !ruby/object:Gem::Dependency
98
82
  name: simplecov
99
83
  requirement: !ruby/object:Gem::Requirement
100
84
  requirements:
101
- - - ">="
85
+ - - "~>"
102
86
  - !ruby/object:Gem::Version
103
- version: '0'
87
+ version: '0.19'
104
88
  type: :development
105
89
  prerelease: false
106
90
  version_requirements: !ruby/object:Gem::Requirement
107
91
  requirements:
108
- - - ">="
92
+ - - "~>"
109
93
  - !ruby/object:Gem::Version
110
- version: '0'
111
- description:
94
+ version: '0.19'
95
+ description:
112
96
  email:
113
97
  - scott@stellar.org
114
98
  executables: []
115
99
  extensions: []
116
- extra_rdoc_files: []
100
+ extra_rdoc_files:
101
+ - README.md
102
+ - LICENSE.txt
103
+ - CHANGELOG.md
117
104
  files:
118
- - ".gitignore"
119
- - ".travis.yml"
120
- - ".yardopts"
121
105
  - CHANGELOG.md
122
- - Gemfile
123
- - Guardfile
124
106
  - LICENSE.txt
125
107
  - README.md
126
- - Rakefile
127
- - examples/enum.rb
128
- - examples/struct.rb
129
- - examples/union.rb
130
108
  - lib/xdr.rb
131
109
  - lib/xdr/array.rb
132
110
  - lib/xdr/bool.rb
@@ -163,38 +141,15 @@ files:
163
141
  - lib/xdr/var_opaque.rb
164
142
  - lib/xdr/version.rb
165
143
  - lib/xdr/void.rb
166
- - spec/lib/xdr/array_spec.rb
167
- - spec/lib/xdr/bool_spec.rb
168
- - spec/lib/xdr/concerns/converts_to_xdr_spec.rb
169
- - spec/lib/xdr/concerns/reads_bytes_spec.rb
170
- - spec/lib/xdr/double_spec.rb
171
- - spec/lib/xdr/dsl/enum_spec.rb
172
- - spec/lib/xdr/dsl/struct_spec.rb
173
- - spec/lib/xdr/dsl/union_spec.rb
174
- - spec/lib/xdr/enum_spec.rb
175
- - spec/lib/xdr/float_spec.rb
176
- - spec/lib/xdr/hyper_spec.rb
177
- - spec/lib/xdr/int_spec.rb
178
- - spec/lib/xdr/opaque_spec.rb
179
- - spec/lib/xdr/option_spec.rb
180
- - spec/lib/xdr/quadruple_spec.rb
181
- - spec/lib/xdr/rpc/record_reader_spec.rb
182
- - spec/lib/xdr/string_spec.rb
183
- - spec/lib/xdr/struct_spec.rb
184
- - spec/lib/xdr/union_spec.rb
185
- - spec/lib/xdr/unsigned_hyper_spec.rb
186
- - spec/lib/xdr/unsigned_int_spec.rb
187
- - spec/lib/xdr/var_array_spec.rb
188
- - spec/lib/xdr/var_opaque_spec.rb
189
- - spec/lib/xdr/void_spec.rb
190
- - spec/spec_helper.rb
191
- - spec/support/matchers/eq_bytes.rb
192
- - xdr.gemspec
193
144
  homepage: https://github.com/stellar/ruby-xdr
194
145
  licenses:
195
- - Apache 2.0
196
- metadata: {}
197
- post_install_message:
146
+ - Apache-2.0
147
+ metadata:
148
+ bug_tracker_uri: https://github.com/stellar/ruby-xdr/issues
149
+ changelog_uri: https://github.com/stellar/ruby-xdr/blob/v3.0.2/CHANGELOG.md
150
+ documentation_uri: https://rubydoc.info/gems/xdr/3.0.2/
151
+ source_code_uri: https://github.com/stellar/ruby-xdr/tree/v3.0.2
152
+ post_install_message:
198
153
  rdoc_options: []
199
154
  require_paths:
200
155
  - lib
@@ -202,41 +157,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
157
  requirements:
203
158
  - - ">="
204
159
  - !ruby/object:Gem::Version
205
- version: 2.2.0
160
+ version: 2.4.0
206
161
  required_rubygems_version: !ruby/object:Gem::Requirement
207
162
  requirements:
208
163
  - - ">="
209
164
  - !ruby/object:Gem::Version
210
165
  version: '0'
211
166
  requirements: []
212
- rubygems_version: 3.0.3
213
- signing_key:
167
+ rubygems_version: 3.1.4
168
+ signing_key:
214
169
  specification_version: 4
215
170
  summary: XDR Helper Library
216
- test_files:
217
- - spec/lib/xdr/array_spec.rb
218
- - spec/lib/xdr/bool_spec.rb
219
- - spec/lib/xdr/concerns/converts_to_xdr_spec.rb
220
- - spec/lib/xdr/concerns/reads_bytes_spec.rb
221
- - spec/lib/xdr/double_spec.rb
222
- - spec/lib/xdr/dsl/enum_spec.rb
223
- - spec/lib/xdr/dsl/struct_spec.rb
224
- - spec/lib/xdr/dsl/union_spec.rb
225
- - spec/lib/xdr/enum_spec.rb
226
- - spec/lib/xdr/float_spec.rb
227
- - spec/lib/xdr/hyper_spec.rb
228
- - spec/lib/xdr/int_spec.rb
229
- - spec/lib/xdr/opaque_spec.rb
230
- - spec/lib/xdr/option_spec.rb
231
- - spec/lib/xdr/quadruple_spec.rb
232
- - spec/lib/xdr/rpc/record_reader_spec.rb
233
- - spec/lib/xdr/string_spec.rb
234
- - spec/lib/xdr/struct_spec.rb
235
- - spec/lib/xdr/union_spec.rb
236
- - spec/lib/xdr/unsigned_hyper_spec.rb
237
- - spec/lib/xdr/unsigned_int_spec.rb
238
- - spec/lib/xdr/var_array_spec.rb
239
- - spec/lib/xdr/var_opaque_spec.rb
240
- - spec/lib/xdr/void_spec.rb
241
- - spec/spec_helper.rb
242
- - spec/support/matchers/eq_bytes.rb
171
+ test_files: []