zyre 0.4.0 → 0.5.0

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
  SHA256:
3
- metadata.gz: e56e2efba36769885761b0e4eca374ee1a2a8b1d9ce453ae84c388218ffed962
4
- data.tar.gz: 8cd9af854d199c9529df5f6b048d64c60d7737d99297025ad8f0b00d1621e831
3
+ metadata.gz: 18eb57b31a6b9b451f723f8c845c00d4fd4547ab5b7b9c3615d32062256e855c
4
+ data.tar.gz: 5b8ae5d09f519edf6386d71f2cfebd62dbab3e757c5769d9e598ea4494360e63
5
5
  SHA512:
6
- metadata.gz: 73cc151bd63a418aa8a88e0a75816e95ad651babc58fbe72b07ca2842ef67bdfb8b257c6ca31982b44772054606dec060f75db97ecb234a8a1f867a50de6c3d8
7
- data.tar.gz: 5a43c47fe85eb3ca1748e7c1808d1a458fe5b0321d29f32ad4fd3ef0e7e42fce7bf44a6d1b950bf836e1023a239c4455bcbbee73cf437d82a381fd9d82c8ec38
6
+ metadata.gz: fe19f91ae8dfb44aa6fcd3184724201662d4852cbdcec3db9e326780f7d5587e6323414f7f49f64d129a00549fbade302c07344fec05128c69a27ff7aa7db8f0
7
+ data.tar.gz: 5bf176e26bfb6c442f7d647defe621d4dbc058d6b59c8b95170d303359f3d9ddb81247a594341d05e1d7673103b8f010f66ba297b843c68e5fe285be93056141
checksums.yaml.gz.sig CHANGED
Binary file
data/History.md CHANGED
@@ -1,6 +1,20 @@
1
1
  # Release History for zyre
2
2
 
3
3
  ---
4
+ ## v0.5.0 [2023-02-14] Michael Granger <ged@faeriemud.org>
5
+
6
+ Improvements:
7
+
8
+ - Add Z85-encoding and -decoding.
9
+
10
+
11
+ ## v0.4.1 [2021-03-16] Michael Granger <ged@faeriemud.org>
12
+
13
+ Bugfixes:
14
+
15
+ - Add a missing library file to the manifest.
16
+
17
+
4
18
  ## v0.4.0 [2021-02-19] Michael Granger <ged@faeriemud.org>
5
19
 
6
20
  Improvements:
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 Ravn Group
1
+ Copyright (c) 2020-2023 Ravn Inc
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -28,7 +28,7 @@ This example joins the Zyre network and dumps messages it sees in the 'global' g
28
28
  node = Zyre::Node.new
29
29
  node.join( 'global' )
30
30
  node.start
31
-
31
+
32
32
  node.each_event do |event|
33
33
  event.print
34
34
  end
@@ -135,7 +135,31 @@ development.
135
135
 
136
136
  ## License
137
137
 
138
- Copyright (c) 2020-2021, Ravn Group
138
+ This project includes code adapted from the ZeroMQ RFC project, used under
139
+ the following license:
140
+
141
+ > Copyright (c) 2010-2013 iMatix Corporation and Contributors
142
+ >
143
+ > Permission is hereby granted, free of charge, to any person obtaining a copy of
144
+ > this software and associated documentation files (the "Software"), to deal in
145
+ > the Software without restriction, including without limitation the rights to
146
+ > use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
147
+ > the Software, and to permit persons to whom the Software is furnished to do so,
148
+ > subject to the following conditions:
149
+ >
150
+ > The above copyright notice and this permission notice shall be included in all
151
+ > copies or substantial portions of the Software.
152
+ >
153
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
155
+ > FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
156
+ > COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
157
+ > IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
158
+ > CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
159
+
160
+ Everything else is:
161
+
162
+ Copyright (c) 2020-2023, Ravn Inc
139
163
  All rights reserved.
140
164
 
141
165
  Redistribution and use in source and binary forms, with or without
data/ext/zyre_ext/event.c CHANGED
@@ -175,7 +175,7 @@ rzyre_zhash_from_rhash( VALUE ruby_hash )
175
175
 
