xdr 2.0.0 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +26 -7
- data/README.md +21 -19
- data/lib/xdr/array.rb +3 -3
- data/lib/xdr/bool.rb +7 -7
- data/lib/xdr/concerns/array_converter.rb +2 -2
- data/lib/xdr/concerns/converts_to_xdr.rb +40 -41
- data/lib/xdr/concerns/float_converter.rb +1 -1
- data/lib/xdr/concerns/integer_converter.rb +1 -1
- data/lib/xdr/concerns/reads_bytes.rb +10 -1
- data/lib/xdr/concerns/string_converter.rb +1 -1
- data/lib/xdr/double.rb +2 -3
- data/lib/xdr/dsl/enum.rb +8 -9
- data/lib/xdr/dsl/struct.rb +1 -2
- data/lib/xdr/dsl/union.rb +12 -12
- data/lib/xdr/dsl.rb +1 -1
- data/lib/xdr/enum.rb +6 -6
- data/lib/xdr/float.rb +2 -3
- data/lib/xdr/hyper.rb +2 -2
- data/lib/xdr/int.rb +2 -2
- data/lib/xdr/namespace.rb +7 -9
- data/lib/xdr/opaque.rb +5 -5
- data/lib/xdr/option.rb +5 -5
- data/lib/xdr/quadruple.rb +1 -1
- data/lib/xdr/rpc/record.rb +2 -2
- data/lib/xdr/rpc/record_reader.rb +7 -7
- data/lib/xdr/string.rb +4 -4
- data/lib/xdr/struct.rb +15 -16
- data/lib/xdr/struct_validator.rb +1 -1
- data/lib/xdr/union.rb +44 -36
- data/lib/xdr/union_validator.rb +1 -1
- data/lib/xdr/unsigned_hyper.rb +2 -2
- data/lib/xdr/unsigned_int.rb +2 -2
- data/lib/xdr/var_array.rb +4 -4
- data/lib/xdr/var_opaque.rb +3 -3
- data/lib/xdr/version.rb +1 -1
- data/lib/xdr/void.rb +1 -1
- data/lib/xdr.rb +16 -10
- metadata +37 -150
- data/.gitignore +0 -15
- data/.travis.yml +0 -9
- data/.yardopts +0 -7
- data/Gemfile +0 -4
- data/Guardfile +0 -5
- data/Rakefile +0 -9
- data/examples/enum.rb +0 -30
- data/examples/struct.rb +0 -24
- data/examples/union.rb +0 -29
- data/spec/lib/xdr/array_spec.rb +0 -73
- data/spec/lib/xdr/bool_spec.rb +0 -43
- data/spec/lib/xdr/concerns/converts_to_xdr_spec.rb +0 -88
- data/spec/lib/xdr/concerns/reads_bytes_spec.rb +0 -31
- data/spec/lib/xdr/double_spec.rb +0 -38
- data/spec/lib/xdr/dsl/enum_spec.rb +0 -44
- data/spec/lib/xdr/dsl/struct_spec.rb +0 -29
- data/spec/lib/xdr/dsl/union_spec.rb +0 -69
- data/spec/lib/xdr/enum_spec.rb +0 -70
- data/spec/lib/xdr/float_spec.rb +0 -37
- data/spec/lib/xdr/hyper_spec.rb +0 -40
- data/spec/lib/xdr/int_spec.rb +0 -40
- data/spec/lib/xdr/opaque_spec.rb +0 -36
- data/spec/lib/xdr/option_spec.rb +0 -36
- data/spec/lib/xdr/quadruple_spec.rb +0 -14
- data/spec/lib/xdr/rpc/record_reader_spec.rb +0 -27
- data/spec/lib/xdr/string_spec.rb +0 -41
- data/spec/lib/xdr/struct_spec.rb +0 -101
- data/spec/lib/xdr/union_spec.rb +0 -248
- data/spec/lib/xdr/unsigned_hyper_spec.rb +0 -36
- data/spec/lib/xdr/unsigned_int_spec.rb +0 -36
- data/spec/lib/xdr/var_array_spec.rb +0 -71
- data/spec/lib/xdr/var_opaque_spec.rb +0 -43
- data/spec/lib/xdr/void_spec.rb +0 -46
- data/spec/spec_helper.rb +0 -15
- data/spec/support/matchers/eq_bytes.rb +0 -6
- data/xdr.gemspec +0 -28
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe XDR::VarOpaque, "#read" do
|
5
|
-
subject{ XDR::VarOpaque[2] }
|
6
|
-
|
7
|
-
it "decodes values correctly" do
|
8
|
-
expect(read("\x00\x00\x00\x00")).to eq("")
|
9
|
-
expect(read("\x00\x00\x00\x01\x00\x00\x00\x00")).to eq("\x00")
|
10
|
-
expect(read("\x00\x00\x00\x01\x01\x00\x00\x00")).to eq("\x01")
|
11
|
-
expect(read("\x00\x00\x00\x02\x00\x01\x00\x00")).to eq("\x00\x01")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "raises a ReadError when the encoded length is greater than the allowed max" do
|
15
|
-
expect{ read "\x00\x00\x00\x03\x00\x00\x00\x00" }.to raise_error(XDR::ReadError)
|
16
|
-
end
|
17
|
-
|
18
|
-
def read(str)
|
19
|
-
io = StringIO.new(str)
|
20
|
-
subject.read(io)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe XDR::VarOpaque, "#write" do
|
25
|
-
subject{ XDR::VarOpaque[2] }
|
26
|
-
|
27
|
-
it "encodes values correctly" do
|
28
|
-
expect(write("")).to eq("\x00\x00\x00\x00")
|
29
|
-
expect(write("\x00")).to eq("\x00\x00\x00\x01\x00\x00\x00\x00")
|
30
|
-
expect(write("\x01")).to eq("\x00\x00\x00\x01\x01\x00\x00\x00")
|
31
|
-
expect(write("\x00\x01")).to eq("\x00\x00\x00\x02\x00\x01\x00\x00")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "raises a WriteError when the provided string is too long" do
|
35
|
-
expect{ write "123" }.to raise_error(XDR::WriteError)
|
36
|
-
end
|
37
|
-
|
38
|
-
def write(val)
|
39
|
-
io = StringIO.new()
|
40
|
-
subject.write(val, io)
|
41
|
-
io.string
|
42
|
-
end
|
43
|
-
end
|
data/spec/lib/xdr/void_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
|
4
|
-
describe XDR::Void, ".read" do
|
5
|
-
|
6
|
-
it "decodes values correctly" do
|
7
|
-
expect(read("\x00\x00\x00\x00")).to eq(:void)
|
8
|
-
expect(read("\x00\x00\x00\x01")).to eq(:void)
|
9
|
-
expect(read("\xFF\xFF\xFF\xFF")).to eq(:void)
|
10
|
-
expect(read("\x7F\xFF\xFF\xFF")).to eq(:void)
|
11
|
-
expect(read("\x80\x00\x00\x00")).to eq(:void)
|
12
|
-
end
|
13
|
-
|
14
|
-
def read(str)
|
15
|
-
io = StringIO.new(str)
|
16
|
-
subject.read(io)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe XDR::Void, ".write" do
|
21
|
-
|
22
|
-
it "decodes values correctly" do
|
23
|
-
expect(write :void).to eq("")
|
24
|
-
end
|
25
|
-
|
26
|
-
def write(val)
|
27
|
-
io = StringIO.new()
|
28
|
-
subject.write(val, io)
|
29
|
-
io.string
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe XDR::Void, ".valid?" do
|
34
|
-
|
35
|
-
it "accepts :void" do
|
36
|
-
expect(subject.valid?(:void)).to eq(true)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "rejects anything not :void" do
|
40
|
-
expect(subject.valid?(nil)).to eq(false)
|
41
|
-
expect(subject.valid?(0)).to eq(false)
|
42
|
-
expect(subject.valid?("hello")).to eq(false)
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
Bundler.setup
|
3
|
-
require 'simplecov'
|
4
|
-
SimpleCov.start
|
5
|
-
|
6
|
-
require 'pry'
|
7
|
-
require 'xdr'
|
8
|
-
|
9
|
-
__dir__ = File.dirname(__FILE__)
|
10
|
-
|
11
|
-
Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
|
15
|
-
end
|
data/xdr.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'xdr/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "xdr"
|
8
|
-
spec.version = XDR::VERSION
|
9
|
-
spec.authors = ["Scott Fleckenstein"]
|
10
|
-
spec.email = ["scott@stellar.org"]
|
11
|
-
spec.summary = %q{XDR Helper Library}
|
12
|
-
spec.homepage = "https://github.com/stellar/ruby-xdr"
|
13
|
-
spec.license = "Apache 2.0"
|
14
|
-
spec.required_ruby_version = '>= 2.2.0'
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
spec.add_dependency "activesupport", ">= 4.2.7"
|
21
|
-
spec.add_dependency "activemodel", ">= 4.2.7"
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.1"
|
26
|
-
spec.add_development_dependency "guard-rspec"
|
27
|
-
spec.add_development_dependency "simplecov"
|
28
|
-
end
|