nn-core 0.1.6 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aec634c40b00d3f8dc8301ee40777c9943d069d6
4
+ data.tar.gz: 23b6f3ea3d5327711e0f1ba2ec971f9f904d4d2f
5
+ SHA512:
6
+ metadata.gz: 171ba1be554febe2101e3253094c722e9124f1da03b870427a7e062b470ab1f9eb955f22e0387e1081bb9ef9ef7fed402321de1172b068213276455a40d753ea
7
+ data.tar.gz: 7e969d818f3044048f9721250cb15a9cc5c1682cefbea62e322f7e3f31b2f04bbc3192611a475aec0b0390c95c4bc7c67e3e21ac3117006fb7d3bc24dd62af77
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ 20130327 / 0.2.0
2
+ * Support nn_symbol function for setting up all constants in the binding.
3
+
4
+ * Remove support for nn_version function.
5
+
6
+ * Change #attach_function calls to use options hash for :blocking => true.
7
+ This is cleaner and less noisy than all of the "@blocking = true" lines
8
+ before the #attach_function call.
9
+
1
10
  20130220 / 0.1.6
2
11
  * Several fixes for tcp string handling have made it to nanomsg trunk,
3
12
  so I can now re-enable those specs.
@@ -1,88 +1,26 @@
1
1
  module NNCore
2
- NN_HAUSNUMERO = 156384712
3
2
 
4
- # SP address families
5
- AF_SP = 1
6
- AF_SP_RAW = 2
7
-
8
- # Transport types
9
- NN_INPROC = -1
10
- NN_IPC = -2
11
- NN_TCP = -3
12
-
13
- # Protocols
14
- NN_PAIR_ID = 1
15
- NN_PAIR = (NN_PAIR_ID * 16 + 0)
16
-
17
- NN_PUBSUB_ID = 2
18
- NN_PUB = (NN_PUBSUB_ID * 16 + 0)
19
- NN_SUB = (NN_PUBSUB_ID * 16 + 1)
20
-
21
- NN_REQREP_ID = 3
22
- NN_REQ = (NN_REQREP_ID * 16 + 0)
23
- NN_REP = (NN_REQREP_ID * 16 + 1)
24
-
25
- NN_FANIN_ID = 4
26
- NN_SOURCE = (NN_FANIN_ID * 16 + 0)
27
- NN_SINK = (NN_FANIN_ID * 16 + 1)
28
- NN_FANOUT_ID = 5
29
- NN_PUSH = (NN_FANOUT_ID * 16 + 0)
30
- NN_PULL = (NN_FANOUT_ID * 16 + 1)
31
-
32
- NN_SURVEY_ID = 6
33
- NN_SURVEYOR = (NN_SURVEY_ID * 16 + 0)
34
- NN_RESPONDENT = (NN_SURVEY_ID * 16 + 1)
3
+ # To simplify management of constants in language bindings that cannot
4
+ # parse or directly utilize a C header file, the library provides the
5
+ # nn_symbol function. This function returns a string and an integer
6
+ # value so that bindings authors can easily setup all constants and
7
+ # their values without worrying about copy/paste or transcription
8
+ # errors every time the underlying library is changed.
9
+ #
10
+ # For documentation on all possible constants, please refer to the
11
+ # man pages at nanomsg.org
12
+ #
13
+ index = 0
14
+ while true
15
+ value = FFI::MemoryPointer.new(:int)
16
+
17
+ constant_string = LibNanomsg.nn_symbol(index, value)
18
+ break if constant_string.nil?
19
+
20
+ const_set(constant_string, value.read_int)
21
+ index += 1
22
+ end
35
23
 
36
- NN_BUS_ID = 7
37
- NN_BUS = (NN_BUS_ID * 16 + 0)
38
-
39
- # Socket Option Levels (SOL)
40
- NN_SOL_SOCKET = 0
41
-
42
- # Socket options
43
- NN_LINGER = 1
44
- NN_SNDBUF = 2
45
- NN_RCVBUF = 3
46
- NN_SNDTIMEO = 4
47
- NN_RCVTIMEO = 5
48
- NN_RECONNECT_IVL = 6
49
- NN_RECONNECT_IVL_MAX = 7
50
- NN_SNDPRIO = 8
51
- #NN_SNDFD = 10
52
- #NN_RCVFD = 11
53
-
54
- # Send/recv options
55
- NN_DONTWAIT = 1
24
+ # This constant is not exported by nn_symbol. It is also of type size_t.
56
25
  NN_MSG = -1