176
176
  /*
177
177
  * call-seq:
178
- * Zyre::Event.synthesized( type, peer_uuid, **fields ) -> event
178
+ * Zyre::Event.synthesize( type, peer_uuid, **fields ) -> event
179
179
  *
180
180
  * Create an event in memory without going through a Zyre::Node. This is useful for
181
181
  * testing.
@@ -9,11 +9,15 @@ have_library( 'zyre' ) or
9
9
  abort "No zyre library!"
10
10
  have_library( 'czmq' ) or
11
11
  abort "No czmq library!"
12
+ have_library( 'zmq' ) or
13
+ abort "No zmq library!"
12
14
 
13
15
  have_header( 'zyre.h' ) or
14
16
  abort "No zyre.h header!"
15
17
  have_header( 'czmq.h' ) or
16
18
  abort "No czmq.h header!"
19
+ have_header( 'zmq.h' ) or
20
+ abort "No zmq.h header!"
17
21
  have_header( 'ruby/thread.h' ) or
18
22
  abort "Your Ruby is too old!"
19
23
 
@@ -23,6 +27,9 @@ have_func( 'zyre_set_beacon_peer_port', 'zyre.h' )
23
27
  have_func( 'zyre_set_contest_in_group', 'zyre.h' )
24
28
  have_func( 'zyre_set_zcert', 'zyre.h' )
25
29
 
30
+ have_func( 'zmq_z85_encode', 'zmq.h' )
31
+ have_func( 'zmq_z85_decode', 'zmq.h' )
32
+
26
33
  have_func( 'zcert_unset_meta', 'czmq.h' )
27
34
 
28
35
  create_header()
@@ -5,6 +5,12 @@
5
5
  * Authors:
6
6
  * * Michael Granger <ged@FaerieMUD.org>
7
7
  *
8
+ * Refs:
9
+ * - https://github.com/zeromq/zyre#api-summary
10
+ * - http://api.zeromq.org/master:zmq-z85-decode
11
+ * - http://api.zeromq.org/master:zmq-z85-encode
12
+ *
13
+ *
8
14
  */
9
15
 
10
16
  #include "zyre_ext.h"
@@ -148,7 +154,7 @@ rzyre_s_zyre_version()
148
154
 
149
155
  version = zyre_version();
150
156
 
151
- return INT2NUM( version );
157
+ return LONG2NUM( version );
152
158
  }
153
159
 
154
160
 
@@ -180,6 +186,7 @@ rzyre_s_interfaces( VALUE module )
180
186
  const char *netmask_s = ziflist_netmask( iflist );
181
187
  const VALUE info_hash = rb_hash_new();
182
188
 
189
+ rzyre_log( "debug", "Getting info for %s", address_s );
183
190
  rb_hash_aset( info_hash, ID2SYM(rb_intern("address")), rb_usascii_str_new_cstr(address_s) );
184
191
  rb_hash_aset( info_hash, ID2SYM(rb_intern("broadcast")), rb_usascii_str_new_cstr(broadcast_s) );
185
192
  rb_hash_aset( info_hash, ID2SYM(rb_intern("netmask")), rb_usascii_str_new_cstr(netmask_s) );
@@ -211,6 +218,77 @@ rzyre_s_disable_zsys_handler( VALUE module )
211
218
  }
212
219
 
213
220
 
