bundesstrasse 0.0.1-java → 0.0.2-java

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.
Files changed (2) hide show
  1. data/lib/bundesstrasse/socket.rb +16 -4
  2. metadata +2 -2
@@ -2,12 +2,17 @@
2
2
  module Bundesstrasse
3
3
  class Socket
4
4
  def initialize(type, options={})
5
- context = Context.context(options[:io_threads] || 1)
5
+ options = options.dup
6
+ context = Context.context(options.delete(:io_threads) || 1)
6
7
  @socket = context.socket(type)
7
8
  raise SocketError unless @socket
8
- error_check { @socket.setsockopt ZMQ::LINGER, options[:linger] || -1 }
9
- error_check { @socket.setsockopt ZMQ::RCVTIMEO, options[:timeout] || -1 }
10
- error_check { @socket.setsockopt ZMQ::SNDTIMEO, options[:timeout] || -1 }
9
+ DEFAULT_OPTIONS.merge(options).each do |option, value|
10
+ begin
11
+ error_check { @socket.setsockopt ZMQ.const_get(option.upcase), value }
12
+ rescue NameError => e
13
+ raise ArgumentError, "Unknown socket option '#{option}'", e.backtrace
14
+ end
15
+ end
11
16
  end
12
17
 
13
18
  def bind(address)
@@ -44,6 +49,13 @@ module Bundesstrasse
44
49
  end
45
50
  true
46
51
  end
52
+
53
+ DEFAULT_OPTIONS = {
54
+ linger: 0,
55
+ rcvtimeo: -1,
56
+ sndtimeo: -1,
57
+ }
58
+
47
59
  end
48
60
 
49
61
  class SocketError < StandardError
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bundesstrasse
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: java
7
7
  authors:
8
8
  - Joel Segerlind
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements: []
100
100
  rubyforge_project:
101
- rubygems_version: 1.8.24
101
+ rubygems_version: 1.8.25
102
102
  signing_key:
103
103
  specification_version: 3
104
104
  summary: A thin wrapper around ffi-rzmq, providing basic functionality