57
-
58
- # Socket errors
59
- ENOTSUP = Errno::ENOTSUP::Errno rescue NN_HAUSNUMERO + 1
60
- EPROTONOSUPPORT = Errno::EPROTONOSUPPORT::Errno rescue NN_HAUSNUMERO + 2
61
- ENOBUFS = Errno::ENOBUFS::Errno rescue NN_HAUSNUMERO + 3
62
- ENETDOWN = Errno::ENETDOWN::Errnow rescue NN_HAUSNUMERO + 4
63
- EADDRINUSE = Errno::EADDRINUSE::Errno rescue NN_HAUSNUMERO + 5
64
- EADDRNOTAVAIL = Errno::EADDRNOTAVAIL::Errno rescue NN_HAUSNUMERO + 6
65
- ECONNREFUSED = Errno::ECONNREFUSED::Errno rescue NN_HAUSNUMERO + 7
66
- EINPROGRESS = Errno::EINPROGRESS::Errno rescue NN_HAUSNUMERO + 8
67
- ENOTSOCK = Errno::ENOTSOCK::Errno rescue NN_HAUSNUMERO + 9
68
- EAFNOSUPPORT = Errno::EAFNOSUPPORT::Errno rescue NN_HAUSNUMERO + 10
69
- EPROTO = Errno::EPROTO::Errno rescue NN_HAUSNUMERO + 11
70
-
71
- ETIMEDOUT = Errno::ETIMEDOUT::Errno
72
- EAGAIN = Errno::EAGAIN::Errno
73
- EINVAL = Errno::EINVAL::Errno
74
- ENOMEM = Errno::ENOMEM::Errno
75
- ENODEV = Errno::ENODEV::Errno
76
- EFAULT = Errno::EFAULT::Errno
77
- # EINTR = Errno::EINTR::Errno
78
- EBADF = Errno::EBADF::Errno
79
- ENOPROTOOPT = Errno::ENOPROTOOPT::Errno
80
- ENAMETOOLONG = Errno::ENAMETOOLONG::Errno
81
-
82
- # Library errors
83
- ETERM = Errno::ETERM::Errno rescue NN_HAUSNUMERO + 53
84
- EFSM = Errno::EFSM::Errno rescue NN_HAUSNUMERO + 54
85
-
86
- # Miscellaneous
87
- NN_SOCKADDR_MAX = 128
88
26
  end
@@ -33,41 +33,26 @@ module NNCore
33
33
  # Size_t not working properly on Windows
34
34
  find_type(:size_t) rescue typedef(:ulong, :size_t)
35
35
 
36
- @blocking = true
37
- attach_function :nn_version, [:pointer, :pointer, :pointer], :int
36
+ attach_function :nn_symbol, [:int, :pointer], :string, :blocking => true
38
37
 
39
- @blocking = true
40
- attach_function :nn_errno, [], :int
41
- @blocking = true
42
- attach_function :nn_strerror, [:int], :string
43
- @blocking = true
44
- attach_function :nn_socket, [:int, :int], :int
45
- @blocking = true
46
- attach_function :nn_close, [:int], :int
38
+ attach_function :nn_errno, [], :int, :blocking => true
39
+ attach_function :nn_strerror, [:int], :string, :blocking => true
40
+ attach_function :nn_socket, [:int, :int], :int, :blocking => true
41
+ attach_function :nn_close, [:int], :int, :blocking => true
47
42
 
48
- @blocking = true
49
- attach_function :nn_getsockopt, [:int, :int, :int, :pointer, :pointer], :int
50
- @blocking = true
51
- attach_function :nn_setsockopt, [:int, :int, :int, :pointer, :size_t], :int
52
- @blocking = true
53
- attach_function :nn_bind, [:int, :string], :int
54
- @blocking = true
55
- attach_function :nn_connect, [:int, :string], :int
56
- @blocking = true
57
- attach_function :nn_shutdown, [:int, :int], :int
58
- @blocking = true
59
- attach_function :nn_send, [:int, :pointer, :size_t, :int], :int
60
- @blocking = true
61
- attach_function :nn_recv, [:int, :pointer, :size_t, :int], :int
43
+ attach_function :nn_getsockopt, [:int, :int, :int, :pointer, :pointer], :int, :blocking => true
44
+ attach_function :nn_setsockopt, [:int, :int, :int, :pointer, :size_t], :int, :blocking => true
45
+ attach_function :nn_bind, [:int, :string], :int, :blocking => true
46
+ attach_function :nn_connect, [:int, :string], :int, :blocking => true
47
+ attach_function :nn_shutdown, [:int, :int], :int, :blocking => true
48
+ attach_function :nn_send, [:int, :pointer, :size_t, :int], :int, :blocking => true
49
+ attach_function :nn_recv, [:int, :pointer, :size_t, :int], :int, :blocking => true
50
+ attach_function :nn_term, [], :void, :blocking => true
62
51
 