221
+ /*
222
+ * call-seq:
223
+ * Zyre.z85_encode( data ) -> string
224
+ *
225
+ * Return the specified binary +data+ as a Z85-encoded binary string. The size of the data must
226
+ * be divisible by 4. If there is a problem encoding the data, returns +nil+.
227
+ *
228
+ */
229
+ static VALUE
230
+ rzyre_s_z85_encode( VALUE module, VALUE data )
231
+ {
232
+ #if HAVE_ZMQ_Z85_ENCODE
233
+ const char *data_str = StringValuePtr( data );
234
+ const long len = RSTRING_LEN( data );
235
+ const long res_len = (len * 1.25) + 1;
236
+ char *encoded = NULL;
237
+ VALUE result = Qnil;
238
+
239
+ if ( len % 4 ) return Qnil;
240
+
241
+ encoded = RB_ZALLOC_N( char, res_len );
242
+ zmq_z85_encode( encoded, (unsigned char *)data_str, len );
243
+
244
+ if ( encoded != NULL ) {
245
+ result = rb_usascii_str_new( encoded, res_len - 1 );
246
+ }
247
+
248
+ ruby_xfree( encoded );
249
+
250
+ return result;
251
+ #else
252
+ rb_notimplement();
253
+ #endif
254
+ }
255
+
256
+
257
+ /*
258
+ * call-seq:
259
+ * Zyre.z85_decode( string ) -> data
260
+ *
261
+ * Return the data decoded from the specified Z85-encoded binary +string+. If there is a
262
+ * problem decoding the string, returns +nil+.
263
+ *
264
+ */
265
+ static VALUE
266
+ rzyre_s_z85_decode( VALUE module, VALUE string )
267
+ {
268
+ #if HAVE_ZMQ_Z85_DECODE
269
+ const char *data_str = StringValueCStr( string );
270
+ const long len = RSTRING_LEN( string );
271
+ const long res_len = (len * 0.8) + 1;
272
+ char *decoded = NULL;
273
+ VALUE result = Qnil;
274
+
275
+ if ( len % 5 ) return Qnil;
276
+
277
+ decoded = RB_ZALLOC_N( char, res_len );
278
+ zmq_z85_decode( (unsigned char *)decoded, data_str );
279
+
280
+ if ( decoded != NULL ) {
281
+ result = rb_str_new( decoded, res_len - 1 );
282
+ }
283
+
284
+ ruby_xfree( decoded );
285
+
286
+ return result;
287
+ #else
288
+ rb_notimplement();
289
+ #endif
290
+ }
291
+
214
292
 
215
293
  static VALUE
216
294
  rzyre_s_start_authenticator( VALUE module )
@@ -225,6 +303,11 @@ rzyre_s_start_authenticator( VALUE module )
225
303
  void
226
304
  Init_zyre_ext()
