nmspec 1.5.0 → 1.6.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
  SHA256:
3
- metadata.gz: 957a2a00e6c56c138e22265df428d64ac042572316b76b55468ecd38835dd6e4
4
- data.tar.gz: 5ffe4d18075f75fcfb825a9c4b041f6d5f62a8ce9aa52d19b1fb46dc2f7051f5
3
+ metadata.gz: 3e70533f6e749c2e1002934b261b6d642d70d05c713ba4ae277e19fdc9ec5ca8
4
+ data.tar.gz: 1ab962483d6d486185ded45fdf9b74d5759741ba7f6baa6d03a857df399afcc6
5
5
  SHA512:
6
- metadata.gz: 7a5d380015227e41dceaee8d125da1561e1e3d15736e24219eeabb1ff2506a0e8084ca143050253a25b2a422fd9df59af97a538315a9674caed795f19a9bf561
7
- data.tar.gz: 0d7596ea1a35cfaed2feac076c77f0a10fba53c70254f2b2b756c827a4b9aed21ff130384421f27aa78a686286aa8b793043e10182c620d7120fef3f3750c763
6
+ metadata.gz: 7011dd7477bc0a65e472a93b8f305e5e9c4e240574543765a36dc30b2bc4244536a762bcd915bca646bca821dfa95c481d866eba9e24656c8d2349a33ed00a53
7
+ data.tar.gz: e173d860689aaa6845e3e7313305cb2667464122506dcfe7069fe5f064a2889fbe8e7638116c34548e3e56c077821b20aa0ce63c8b61747836b57c2d00131e86
data/README.md CHANGED
@@ -12,6 +12,12 @@ described in `nmspec` are used to create both the reading and writing sides
12
12
  of the connection, so that a single source code file contains everything you
13
13
  need for a network peer, regardless of if it's the client or server.
14
14
 
15
+ ## Demo video explaining how to use this gem
16
+
17
+ <a href="https://youtu.be/Ib6c6BEl82c">
18
+ <img src="https://s3.us-east-2.amazonaws.com/vim4evar.com/nmspec-imgs/link-to-demo-video.png" />
19
+ </a>
20
+
15
21
  ## Motivation
16
22
 
17
23
  `nmspec` was specifically created to help with with a problem I was facing,
@@ -48,8 +54,8 @@ As a starting point this gem supports network messengers in these two languages:
48
54
  * [Ruby 3.0.x][ruby-lang]
49
55
  * [GDScript 3.4.stable][gdscript]
50
56
 
51
- `nmspec` came out of a online game project where the backend was written in
52
- Ruby, and the frontend build with the Godot game engine, which includes the
57
+ `nmspec` came out of a online game project where the backend is written in
58
+ Ruby, and the frontend is built with the Godot game engine, which includes the
53
59
  embedded scripting language, GDSCript.
54
60
 
55
61
  # Sample usage
@@ -283,7 +289,7 @@ description languages/tools in the past, beginning with [Prolac][prolac]. This
283
289
  lead me to other network messaging tools, binary serialization in general,
284
290
  finally [Google's protocol buffers][protobuffs]. Protocol buffers were probably
285
291
  the closest thing to what I wanted, and took care of binary
286
- serialization/deserialization, but weren't packaaged with the networking layer,
292
+ serialization/deserialization, but weren't packaged with the networking layer,
287
293
  which introduces additional considerations such as byte ordering, efficient
288
294
  packet construction, TCP stack options, and communication retries and graceful
289
295
  failover. While protocol buffers are a good design, and I think do a good job of
@@ -14,7 +14,7 @@ module Nmspec
14
14
 
15
15
  if spec.dig(:msgr, :desc)
16
16
  code << '#'
17
- code << "# #{spec.dig(:msgr, :desc)}"
17
+ spec.dig(:msgr, :desc).lines.each{|l| code << "# #{l.strip}" }
18
18
  end
19
19
 
20
20
  code << 'extends Reference'
@@ -91,7 +91,6 @@ module Nmspec
91
91
  code << '# WARN: this means sockets that use little-endian will tend to lock up'
92
92
  code << 'func _init(_socket):'
93
93
  code << "\tsocket = _socket"
94
- code << "\tsocket.set_no_delay(#{nodelay})"
95
94
  code << "\tsocket.set_big_endian(#{big_endian})"
96
95
 
97
96
  code
@@ -324,7 +323,7 @@ module Nmspec
324
323
  def _proto_method(kind, proto_code, proto, local_vars, passed_params, subtypes)
325
324
  code = []
326
325
 
327
- code << "# #{proto[:desc]}" if proto[:desc]
326
+ proto[:desc].lines.each{|l| code << "# #{l.strip}" } if proto[:desc]
328
327
  unless local_vars.empty?
329
328
  code << '#'
330
329
  code << '# returns: (type | local var name)'
data/lib/nmspec/ruby.rb CHANGED
@@ -14,8 +14,8 @@ module Nmspec
14
14
  code << '# NOTE: this code is auto-generated from an nmspec file'
15
15
 
16
16
  if spec.dig(:msgr, :desc)
17
- code << '#'
18
- code << "# #{spec.dig(:msgr, :desc)}"
17
+ code << '##'
18
+ spec.dig(:msgr, :desc).lines.each{|l| code << "# #{l.strip}" }
19
19
  end
20
20
 
21
21
  code << "class #{_class_name_from_msgr_name(spec.dig(:msgr, :name))}"
@@ -27,6 +27,8 @@ module Nmspec
27
27
 
28
28
  code << _initialize
29
29
  code << ''
30
+ code << _open?
31
+ code << ''
30
32
  code << _close
31
33
  code << ''
32
34
  code << _bool_type
@@ -77,18 +79,32 @@ module Nmspec
77
79
 
78
80
  code << ' def initialize(socket, no_delay=false)'
79
81
  code << ' @socket = socket'
82
+ code << ' @open = true'
80
83
  code << ' @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if no_delay'
81
84
  code << ' end'
82
85
 
83
86
  code
84
87
  end
85
88
 
89
+ def _open?
90
+ code = []
91
+
92
+ code << ' ##'
93
+ code << ' # closes the socket inside this object'
94
+ code << ' def open?'
95
+ code << ' !!(@socket && @open)'
96
+ code << ' end'
97
+
98
+ code
99
+ end
100
+
86
101
  def _close
87
102
  code = []
88
103
 
89
104
  code << ' ##'
90
105
  code << ' # closes the socket inside this object'
91
106
  code << ' def close'
107
+ code << ' @open = false'
92
108
  code << ' @socket&.close'
93
109
  code << ' end'
94
110
 
@@ -356,7 +372,8 @@ module Nmspec
356
372
  def _proto_method(kind, proto_code, proto, local_vars, passed_params)
357
373
  code = []
358
374
 
359
- code << " # #{proto[:desc]}" if proto[:desc]
375
+ proto[:desc].lines.each{|l| code << " # #{l.strip}" } if proto[:desc]
376
+
360
377
  unless local_vars.empty?
361
378
  code << ' #'
362
379
  code << ' # returns: (type | local var name)'
@@ -1 +1 @@
1
- NMSPEC_GEM_VERSION = '1.5.0'
1
+ NMSPEC_GEM_VERSION = '1.6.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nmspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-25 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: nmspec makes it easier to describe binary messages between two network
14
14
  peers via a config file, generate their network code in a number of languages, and