nn-core 0.1.0 → 0.1.5
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.
- data/History.txt +7 -0
- data/lib/nn-core/constants.rb +4 -1
- data/lib/nn-core/libnanomsg.rb +0 -2
- data/lib/nn-core/version.rb +1 -1
- data/spec/nn_bind_spec.rb +1 -6
- data/spec/nn_close_spec.rb +0 -12
- data/spec/nn_connect_spec.rb +1 -6
- data/spec/nn_getsockopt_spec.rb +0 -5
- data/spec/nn_recv_spec.rb +0 -6
- data/spec/nn_send_spec.rb +0 -5
- data/spec/nn_setsockopt_spec.rb +0 -5
- data/spec/nn_shutdown_spec.rb +0 -5
- data/spec/nn_socket_spec.rb +9 -9
- data/spec/nn_version_spec.rb +0 -2
- data/spec/spec_helper.rb +15 -1
- metadata +5 -13
- data/spec/nn_init_spec.rb +0 -11
- data/spec/nn_term_spec.rb +0 -17
data/History.txt
CHANGED
data/lib/nn-core/constants.rb
CHANGED
@@ -32,6 +32,9 @@ module NNCore
|
|
32
32
|
NN_SURVEY_ID = 6
|
33
33
|
NN_SURVEYOR = (NN_SURVEY_ID * 16 + 0)
|
34
34
|
NN_RESPONDENT = (NN_SURVEY_ID * 16 + 1)
|
35
|
+
|
36
|
+
NN_BUS_ID = 7
|
37
|
+
NN_BUS = (NN_BUS_ID * 16 + 0)
|
35
38
|
|
36
39
|
# Socket Option Levels (SOL)
|
37
40
|
NN_SOL_SOCKET = 0
|
@@ -81,5 +84,5 @@ module NNCore
|
|
81
84
|
EFSM = Errno::EFSM::Errno rescue NN_HAUSNUMERO + 54
|
82
85
|
|
83
86
|
# Miscellaneous
|
84
|
-
|
87
|
+
NN_SOCKADDR_MAX = 128
|
85
88
|
end
|
data/lib/nn-core/libnanomsg.rb
CHANGED
@@ -35,8 +35,6 @@ module NNCore
|
|
35
35
|
|
36
36
|
attach_function :nn_version, [:pointer, :pointer, :pointer], :int
|
37
37
|
|
38
|
-
attach_function :nn_init, [], :int
|
39
|
-
attach_function :nn_term, [], :int
|
40
38
|
attach_function :nn_errno, [], :int
|
41
39
|
attach_function :nn_strerror, [:int], :string
|
42
40
|
attach_function :nn_socket, [:int, :int], :int
|
data/lib/nn-core/version.rb
CHANGED
data/spec/nn_bind_spec.rb
CHANGED
@@ -4,19 +4,14 @@ module NNCore
|
|
4
4
|
describe "nn_bind" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
7
|
|
11
8
|
context "given a valid socket" do
|
12
9
|
before(:each) do
|
13
|
-
LibNanomsg.nn_init
|
14
10
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
|
15
11
|
end
|
16
12
|
|
17
13
|
after(:each) do
|
18
14
|
LibNanomsg.nn_close(@socket)
|
19
|
-
LibNanomsg.nn_term
|
20
15
|
end
|
21
16
|
|
22
17
|
it "returns a non-zero endpoint number for a valid INPROC address" do
|
@@ -41,7 +36,7 @@ module NNCore
|
|
41
36
|
end
|
42
37
|
|
43
38
|
it "returns -1 for an invalid INPROC address (too long)" do
|
44
|
-
rc = LibNanomsg.nn_bind(@socket, "inproc://#{'a' * (
|
39
|
+
rc = LibNanomsg.nn_bind(@socket, "inproc://#{'a' * (NN_SOCKADDR_MAX + 1)}")
|
45
40
|
rc.should == -1
|
46
41
|
LibNanomsg.nn_errno.should == ENAMETOOLONG
|
47
42
|
end
|
data/spec/nn_close_spec.rb
CHANGED
@@ -3,19 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module NNCore
|
4
4
|
describe "nn_close" do
|
5
5
|
|
6
|
-
context "given an unitialized library" do
|
7
|
-
before(:each) { LibNanomsg.nn_term }
|
8
|
-
|
9
|
-
it "returns -1 and sets nn_errno to EFAULT" do
|
10
|
-
LibNanomsg.nn_close(0).should == -1
|
11
|
-
LibNanomsg.nn_errno.should == EFAULT
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
6
|
context "given an initialized library and" do
|
17
|
-
before(:each) { LibNanomsg.nn_init }
|
18
|
-
after(:each) { LibNanomsg.nn_term }
|
19
7
|
|
20
8
|
context "given a valid socket" do
|
21
9
|
before(:each) { @socket = LibNanomsg.nn_socket(AF_SP, NN_PUB) }
|
data/spec/nn_connect_spec.rb
CHANGED
@@ -10,19 +10,14 @@ module NNCore
|
|
10
10
|
describe "nn_connect" do
|
11
11
|
|
12
12
|
context "given an initialized library and" do
|
13
|
-
before(:each) { LibNanomsg.nn_init }
|
14
|
-
after(:each) { LibNanomsg.nn_term }
|
15
|
-
|
16
13
|
|
17
14
|
context "given a valid socket" do
|
18
15
|
before(:each) do
|
19
|
-
LibNanomsg.nn_init
|
20
16
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
|
21
17
|
end
|
22
18
|
|
23
19
|
after(:each) do
|
24
20
|
LibNanomsg.nn_close(@socket)
|
25
|
-
LibNanomsg.nn_term
|
26
21
|
end
|
27
22
|
|
28
23
|
it "returns a non-zero endpoint number for a valid INPROC address" do
|
@@ -47,7 +42,7 @@ module NNCore
|
|
47
42
|
end
|
48
43
|
|
49
44
|
it "returns -1 for an invalid INPROC address (too long)" do
|
50
|
-
rc = LibNanomsg.nn_connect(@socket, "inproc://#{'a' * (
|
45
|
+
rc = LibNanomsg.nn_connect(@socket, "inproc://#{'a' * (NN_SOCKADDR_MAX + 1)}")
|
51
46
|
rc.should == -1
|
52
47
|
LibNanomsg.nn_errno.should == ENAMETOOLONG
|
53
48
|
end
|
data/spec/nn_getsockopt_spec.rb
CHANGED
@@ -4,13 +4,9 @@ module NNCore
|
|
4
4
|
describe "nn_getsockopt" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
7
|
|
11
8
|
context "given a valid socket" do
|
12
9
|
before(:each) do
|
13
|
-
LibNanomsg.nn_init
|
14
10
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
|
15
11
|
@option = FFI::MemoryPointer.new(:int32)
|
16
12
|
@size = FFI::MemoryPointer.new :size_t
|
@@ -19,7 +15,6 @@ module NNCore
|
|
19
15
|
|
20
16
|
after(:each) do
|
21
17
|
LibNanomsg.nn_close(@socket)
|
22
|
-
LibNanomsg.nn_term
|
23
18
|
end
|
24
19
|
|
25
20
|
it "NN_LINGER returns a default of 1000" do
|
data/spec/nn_recv_spec.rb
CHANGED
@@ -4,13 +4,9 @@ module NNCore
|
|
4
4
|
describe "nn_recv" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
7
|
|
11
8
|
context "given a valid connected sender and receiver socket pair" do
|
12
9
|
before(:each) do
|
13
|
-
LibNanomsg.nn_init
|
14
10
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PAIR)
|
15
11
|
@sender = LibNanomsg.nn_socket(AF_SP, NN_PAIR)
|
16
12
|
@endpoint = LibNanomsg.nn_bind(@socket, "inproc://some_endpoint")
|
@@ -20,7 +16,6 @@ module NNCore
|
|
20
16
|
after(:each) do
|
21
17
|
LibNanomsg.nn_close(@socket)
|
22
18
|
LibNanomsg.nn_close(@sender)
|
23
|
-
LibNanomsg.nn_term
|
24
19
|
end
|
25
20
|
|
26
21
|
context "given a pre-allocated buffer" do
|
@@ -37,7 +32,6 @@ module NNCore
|
|
37
32
|
end
|
38
33
|
|
39
34
|
context "given no pre-allocated buffer" do
|
40
|
-
|
41
35
|
|
42
36
|
it "returns the number of bytes received and returns the buffer" do
|
43
37
|
string = "ABC"
|
data/spec/nn_send_spec.rb
CHANGED
@@ -4,19 +4,14 @@ module NNCore
|
|
4
4
|
describe "nn_send" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
7
|
|
11
8
|
context "given a valid socket" do
|
12
9
|
before(:each) do
|
13
|
-
LibNanomsg.nn_init
|
14
10
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
|
15
11
|
end
|
16
12
|
|
17
13
|
after(:each) do
|
18
14
|
LibNanomsg.nn_close(@socket)
|
19
|
-
LibNanomsg.nn_term
|
20
15
|
end
|
21
16
|
|
22
17
|
context "given a valid endpoint" do
|
data/spec/nn_setsockopt_spec.rb
CHANGED
@@ -4,13 +4,9 @@ module NNCore
|
|
4
4
|
describe "nn_setsockopt" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
7
|
|
11
8
|
context "given a valid socket" do
|
12
9
|
before(:each) do
|
13
|
-
LibNanomsg.nn_init
|
14
10
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
|
15
11
|
@option = FFI::MemoryPointer.new(:int32)
|
16
12
|
@size = FFI::MemoryPointer.new :size_t
|
@@ -19,7 +15,6 @@ module NNCore
|
|
19
15
|
|
20
16
|
after(:each) do
|
21
17
|
LibNanomsg.nn_close(@socket)
|
22
|
-
LibNanomsg.nn_term
|
23
18
|
end
|
24
19
|
|
25
20
|
SOCKET_OPTIONS.keys.each do |socket_option|
|
data/spec/nn_shutdown_spec.rb
CHANGED
@@ -4,19 +4,14 @@ module NNCore
|
|
4
4
|
describe "nn_shutdown" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
7
|
|
11
8
|
context "given a valid socket and" do
|
12
9
|
before(:each) do
|
13
|
-
LibNanomsg.nn_init
|
14
10
|
@socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
|
15
11
|
end
|
16
12
|
|
17
13
|
after(:each) do
|
18
14
|
LibNanomsg.nn_close(@socket)
|
19
|
-
LibNanomsg.nn_term
|
20
15
|
end
|
21
16
|
|
22
17
|
context "given a valid endpoint" do
|
data/spec/nn_socket_spec.rb
CHANGED
@@ -4,8 +4,6 @@ module NNCore
|
|
4
4
|
describe "nn_socket" do
|
5
5
|
|
6
6
|
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
7
|
|
10
8
|
PROTOCOLS.keys.each do |protocol|
|
11
9
|
|
@@ -13,20 +11,22 @@ module NNCore
|
|
13
11
|
|
14
12
|
it "returns a non-zero file descriptor for the socket" do
|
15
13
|
@socket = LibNanomsg.nn_socket(AF_SP, PROTOCOLS[protocol])
|
16
|
-
|
14
|
+
|
17
15
|
@socket.should == 0
|
18
|
-
|
16
|
+
|
19
17
|
LibNanomsg.nn_close(@socket)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
21
|
context "given a supported protocol #{protocol} and address family AF_SP_RAW" do
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
if RAW_UNSUPPORTED.include?(protocol)
|
24
|
+
it "returns -1 and sets nn_errno to EINVAL" do
|
25
|
+
@socket = LibNanomsg.nn_socket(AF_SP_RAW, PROTOCOLS[protocol])
|
26
|
+
|
27
|
+
@socket.should == -1
|
28
|
+
LibNanomsg.nn_errno.should == EINVAL
|
29
|
+
end
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/spec/nn_version_spec.rb
CHANGED
@@ -4,8 +4,6 @@ module NNCore
|
|
4
4
|
describe "nn_bind" do
|
5
5
|
|
6
6
|
context "given an initialized library" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
7
|
|
10
8
|
it "returns 0 and populates the pointers with the major, minor and patch version numbers" do
|
11
9
|
major = FFI::MemoryPointer.new(:int)
|
data/spec/spec_helper.rb
CHANGED
@@ -15,11 +15,25 @@ module NNCore
|
|
15
15
|
|
16
16
|
PROTOCOLS = {
|
17
17
|
:NN_PUB => NN_PUB,
|
18
|
-
:NN_SUB => NN_SUB
|
18
|
+
:NN_SUB => NN_SUB,
|
19
|
+
:NN_BUS => NN_BUS,
|
20
|
+
:NN_PAIR => NN_PAIR,
|
21
|
+
:NN_REQ => NN_REQ,
|
22
|
+
:NN_REP => NN_REP,
|
23
|
+
:NN_SOURCE => NN_SOURCE,
|
24
|
+
:NN_SINK => NN_SINK,
|
25
|
+
:NN_PUSH => NN_PUSH,
|
26
|
+
:NN_PULL => NN_PULL,
|
27
|
+
:NN_SURVEYOR => NN_SURVEYOR,
|
28
|
+
:NN_RESPONDENT => NN_RESPONDENT
|
19
29
|
}
|
20
30
|
|
21
31
|
ADDRESS_FAMILIES = {
|
22
32
|
:AF_SP => AF_SP,
|
23
33
|
:AF_SP_RAW => AF_SP_RAW
|
24
34
|
}
|
35
|
+
|
36
|
+
# Some protocols support the AF_SP_RAW address family, so we need to skip those
|
37
|
+
# tests that are expecting a failure.
|
38
|
+
RAW_UNSUPPORTED = [:NN_PUB, :NN_SUB]
|
25
39
|
end
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: nn-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chuck Remes
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
prerelease: false
|
@@ -19,6 +19,7 @@ dependencies:
|
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
none: false
|
22
|
+
type: :runtime
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - ! '>='
|
@@ -26,7 +27,6 @@ dependencies:
|
|
26
27
|
version: '0'
|
27
28
|
none: false
|
28
29
|
name: ffi
|
29
|
-
type: :runtime
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
prerelease: false
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -35,6 +35,7 @@ dependencies:
|
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '2.6'
|
37
37
|
none: false
|
38
|
+
type: :development
|
38
39
|
version_requirements: !ruby/object:Gem::Requirement
|
39
40
|
requirements:
|
40
41
|
- - ~>
|
@@ -42,7 +43,6 @@ dependencies:
|
|
42
43
|
version: '2.6'
|
43
44
|
none: false
|
44
45
|
name: rspec
|
45
|
-
type: :development
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
prerelease: false
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,6 +51,7 @@ dependencies:
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
none: false
|
54
|
+
type: :development
|
54
55
|
version_requirements: !ruby/object:Gem::Requirement
|
55
56
|
requirements:
|
56
57
|
- - ! '>='
|
@@ -58,7 +59,6 @@ dependencies:
|
|
58
59
|
version: '0'
|
59
60
|
none: false
|
60
61
|
name: rake
|
61
|
-
type: :development
|
62
62
|
description: ! 'Wraps the nanomsg networking library using the ruby FFI (foreign
|
63
63
|
|
64
64
|
function interface). It only exposes the native C API to Ruby. Other gems should
|
@@ -105,8 +105,6 @@ files:
|
|
105
105
|
c3BlYy9ubl9jb25uZWN0X3NwZWMucmI=
|
106
106
|
- !binary |-
|
107
107
|
c3BlYy9ubl9nZXRzb2Nrb3B0X3NwZWMucmI=
|
108
|
-
- !binary |-
|
109
|
-
c3BlYy9ubl9pbml0X3NwZWMucmI=
|
110
108
|
- !binary |-
|
111
109
|
c3BlYy9ubl9yZWN2X3NwZWMucmI=
|
112
110
|
- !binary |-
|
@@ -117,8 +115,6 @@ files:
|
|
117
115
|
c3BlYy9ubl9zaHV0ZG93bl9zcGVjLnJi
|
118
116
|
- !binary |-
|
119
117
|
c3BlYy9ubl9zb2NrZXRfc3BlYy5yYg==
|
120
|
-
- !binary |-
|
121
|
-
c3BlYy9ubl90ZXJtX3NwZWMucmI=
|
122
118
|
- !binary |-
|
123
119
|
c3BlYy9ubl92ZXJzaW9uX3NwZWMucmI=
|
124
120
|
- !binary |-
|
@@ -156,8 +152,6 @@ test_files:
|
|
156
152
|
c3BlYy9ubl9jb25uZWN0X3NwZWMucmI=
|
157
153
|
- !binary |-
|
158
154
|
c3BlYy9ubl9nZXRzb2Nrb3B0X3NwZWMucmI=
|
159
|
-
- !binary |-
|
160
|
-
c3BlYy9ubl9pbml0X3NwZWMucmI=
|
161
155
|
- !binary |-
|
162
156
|
c3BlYy9ubl9yZWN2X3NwZWMucmI=
|
163
157
|
- !binary |-
|
@@ -168,8 +162,6 @@ test_files:
|
|
168
162
|
c3BlYy9ubl9zaHV0ZG93bl9zcGVjLnJi
|
169
163
|
- !binary |-
|
170
164
|
c3BlYy9ubl9zb2NrZXRfc3BlYy5yYg==
|
171
|
-
- !binary |-
|
172
|
-
c3BlYy9ubl90ZXJtX3NwZWMucmI=
|
173
165
|
- !binary |-
|
174
166
|
c3BlYy9ubl92ZXJzaW9uX3NwZWMucmI=
|
175
167
|
- !binary |-
|
data/spec/nn_init_spec.rb
DELETED
data/spec/nn_term_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module NNCore
|
4
|
-
describe "nn_term" do
|
5
|
-
|
6
|
-
context "given an initialized library and" do
|
7
|
-
before(:each) { LibNanomsg.nn_init }
|
8
|
-
after(:each) { LibNanomsg.nn_term }
|
9
|
-
|
10
|
-
it "returns 0 for successful library termination" do
|
11
|
-
LibNanomsg.nn_term.should be_zero
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|