227
305
  {
306
+ /*
307
+ * Document-module: Zyre
308
+ *
309
+ * The top level namespace for Zyre classes.
310
+ */
228
311
  rzyre_mZyre = rb_define_module( "Zyre" );
229
312
 
230
313
  #ifdef CZMQ_BUILD_DRAFT_API
@@ -242,6 +325,9 @@ Init_zyre_ext()
242
325
  rb_define_singleton_method( rzyre_mZyre, "interfaces", rzyre_s_interfaces, 0 );
243
326
  rb_define_singleton_method( rzyre_mZyre, "disable_zsys_handler", rzyre_s_disable_zsys_handler, 0 );
244
327
 
328
+ rb_define_singleton_method( rzyre_mZyre, "z85_encode", rzyre_s_z85_encode, 1 );
329
+ rb_define_singleton_method( rzyre_mZyre, "z85_decode", rzyre_s_z85_decode, 1 );
330
+
245
331
  // :TODO: Allow for startup of the zauth agent. This will require enough of a
246
332
  // subset of CZMQ that I hesitate to do it in Zyre. Maybe better to just write a
247
333
  // decent CZMQ library instead?
@@ -27,6 +27,7 @@
27
27
 
28
28
  #include "zyre.h"
29
29
  #include "czmq.h"
30
+ #include "zmq.h"
30
31
 
31
32
  #ifndef TRUE
32
33
  # define TRUE 1
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'observability'
5
4
  require 'observability/instrumentation' unless defined?( Observability::Instrumentation )
data/lib/zyre/cert.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'loggability'
5
4
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -11,7 +10,6 @@ class Zyre::Event::Exit < Zyre::Event
11
10
  return "%s (%s) has left the network" % [
12
11
  self.peer_uuid,
13
12
  self.peer_name,
14
- self.headers,
15
13
  ]
16
14
  end
17
15
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'zyre/event' unless defined?( Zyre::Event )
4
+
5
+
6
+ class Zyre::Event::Leader < Zyre::Event
7
+
8
+ ### Provide the details of the inspect message.
9
+ def inspect_details
10
+ return "%s (%s) has been elected leader of «%s»" % [
11
+ self.peer_uuid,
12
+ self.peer_name,
13
+ self.group
14
+ ]
15
+ end
16
+
17
+ end # class Zyre::Event::Leader
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -8,7 +7,7 @@ class Zyre::Event::Silent < Zyre::Event
8
7
 
9
8
  ### Provide the details of the inspect message.
10
9
  def inspect_details
11
- return "%s (%s) isn't responding to pings" % [
10
+ return "%s %s (%s) isn't responding to pings" % [
12
11
  self.peer_uuid,
13
12
  self.peer_name,
14
13
  self.headers,
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'zyre/event' unless defined?( Zyre::Event )
5
4
 
data/lib/zyre/event.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'loggability'
5
4
 
data/lib/zyre/node.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'loggability'
5
4
 
data/lib/zyre/poller.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'loggability'
5
4
 
data/lib/zyre/testing.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'securerandom'
5
4
  require 'loggability'
data/lib/zyre.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'set'
5
4
  require 'loggability'
@@ -14,8 +13,7 @@ module Zyre
14
13
 
15
14
 
16
15
  # Gem version (semver)
17
- VERSION = '0.4.0'
18
-
16
+ VERSION = '0.5.0'
19
17
 
20
18
  # Set up a logger for Zyre classes
21
19
  log_as :zyre
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # -*- ruby -*-
2
- # frozen_string_literal: true
3
2
 
4
3
  if ENV['COVERAGE'] || ENV['CI']
5
4
  require 'simplecov'
@@ -49,7 +48,7 @@ RSpec.configure do |config|
49
48
  config.profile_examples = 5
50
49
  config.run_all_when_everything_filtered = true
51
50
  config.shared_context_metadata_behavior = :apply_to_host_groups
52
- # config.warnings = true
51
+ config.warnings = true
53
52
 
54
53
  config.before( :suite ) do
55
54
  Zyre::Testing.check_fdmax
@@ -199,5 +199,125 @@ RSpec.describe( Zyre::Event ) do
199
199
 
200
200
  end
201
201
 
202
+
203
+
204
+ describe "inspect output" do
205
+
206
+ let( :peer_uuid ) { '8D9B6F67-2B40-4E56-B352-39029045B568' }
207
+ let( :peer_name ) { 'node1' }
208
+ let( :peer_addr ) { 'in-proc:/synthesized' }
209
+
210
+
211
+ it "has useful inspect output for ENTER events" do
212
+ event = described_class.synthesize( :ENTER,
213
+ peer_uuid, peer_name: peer_name, peer_addr: peer_addr,
214
+ headers: {'Content-type' => 'application/msgpack'} )
215
+
216
+ expect( event.inspect ).to include( peer_uuid )
217
+ expect( event.inspect ).to include( peer_name )
218
+ expect( event.inspect ).to include( peer_addr )
219
+ expect( event.inspect ).to match( /has entered the network/i )
220
+ expect( event.inspect ).to match( /Content-type/i )
221
+ expect( event.inspect ).to match( %r{application/msgpack}i )
222
+ end
223
+
224
+
225
+ it "has useful inspect output for EVASIVE events" do
226
+ event = described_class.synthesize( :EVASIVE, peer_uuid, peer_name: peer_name )
227
+
228
+ expect( event.inspect ).to include( peer_uuid )
229
+ expect( event.inspect ).to include( peer_name )
230
+ expect( event.inspect ).to match( /is being evasive/i )
231
+ end
232
+
233
+
234
+ it "has useful inspect output for EXIT events" do
235
+ event = described_class.synthesize( :EXIT, peer_uuid, peer_name: peer_name )
236
+
237
+ expect( event.inspect ).to include( peer_uuid )
238
+ expect( event.inspect ).to include( peer_name )
239
+ expect( event.inspect ).to match( /has left the network/i )
240
+ end
241
+
242
+
243
+ it "has useful inspect output for JOIN events" do
244
+ event = described_class.synthesize( :JOIN,
245
+ peer_uuid, group: 'CHANNEL1', peer_name: peer_name )
246
+
247
+ expect( event.inspect ).to include( peer_uuid )
248
+ expect( event.inspect ).to include( peer_name )
249
+ expect( event.inspect ).to include( 'CHANNEL1' )
250
+ expect( event.inspect ).to match( /joined/i )
251
+ end
252
+
253
+
254
+ it "has useful inspect output for LEADER events" do
255
+ event = described_class.synthesize( :LEADER,
256
+ peer_uuid, group: 'CHANNEL1', peer_name: peer_name )
257
+
258
+ expect( event.inspect ).to include( peer_uuid )
259
+ expect( event.inspect ).to include( peer_name )
260
+ expect( event.inspect ).to include( 'CHANNEL1' )
261
+ expect( event.inspect ).to match( /has been elected leader of/i )
262
+ end
263
+
264
+
265
+ it "has useful inspect output for LEAVE events" do
266
+ event = described_class.synthesize( :LEAVE,
267
+ peer_uuid, group: 'CHANNEL1', peer_name: peer_name )
268
+
269
+ expect( event.inspect ).to include( peer_uuid )
270
+ expect( event.inspect ).to include( peer_name )
271
+ expect( event.inspect ).to include( 'CHANNEL1' )
272
+ expect( event.inspect ).to match( /left/i )
273
+ end
274
+
275
+
276
+ it "has useful inspect output for SHOUT events" do
277
+ message = 'Hey guys, who wants to play Valheim?'
278
+ event = described_class.synthesize( :SHOUT,
279
+ peer_uuid, group: 'CHANNEL1', msg: message,
280
+ peer_name: peer_name )
281
+
282
+ expect( event.inspect ).to include( peer_uuid )
283
+ expect( event.inspect ).to include( peer_name )
284
+ expect( event.inspect ).to include( 'CHANNEL1' )
285
+ expect( event.inspect ).to match( / on /i )
286
+ expect( event.inspect ).to include( message )
287
+ end
288
+
289
+
290
+ it "has useful inspect output for SILENT events" do
291
+ event = described_class.synthesize( :SILENT, peer_uuid, peer_name: peer_name )
292
+
293
+ expect( event.inspect ).to include( peer_uuid )
294
+ expect( event.inspect ).to include( peer_name )
295
+ expect( event.inspect ).to match( /isn't responding to pings/i )
296
+ end
297
+
298
+
299
+ it "has useful inspect output for STOP events" do
300
+ event = described_class.synthesize( :STOP, peer_uuid )
301
+
302
+ expect( event.inspect ).to match( /node is stopping/i )
303
+ end
304
+
305
+
306
+ it "has useful inspect output for WHISPER events" do
307
+ target = SecureRandom.uuid
308
+ message = "Hey #{target}, want to play Valheim?"
309
+ event = described_class.synthesize( :WHISPER,
310
+ peer_uuid, msg: message,
311
+ peer_name: peer_name )
312
+
313
+ expect( event.inspect ).to include( peer_uuid )
314
+ expect( event.inspect ).to include( peer_name )
315
+ expect( event.inspect ).to match( /whisper from/i )
316
+ expect( event.inspect ).to include( message )
317
+ end
318
+
319
+ end
320
+
321
+
202
322
  end
203
323
 
@@ -44,7 +44,7 @@ RSpec.describe( Zyre::Node ) do
44
44
 
45
45
 
46
46
  it "can set headers" do
47
- node1 = started_node do |n|
47
+ _node1 = started_node do |n|
48
48
  n.set_header( 'Protocol-version', '2' )
49
49
  end
50
50
  node2 = started_node
@@ -56,7 +56,7 @@ RSpec.describe( Zyre::Node ) do
56
56
 
57
57
 
58
58
  it "can set headers from a hash" do
59
- node1 = started_node do |n|
59
+ _node1 = started_node do |n|
60
60
  n.headers = {
61
61
  protocol_version: 2,
62
62
  content_type: 'application/messagepack'
data/spec/zyre_spec.rb CHANGED
@@ -5,7 +5,7 @@ require_relative 'spec_helper'
5
5
  require 'zyre'
6
6
 
7
7
 
8
- RSpec.describe Zyre do
8
+ RSpec.describe( Zyre ) do
9
9
 
10
10
 
11
11
  # Pattern for matching IPv4 addresses
@@ -63,5 +63,68 @@ RSpec.describe Zyre do
63
63
  expect( described_class.has_draft_apis? ).to eq( true ).or( eq false )
64
64
  end
65
65
 
66
+
67
+ describe "Z85 encoding/decoding" do
68
+
69
+ # From the 32/Z85 reference code:
70
+ # https://github.com/zeromq/rfc/blob/master/src/spec_32.c
71
+ let( :test_data_1 ) do
72
+ [0x86, 0x4F, 0xD2, 0x6F, 0xB5, 0x59, 0xF7, 0x5B].pack('C*')
73
+ end
74
+ let( :test_data_2 ) do
75
+ [
76
+ 0x8E, 0x0B, 0xDD, 0x69, 0x76, 0x28, 0xB9, 0x1D,
77
+ 0x8F, 0x24, 0x55, 0x87, 0xEE, 0x95, 0xC5, 0xB0,
78
+ 0x4D, 0x48, 0x96, 0x3F, 0x79, 0x25, 0x98, 0x77,
79
+ 0xB4, 0x9C, 0xD9, 0x06, 0x3A, 0xEA, 0xD3, 0xB7
80
+ ].pack('C*')
81
+ end
82
+
83
+
84
+ it "can round-trip an empty string" do
85
+ result = described_class.z85_decode( described_class.z85_encode(''.b) )
86
+ expect( result ).to eq( ''.b )
87
+ end
88
+
89
+
90
+ it "fails if the data to be encoded is not bounded at 4 bytes" do
91
+ expect( described_class.z85_encode(test_data_1[0, 3]) ).to be_nil
92
+ end
93
+
94
+
95
+ it "can round-trip 4-byte-bounded data" do
96
+ encoded = described_class.z85_encode( test_data_1 )
97
+
98
+ expect( encoded ).to eq( 'HelloWorld' )
99
+ expect( encoded.encoding ).to eq( Encoding::US_ASCII )
100
+
101
+ decoded = described_class.z85_decode( encoded )
102
+
103
+ expect( decoded ).to eq( test_data_1 )
104
+ expect( decoded.encoding ).to eq( Encoding::ASCII_8BIT )
105
+ end
106
+
107
+
108
+ it "can round-trip a ZMQ Curve test key" do
109
+ encoded = described_class.z85_encode( test_data_2 )
110
+
111
+ expect( encoded ).to eq( 'JTKVSB%%)wK0E.X)V>+}o?pNmC{O&4W4b!Ni{Lh6' )
112
+ expect( encoded.encoding ).to eq( Encoding::US_ASCII )
113
+
114
+ decoded = described_class.z85_decode( encoded )
115
+
116
+ expect( decoded ).to eq( test_data_2 )
117
+ expect( decoded.encoding ).to eq( Encoding::ASCII_8BIT )
118
+ end
119
+
120
+
121
+ it "fails if the data to be decoded is not bounded at 5 bytes" do
122
+ encoded = 'JTKVSB%%)wK0E.X)V>+}o?pNmC{O&4W4b!Ni{Lh6'
123
+
124
+ expect( described_class.z85_decode(encoded[0..-2]) ).to be_nil
125
+ end
126
+
127
+ end
128
+
66
129
  end
67
130
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zyre
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIID+DCCAmCgAwIBAgIBAzANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
14
- REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMDEyMjQyMDU1MjlaFw0yMTEyMjQyMDU1
15
- MjlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
13
+ MIID+DCCAmCgAwIBAgIBBTANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
14
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMzAxMTYxNzE2MDlaFw0yNDAxMTYxNzE2
15
+ MDlaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
16
16
  hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
17
17
  L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZxkSUuWcP/sFhDXL1lWUuIl
18
18
  M4uHbGCRmOshDrF4dgnBeOvkHr1fIhPlJm5FO+Vew8tSQmlDsosxLUx+VB7DrVFO
@@ -23,17 +23,17 @@ cert_chain:
23
23
  ozilJg4aar2okb/RA6VS87o+d7g6LpDDMMQjH4G9OPnJENLdhu8KnPw/ivSVvQw7
24
24
  N2I4L/ZOIe2DIVuYH7aLHfjZDQv/mNgpAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
25
25
  VR0PBAQDAgSwMB0GA1UdDgQWBBRyjf55EbrHagiRLqt5YAd3yb8k4DANBgkqhkiG
26
- 9w0BAQsFAAOCAYEAMYegZanJi8zq7QKPT7wqXefX4C88I5JWeBHR3PvvWK0CwyMV
27
- peyiu5I13w/lYX+HUZjE4qsSpJMJFXWl4WZCOo+AMprOcf0PxfuJpxCej5D4tavf
28
- vRfhahSw7XJrcZih/3J+/UgoH7R05MJ+8LTcy3HGrB3a0vTafjm8OY7Xpa0LJDoN
29
- JDqxK321VIHyTibbKeA1hWSE6ljlQDvFbTqiCj3Ulp1jTv3TOlvRl8fqcfhxUJI0
30
- +5Q82jJODjEN+GaWs0V+NlrbU94cXwS2PH5dXogftB5YYA5Ex8A0ikZ73xns4Hdo
31
- XxdLdd92F5ovxA23j/rKe/IDwqr6FpDkU3nPXH/Qp0TVGv9zZnVJc/Z6ChkuWj8z
32
- pW7JAyyiiHZgKKDReDrA2LA7Zs3o/7KA6UtUH0FHf8LYhcK+pfHk6RtjRe65ffw+
33
- MCh97sQ/Z/MOusb5+QddBmB+k8EicXyGNl4b5L4XpL7fIQu+Y96TB3JEJlShxFD9
34
- k9FjI4d9EP54gS/4
26
+ 9w0BAQsFAAOCAYEARYCeUVBWARNKqF0cvNnLJvFf4hdW2+Rtc7NfC5jQvX9a1oom
27
+ sfVvS96eER/9cbrphu+vc59EELw4zT+RY3/IesnoE7CaX6zIOFmSmG7K61OHsSLR
28
+ KqMygcWwyuPXT2JG7JsGHuxbzgaRWe29HbSjBbLYxiMH8Zxh4tKutxzKF7jb0Ggq
29
+ KAf9MH5LwG8IHVIfV5drT14PvgR3tcvmrn1timPyJl+eZ3LNnm9ofOCweuZCq1cy
30
+ 4Q8LV3vP2Cofy9q+az3DHdaUGlmMiZZZqKixDr1KSS9nvh0ZrKMOUL1sWj/IaxrQ
31
+ RV3y6td14q49t+xnbj00hPlbW7uE2nLJLt2NAoXiE1Nonndz1seB2c6HL79W9fps
32
+ E/O12pQjCp/aPUZMt8/8tKW31RIy/KP8XO6OTJNWA8A/oNEI0g5p/LmmEtJKWYr1
33
+ WmEdESlpWhzFECctefIF2lsN9vaOuof57RM77t2otrtcscDtNarIqjZsIyqtDvtL
34
+ DttITiit0Vwz7bY0
35
35
  -----END CERTIFICATE-----
36
- date: 2021-02-19 00:00:00.000000000 Z
36
+ date: 2023-02-14 00:00:00.000000000 Z
37
37
  dependencies:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: loggability
@@ -42,6 +42,9 @@ dependencies:
42
42
  - - "~>"
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0.18'
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.18.2
45
48
  type: :runtime
46
49
  prerelease: false
47
50
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,6 +52,9 @@ dependencies:
49
52
  - - "~>"
50
53
  - !ruby/object:Gem::Version
51
54
  version: '0.18'
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.18.2
52
58
  - !ruby/object:Gem::Dependency
53
59
  name: rake-deveiate
54
60
  requirement: !ruby/object:Gem::Requirement
@@ -182,6 +188,7 @@ files:
182
188
  - lib/zyre/event/evasive.rb
183
189
  - lib/zyre/event/exit.rb
184
190
  - lib/zyre/event/join.rb
191
+ - lib/zyre/event/leader.rb
185
192
  - lib/zyre/event/leave.rb
186
193
  - lib/zyre/event/shout.rb
187
194
  - lib/zyre/event/silent.rb
@@ -221,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
228
  - !ruby/object:Gem::Version
222
229
  version: '0'
223
230
  requirements: []
224
- rubygems_version: 3.2.11
231
+ rubygems_version: 3.4.6
225
232
  signing_key:
226
233
  specification_version: 4
227
234
  summary: A ZRE library for Ruby.
metadata.gz.sig CHANGED
Binary file