63
52
  # functions for working with raw buffers
64
- @blocking = true
65
- attach_function :nn_sendmsg, [:int, :pointer, :int], :int
66
- @blocking = true
67
- attach_function :nn_recvmsg, [:int, :pointer, :int], :int
68
- @blocking = true
69
- attach_function :nn_allocmsg, [:size_t, :int], :pointer
70
- @blocking = true
71
- attach_function :nn_freemsg, [:pointer], :int
53
+ attach_function :nn_sendmsg, [:int, :pointer, :int], :int, :blocking => true
54
+ attach_function :nn_recvmsg, [:int, :pointer, :int], :int, :blocking => true
55
+ attach_function :nn_allocmsg, [:size_t, :int], :pointer, :blocking => true
56
+ attach_function :nn_freemsg, [:pointer], :int, :blocking => true
72
57
  end
73
58
  end
@@ -1,3 +1,3 @@
1
1
  module NNCore
2
- VERSION = "0.1.6"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ module NNCore
4
+ describe "nn_symbol" do
5
+
6
+ context "given an initialized library" do
7
+
8
+ it "returns a string constant given an index of 0" do
9
+ value = FFI::MemoryPointer.new(:int)
10
+
11
+ constant_string = LibNanomsg.nn_symbol(0, value)
12
+ constant_string.should be_a(String)
13
+ end
14
+
15
+ it "returns an integer value in the second parameter given an index of 0" do
16
+ value = FFI::MemoryPointer.new(:int)
17
+
18
+ constant_string = LibNanomsg.nn_symbol(0, value)
19
+ value.read_int.should >= 0
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ module NNCore
4
+ describe "nn_term" do
5
+
6
+ context "given an initialized library and" do
7
+
8
+ context "given a valid socket" do
9
+ before(:each) do
10
+ @socket = LibNanomsg.nn_socket(AF_SP, NN_PUB)
11
+ end
12
+
13
+ after(:each) do
14
+ LibNanomsg.nn_close(@socket)
15
+ end
16
+
17
+ it "makes subsequent calls to nn_send fail with ETERM" do
18
+ LibNanomsg.nn_term
19
+ rc = LibNanomsg.nn_send(0, "ABC", 3, 0)
20
+ rc.should == -1
21
+ LibNanomsg.nn_errno.should == ETERM
22
+ end
23
+
24
+ # it "makes subsequent calls to nn_recv fail with ETERM" do
25
+ # LibNanomsg.nn_term
26
+ # buffer = FFI::MemoryPointer.new(:pointer)
27
+ # rc = LibNanomsg.nn_recv(@socket, buffer, NN_MSG, 0)
28
+ # rc.should == -1
29
+ # LibNanomsg.nn_errno.should == ETERM
30
+ # end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
data/spec/spec_helper.rb CHANGED
@@ -20,8 +20,6 @@ module NNCore
20
20
  :NN_PAIR => NN_PAIR,
21
21
  :NN_REQ => NN_REQ,
22
22
  :NN_REP => NN_REP,
23
- :NN_SOURCE => NN_SOURCE,
24
- :NN_SINK => NN_SINK,
25
23
  :NN_PUSH => NN_PUSH,
26
24
  :NN_PULL => NN_PULL,
27
25
  :NN_SURVEYOR => NN_SURVEYOR,
@@ -35,5 +33,5 @@ module NNCore
35
33
 
36
34
  # Some protocols support the AF_SP_RAW address family, so we need to skip those
37
35
  # tests that are expecting a failure.
38
- RAW_UNSUPPORTED = [:NN_PUB, :NN_SUB]
36
+ RAW_UNSUPPORTED = []
39
37
  end
metadata CHANGED
@@ -1,170 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nn-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chuck Remes
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- none: false
21
20
  type: :runtime
22
- name: ffi
23
21
  prerelease: false
