ffi-rzmq-core 1.0.0 → 1.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
  SHA1:
3
- metadata.gz: d251cf90787964d1767307c511f830c983dd47c0
4
- data.tar.gz: dbc73d731823c0f445d56b3a06250e4bdea8d2cc
3
+ metadata.gz: 65eb637703a1d78ee4d04307a8abee14f7ef4f33
4
+ data.tar.gz: 75103d5374eab92e290d2f4d9b62327446749570
5
5
  SHA512:
6
- metadata.gz: 4a0b12abbb518be94ce38b80a65c3c494f76d7e527cbcb4e93ad801e066ef2d6553c5a0ed44c73aed998626d497e5d9e96f01fd0399407f5186bc100604f58d9
7
- data.tar.gz: da40bae1ff70d829ec8b4f8bea9628417e3210138e83aa89f6e4d58fe5209103af8126ab48a2718f9b01416dc0fdcc268718e0c9e323bfd8a6213edc752739b9
6
+ metadata.gz: 1059be1ce0a593b54a70d149f8b9d7cf08ef28b3255612b4e6661ca3bf7b5fc283f14ac83c4b90640dd74777c6d95ee4c8c6c3f5c53f5841dfbfb1ab490c231d
7
+ data.tar.gz: 7d69ae0b651d109c17fa865934302161e63f246a3fb39e2c73b526d4db5eb2b35079163f14ba17b0b25b3dc134932fe430b893fb73a8af012c3ca7f7aa950cb7
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
@@ -8,8 +8,8 @@ module LibC
8
8
  find_type(:size_t) rescue typedef(:ulong, :size_t)
9
9
 
10
10
  # memory allocators
11
- attach_function :malloc, [:size_t], :pointer
12
- attach_function :free, [:pointer], :void
11
+ attach_function :malloc, [:size_t], :pointer
12
+ attach_function :free, [:pointer], :void
13
13
 
14
14
  # get a pointer to the free function; used for ZMQ::Message deallocation
15
15
  Free = library.find_symbol('free')
@@ -39,7 +39,7 @@ module LibZMQ
39
39
 
40
40
  # Context and misc api
41
41
  #
42
- # @blocking = true is a hint to FFI that the following (and only the following)
42
+ # The `:blocking` option is a hint to FFI that the following (and only the following)
43
43
  # function may block, therefore it should release the GIL before calling it.
44
44
  # This can aid in situations where the function call will/may block and another
45
45
  # thread within the lib may try to call back into the ruby runtime. Failure to
@@ -80,6 +80,12 @@ module LibZMQ
80
80
  attach_function :zmq_bind, [:pointer, :string], :int, :blocking => true
81
81
  attach_function :zmq_connect, [:pointer, :string], :int, :blocking => true
82
82
  attach_function :zmq_close, [:pointer], :int, :blocking => true
83
+ attach_function :zmq_unbind, [:pointer, :string], :int, :blocking => true
84
+ attach_function :zmq_disconnect, [:pointer, :string], :int, :blocking => true
85
+ attach_function :zmq_recvmsg, [:pointer, :pointer, :int], :int, :blocking => true
86
+ attach_function :zmq_recv, [:pointer, :pointer, :size_t, :int], :int, :blocking => true
87
+ attach_function :zmq_sendmsg, [:pointer, :pointer, :int], :int, :blocking => true
88
+ attach_function :zmq_send, [:pointer, :pointer, :size_t, :int], :int, :blocking => true
83
89
 
84
90
  # Device API
85
91
  attach_function :zmq_proxy, [:pointer, :pointer, :pointer], :int, :blocking => true
@@ -90,11 +96,4 @@ module LibZMQ
90
96
  # Monitoring API
91
97
  attach_function :zmq_socket_monitor, [:pointer, :pointer, :int], :int, :blocking => true
92
98
 
93
- # Socket API
94
- attach_function :zmq_unbind, [:pointer, :string], :int, :blocking => true
95
- attach_function :zmq_disconnect, [:pointer, :string], :int, :blocking => true
96
- attach_function :zmq_recvmsg, [:pointer, :pointer, :int], :int, :blocking => true
97
- attach_function :zmq_recv, [:pointer, :pointer, :size_t, :int], :int, :blocking => true
98
- attach_function :zmq_sendmsg, [:pointer, :pointer, :int], :int, :blocking => true
99
- attach_function :zmq_send, [:pointer, :pointer, :size_t, :int], :int, :blocking => true
100
99
  end
@@ -0,0 +1,17 @@
1
+ # Wraps the new API methods available in ZeroMQ 4
2
+ #
3
+ module LibZMQ
4
+
5
+ attach_function :zmq_ctx_term, [:pointer], :void, :blocking => true
6
+ attach_function :zmq_ctx_shutdown, [:pointer], :void, :blocking => true
7
+
8
+ attach_function :zmq_send_const, [:pointer, :pointer, :size_t], :int, :blocking => true
9
+
10
+ attach_function :zmq_z85_encode, [:pointer, :pointer, :size_t], :string, :blocking => true
11
+ attach_function :zmq_z85_decode, [:pointer, :string], :pointer, :blocking => true
12
+
13
+ # Requires ZMQ compiled with libsodium
14
+ # Will return -1 with errno set to ENOSUP otherwise
15
+ attach_function :zmq_curve_keypair, [:pointer, :pointer], :int, :blocking => true
16
+
17
+ end
@@ -2,12 +2,12 @@ module LibZMQ
2
2
 