24
- requirement: !ruby/object:Gem::Requirement
22
+ version_requirements: !ruby/object:Gem::Requirement
25
23
  requirements:
26
- - - ! '>='
24
+ - - ">="
27
25
  - !ruby/object:Gem::Version
28
26
  version: '0'
29
- none: false
30
27
  - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
32
30
  requirements:
33
- - - ~>
31
+ - - "~>"
34
32
  - !ruby/object:Gem::Version
35
33
  version: '2.6'
36
- none: false
37
34
  type: :development
38
- name: rspec
39
35
  prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
36
+ version_requirements: !ruby/object:Gem::Requirement
41
37
  requirements:
42
- - - ~>
38
+ - - "~>"
43
39
  - !ruby/object:Gem::Version
44
40
  version: '2.6'
45
- none: false
46
41
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
48
44
  requirements:
49
- - - ! '>='
45
+ - - ">="
50
46
  - !ruby/object:Gem::Version
51
47
  version: '0'
52
- none: false
53
48
  type: :development
54
- name: rake
55
49
  prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
50
+ version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - ! '>='
52
+ - - ">="
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0'
61
- none: false
62
- description: ! 'Wraps the nanomsg networking library using the ruby FFI (foreign
63
-
64
- function interface). It only exposes the native C API to Ruby. Other gems should
65
- use this gem
66
-
67
- to build an API using Ruby idioms.'
55
+ description: |-
56
+ Wraps the nanomsg networking library using the ruby FFI (foreign
57
+ function interface). It only exposes the native C API to Ruby. Other gems should use this gem
58
+ to build an API using Ruby idioms.
68
59
  email:
69
60
  - git@chuckremes.com
70
61
  executables: []
71
62
  extensions: []
72
63
  extra_rdoc_files: []
73
64
  files:
74
- - !binary |-
75
- LmdpdGlnbm9yZQ==
76
- - !binary |-
77
- LnJzcGVj
78
- - !binary |-
79
- QXV0aG9ycy50eHQ=
80
- - !binary |-
81
- R2VtZmlsZQ==
82
- - !binary |-
83
- SGlzdG9yeS50eHQ=
84
- - !binary |-
85
- UkVBRE1FLm1k
86
- - !binary |-
87
- UmFrZWZpbGU=
88
- - !binary |-
89
- ZXhhbXBsZXMvcm91bmR0cmlwX2xhdGVuY3kucmI=
90
- - !binary |-
91
- bGliL25uLWNvcmUucmI=
92
- - !binary |-
93
- bGliL25uLWNvcmUvY29uc3RhbnRzLnJi
94
- - !binary |-
95
- bGliL25uLWNvcmUvbGlibmFub21zZy5yYg==
96
- - !binary |-
97
- bGliL25uLWNvcmUvc3RydWN0cy5yYg==
98
- - !binary |-
99
- bGliL25uLWNvcmUvdmVyc2lvbi5yYg==
100
- - !binary |-
101
- bm4tY29yZS5nZW1zcGVj
102
- - !binary |-
103
- c3BlYy9ubl9iaW5kX3NwZWMucmI=
104
- - !binary |-
105
- c3BlYy9ubl9jbG9zZV9zcGVjLnJi
106
- - !binary |-
107
- c3BlYy9ubl9jb25uZWN0X3NwZWMucmI=
108
- - !binary |-
109
- c3BlYy9ubl9nZXRzb2Nrb3B0X3NwZWMucmI=
110
- - !binary |-
111
- c3BlYy9ubl9yZWN2X3NwZWMucmI=
112
- - !binary |-
113
- c3BlYy9ubl9zZW5kX3NwZWMucmI=
114
- - !binary |-
115
- c3BlYy9ubl9zZXRzb2Nrb3B0X3NwZWMucmI=
116
- - !binary |-
117
- c3BlYy9ubl9zaHV0ZG93bl9zcGVjLnJi
118
- - !binary |-
119
- c3BlYy9ubl9zb2NrZXRfc3BlYy5yYg==
120
- - !binary |-
121
- c3BlYy9ubl92ZXJzaW9uX3NwZWMucmI=
122
- - !binary |-
123
- c3BlYy9zcGVjX2hlbHBlci5yYg==
65
+ - ".gitignore"
66
+ - ".rspec"
67
+ - Authors.txt
68
+ - Gemfile
69
+ - History.txt
70
+ - README.md
71
+ - Rakefile
72
+ - examples/roundtrip_latency.rb
73
+ - lib/nn-core.rb
74
+ - lib/nn-core/constants.rb
75
+ - lib/nn-core/libnanomsg.rb
76
+ - lib/nn-core/structs.rb
77
+ - lib/nn-core/version.rb
78
+ - nn-core.gemspec
79
+ - spec/nn_bind_spec.rb
80
+ - spec/nn_close_spec.rb
81
+ - spec/nn_connect_spec.rb
82
+ - spec/nn_getsockopt_spec.rb
83
+ - spec/nn_recv_spec.rb
84
+ - spec/nn_send_spec.rb
85
+ - spec/nn_setsockopt_spec.rb
86
+ - spec/nn_shutdown_spec.rb
87
+ - spec/nn_socket_spec.rb
88
+ - spec/nn_symbol_spec.rb
89
+ - spec/nn_term_spec.rb
90
+ - spec/spec_helper.rb
124
91
  homepage: http://github.com/chuckremes/nn-core
125
92
  licenses: []
93
+ metadata: {}
126
94
  post_install_message:
127
95
  rdoc_options: []
128
96
  require_paths:
129
97
  - lib
130
98
  required_ruby_version: !ruby/object:Gem::Requirement
131
99
  requirements:
132
- - - ! '>='
100
+ - - ">="
133
101
  - !ruby/object:Gem::Version
134
102
  version: '0'
135
- none: false
136
103
  required_rubygems_version: !ruby/object:Gem::Requirement
137
104
  requirements:
138
- - - ! '>='
105
+ - - ">="
139
106
  - !ruby/object:Gem::Version
140
107
  version: '0'
141
- none: false
142
108
  requirements: []
143
109
  rubyforge_project: nn-core
144
- rubygems_version: 1.8.24
110
+ rubygems_version: 2.2.0
145
111
  signing_key:
146
- specification_version: 3
112
+ specification_version: 4
147
113
  summary: Wraps the nanomsg networking library using Ruby FFI (foreign function interface).
148
114
  test_files:
149
- - !binary |-
150
- c3BlYy9ubl9iaW5kX3NwZWMucmI=
151
- - !binary |-
152
- c3BlYy9ubl9jbG9zZV9zcGVjLnJi
153
- - !binary |-
154
- c3BlYy9ubl9jb25uZWN0X3NwZWMucmI=
155
- - !binary |-
156
- c3BlYy9ubl9nZXRzb2Nrb3B0X3NwZWMucmI=
157
- - !binary |-
158
- c3BlYy9ubl9yZWN2X3NwZWMucmI=
159
- - !binary |-
160
- c3BlYy9ubl9zZW5kX3NwZWMucmI=
161
- - !binary |-
162
- c3BlYy9ubl9zZXRzb2Nrb3B0X3NwZWMucmI=
163
- - !binary |-
164
- c3BlYy9ubl9zaHV0ZG93bl9zcGVjLnJi
165
- - !binary |-
166
- c3BlYy9ubl9zb2NrZXRfc3BlYy5yYg==
167
- - !binary |-
168
- c3BlYy9ubl92ZXJzaW9uX3NwZWMucmI=
169
- - !binary |-
170
- c3BlYy9zcGVjX2hlbHBlci5yYg==
115
+ - spec/nn_bind_spec.rb
116
+ - spec/nn_close_spec.rb
117
+ - spec/nn_connect_spec.rb
118
+ - spec/nn_getsockopt_spec.rb
119
+ - spec/nn_recv_spec.rb
120
+ - spec/nn_send_spec.rb
121
+ - spec/nn_setsockopt_spec.rb
122
+ - spec/nn_shutdown_spec.rb
123
+ - spec/nn_socket_spec.rb
124
+ - spec/nn_symbol_spec.rb
125
+ - spec/nn_term_spec.rb
126
+ - spec/spec_helper.rb
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module NNCore
4
- describe "nn_version" do
5
-
6
- context "given an initialized library" do
7
-
8
- it "returns 0 and populates the pointers with the major, minor and patch version numbers" do
9
- major = FFI::MemoryPointer.new(:int)
10
- minor = FFI::MemoryPointer.new(:int)
11
- patch = FFI::MemoryPointer.new(:int)
12
-
13
- # there is no return value for this function
14
- LibNanomsg.nn_version(major, minor, patch)
15
-
16
- major.read_int.should >= 0
17
- minor.read_int.should >= 0
18
- patch.read_int.should >= 0
19
- end
20
-
21
- end
22
- end
23
- end