3
3
  # Used for casting pointers back to the msg_t struct
4
4
  #
5
- class Msg < FFI::Struct
5
+ class Message < FFI::Struct
6
6
  layout :content, :pointer,
7
7
  :flags, :uint8,
8
8
  :vsm_size, :uint8,
9
9
  :vsm_data, [:uint8, 30]
10
- end # class Msg
10
+ end
11
11
 
12
12
 
13
13
  # Create the basic mapping for the poll_item_t structure so we can
@@ -1,3 +1,3 @@
1
1
  module LibZMQ
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/ffi-rzmq-core.rb CHANGED
@@ -3,4 +3,8 @@ require 'ffi-rzmq-core/libc'
3
3
  require 'ffi-rzmq-core/libzmq'
4
4
  require 'ffi-rzmq-core/structures'
5
5
  require 'ffi-rzmq-core/utilities'
6
- require 'ffi-rzmq-core/constants'
6
+ require 'ffi-rzmq-core/constants'
7
+
8
+ if LibZMQ.version4?
9
+ require 'ffi-rzmq-core/libzmq4'
10
+ end
data/spec/libc_spec.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe LibC do
4
+
5
+ it "exposes the malloc function" do
6
+ expect(LibC).to respond_to(:malloc)
7
+ end
8
+
9
+ it "exposes the free function" do
10
+ expect(LibC).to respond_to(:free)
11
+ expect(LibC::Free).to_not be_nil
12
+ end
13
+
14
+ it "exposes the memcpy function" do
15
+ expect(LibC).to respond_to(:memcpy)
16
+ end
17
+
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ if LibZMQ.version4?
4
+ describe LibZMQ do
5
+
6
+ it "exposes new context management methods" do
7
+ [:zmq_ctx_term, :zmq_ctx_shutdown].each do |method|
8
+ expect(LibZMQ).to respond_to(method)
9
+ end
10
+ end
11
+
12
+ it "exposes new sending methods" do
13
+ expect(LibZMQ).to respond_to(:zmq_send_const)
14
+ end
15
+
16
+ it "exposes the binary encoding / decoding API" do
17
+ [:zmq_z85_encode, :zmq_z85_decode].each do |method|
18
+ expect(LibZMQ).to respond_to(method)
19
+ end
20
+ end
21
+
22
+ it "exposes CURVE security methods" do
23
+ expect(LibZMQ).to respond_to(:zmq_curve_keypair)
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe LibZMQ do
4
+
5
+ it "exposes basic query methods" do
6
+ [:zmq_version, :zmq_errno, :zmq_strerror].each do |method|
7
+ expect(LibZMQ).to respond_to(method)
8
+ end
9
+ end
10
+
11
+ it "exposes initialization and context methods" do
12
+ [:zmq_init, :zmq_term, :zmq_ctx_new,
13
+ :zmq_ctx_destroy, :zmq_ctx_set, :zmq_ctx_get].each do |method|
14
+ expect(LibZMQ).to respond_to(method)
15
+ end
16
+ end
17
+
18
+ it "exposes the message API" do
19
+ [:zmq_msg_init, :zmq_msg_init_size, :zmq_msg_init_data,
20
+ :zmq_msg_close, :zmq_msg_data, :zmq_msg_size,
21
+ :zmq_msg_copy, :zmq_msg_move, :zmq_msg_send,
22
+ :zmq_msg_recv, :zmq_msg_more, :zmq_msg_get, :zmq_msg_set].each do |method|
23
+ expect(LibZMQ).to respond_to(method)
24
+ end
25
+ end
26
+
27
+ it "exposes the socket API" do
28
+ [:zmq_socket, :zmq_setsockopt, :zmq_getsockopt,
29
+ :zmq_bind, :zmq_connect, :zmq_close,
30
+ :zmq_unbind, :zmq_disconnect, :zmq_recvmsg,
31
+ :zmq_recv, :zmq_sendmsg, :zmq_send].each do |method|
32
+ expect(LibZMQ).to respond_to(method)
33
+ end
34
+ end
35
+
36
+ it "exposes the Device API" do
37
+ expect(LibZMQ).to respond_to(:zmq_proxy)
38
+ end
39
+
40
+ it "exposes the Poll API" do
41
+ expect(LibZMQ).to respond_to(:zmq_poll)
42
+ end
43
+
44
+ it "exposes the Monitoring API" do
45
+ expect(LibZMQ).to respond_to(:zmq_socket_monitor)
46
+ end
47
+
48
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,14 @@
1
-
2
1
  require File.expand_path(
3
2
  File.join(File.dirname(__FILE__), %w[.. lib ffi-rzmq-core]))
4
3
 
5
- def jruby?
6
- RUBY_PLATFORM =~ /java/
4
+ require 'rspec'
5
+ require 'rspec/autorun'
6
+
7
+ Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each do |support|
8
+ require support
9
+ end
10
+
11
+ RSpec.configure do |config|
12
+ config.include VersionChecking
7
13
  end
8
14
 
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe LibZMQ do
4
+
5
+ it "wraps the msg_t struct as Message" do
6
+ message = LibZMQ::Message.new
7
+
8
+ expect(message[:content]).to_not be_nil
9
+ expect(message[:flags]).to_not be_nil
10
+ expect(message[:vsm_size]).to_not be_nil
11
+ expect(message[:vsm_data]).to_not be_nil
12
+ end
13
+
14
+ it "wraps poll_item_t in a PollItem" do
15
+ poll_item = LibZMQ::PollItem.new
16
+ expect(poll_item.socket).to_not be_nil
17
+ expect(poll_item.fd).to_not be_nil
18
+ expect(poll_item.readable?).to_not be_nil
19
+ expect(poll_item.writable?).to_not be_nil
20
+ expect(poll_item.inspect).to_not be_nil
21
+ end
22
+
23
+ it "wraps zmq_event_t in an EventData" do
24
+ event_data = LibZMQ::EventData.new
25
+
26
+ expect(event_data.event).to_not be_nil
27
+ expect(event_data.value).to_not be_nil
28
+ expect(event_data.inspect).to_not be_nil
29
+ end
30
+
31
+ end
@@ -0,0 +1,7 @@
1
+ # Helper methods for figuring out which version of Ruby / ZMQ we are
2
+ # testing and working with.
3
+ module VersionChecking
4
+ def jruby?
5
+ RUBY_PLATFORM =~ /java/
6
+ end
7
+ end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-rzmq-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuck Remes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-14 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ffi
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ~>
18
17
  - !ruby/object:Gem::Version
19
18
  version: '1.9'
20
19
  type: :runtime
21
- prerelease: false
20
+ name: ffi
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ~>
25
24
  - !ruby/object:Gem::Version
26
25
  version: '1.9'
26
+ prerelease: false
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ~>
32
31
  - !ruby/object:Gem::Version
33
32
  version: '2.14'
34
33
  type: :development
35
- prerelease: false
34
+ name: rspec
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ~>
39
38
  - !ruby/object:Gem::Version
40
39
  version: '2.14'
40
+ prerelease: false
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - '>='
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  type: :development
49
- prerelease: false
48
+ name: rake
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - '>='
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
54
+ prerelease: false
55
55
  description: |-
56
56
  This gem provides only the FFI wrapper for the ZeroMQ (0mq) networking library.
57
57
  Project can be used by any other zeromq gems that want to provide their own high-level Ruby API.
@@ -63,22 +63,30 @@ extra_rdoc_files: []
63
63
  files:
64
64
  - .gitignore
65
65
  - .travis.yml
66
+ - Gemfile
66
67
  - LICENSE
67
68
  - README.md
69
+ - Rakefile
68
70
  - ffi-rzmq-core.gemspec
69
71
  - lib/ffi-rzmq-core.rb
70
72
  - lib/ffi-rzmq-core/constants.rb
71
73
  - lib/ffi-rzmq-core/libc.rb
72
74
  - lib/ffi-rzmq-core/libzmq.rb
75
+ - lib/ffi-rzmq-core/libzmq4.rb
73
76
  - lib/ffi-rzmq-core/structures.rb
74
77
  - lib/ffi-rzmq-core/utilities.rb
75
78
  - lib/ffi-rzmq-core/version.rb
79
+ - spec/libc_spec.rb
80
+ - spec/libzmq4_spec.rb
81
+ - spec/libzmq_spec.rb
76
82
  - spec/spec_helper.rb
83
+ - spec/structures_spec.rb
84
+ - spec/support/version_checking.rb
77
85
  homepage: http://github.com/chuckremes/ffi-rzmq-core
78
86
  licenses:
79
87
  - MIT
80
88
  metadata: {}
81
- post_install_message:
89
+ post_install_message:
82
90
  rdoc_options: []
83
91
  require_paths:
84
92
  - lib
@@ -93,10 +101,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
101
  - !ruby/object:Gem::Version
94
102
  version: '0'
95
103
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.0.3
98
- signing_key:
104
+ rubyforge_project:
105
+ rubygems_version: 2.1.9
106
+ signing_key:
99
107
  specification_version: 4
100
108
  summary: This gem provides only the FFI wrapper for the ZeroMQ (0mq) networking library.
101
109
  test_files:
110
+ - spec/libc_spec.rb
111
+ - spec/libzmq4_spec.rb
112
+ - spec/libzmq_spec.rb
102
113
  - spec/spec_helper.rb
114
+ - spec/structures_spec.rb
115
+ - spec/support/version_checking.rb
116
+ has_rdoc: