supplement 2.13 → 2.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d2e9e61df27643fc4cebe593ba085cbbfb26a3fbcc87094c5a80c9ea10b2cf2
4
- data.tar.gz: b6d88bb52fe8e8655f2df9d0c567b164fe81f5f1c935f27cfbdfd553201c1116
3
+ metadata.gz: 87a39a1087d00c8d9b259a074c1fdd969e9a76b2fa3dda7b497b909178b16798
4
+ data.tar.gz: 41649aa614f380e9af051d9bf4d6e47d44b6c2bb359a6b774c19e42c9d714364
5
5
  SHA512:
6
- metadata.gz: 87a0fd7dad676d4f8920506c796ca047fbcf4d3ce751377e12b5b5e4174e82e474ef405ded030289dc310a469f5b35eef517ccf00382a44f2626f32f18b63d7a
7
- data.tar.gz: d023c6da1c77ab1b56acc978da9b107d7a9c76f6988a87ec9babfb2429dd56331ef69dc10ad72bdad86bb53387a5cccb311bb0405e13dc952bac3125482ed3f4
6
+ metadata.gz: 8219771e3227ecb9d99c1fa4eb658565dec657559181ef098cf31f8567248071c54e496c6debefeadfd05bed7ca7f5520c0ae644725be30e8e979685d6160c8b
7
+ data.tar.gz: 4488bc07f0cf1087620992e7b5c69e63b639260efd79c020957520e54e81f4f13c49e0707f3a9f4c64c99dd480b08af7fb93f9dce9f038b168dc3c2868512ac6
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.13 -- Useful Ruby enhancements
1
+ = supplement 2.14 -- Useful Ruby enhancements
2
2
 
3
3
 
4
4
  Some simple Ruby extensions.
@@ -59,6 +59,7 @@ Now here it is where I can just point to.
59
59
  * Struct.[]
60
60
  * Integer.roman
61
61
  * Date.easter
62
+ * TCPServer.accept with a code block
62
63
  * File system stats
63
64
  * Process.renice
64
65
  * Interval timer
data/lib/Rakefile CHANGED
@@ -17,6 +17,7 @@ DLs = {
17
17
  "supplement/filesys.so" => %w(supplement/filesys.o),
18
18
  "supplement/itimer.so" => %w(supplement/itimer.o),
19
19
  "supplement/terminal.so" => %w(supplement/terminal.o),
20
+ "supplement/socket.so" => %w(supplement/socket.o),
20
21
  }
21
22
 
22
23
  DLs.each { |k,v|
@@ -59,8 +59,8 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
59
59
  static ID id_lock_failed = 0;
60
60
 
61
61
  switch (errno) {
62
- case EINTR:
63
- break;
62
+ case EINTR:
63
+ break;
64
64
  case EAGAIN:
65
65
  case EACCES:
66
66
  #if defined( EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
@@ -0,0 +1,53 @@
1
+ /*
2
+ * supplement/socket.c -- Socket methods
3
+ */
4
+
5
+ #if HAVE_HEADER_RUBYIO_H
6
+ #include <rubyio.h>
7
+ #elif HAVE_HEADER_RUBY_IO_H
8
+ #include <ruby/io.h>
9
+ #endif
10
+
11
+
12
+ static ID id_accept_orig;
13
+ static ID id_close;
14
+
15
+ static VALUE socket_close( VALUE);
16
+
17
+
18
+ /*
19
+ * call-seq:
20
+ * socket.accept() { |socket| ... } -> obj
21
+ *
22
+ * Accept a connection and yield it to a block, if given.
23
+ */
24
+
25
+ VALUE
26
+ rb_socket_accept( VALUE socket)
27
+ {
28
+ VALUE a = rb_funcall( socket, id_accept_orig, 0);
29
+ return rb_block_given_p() ?
30
+ rb_ensure( rb_yield, a, socket_close, a) : a;
31
+ }
32
+
33
+ VALUE
34
+ socket_close( VALUE v)
35
+ {
36
+ return rb_funcall( v, id_close, 0);
37
+ }
38
+
39
+
40
+ void Init_socket( void)
41
+ {
42
+ VALUE rb_cTCPServer;
43
+
44
+ id_accept_orig = rb_intern( "accept_orig");
45
+ id_close = rb_intern( "close");
46
+
47
+ rb_require( "socket");
48
+ rb_cTCPServer = rb_const_get( rb_cObject, rb_intern( "TCPServer"));
49
+
50
+ rb_define_alias( rb_cTCPServer, "accept_orig", "accept");
51
+ rb_define_method( rb_cTCPServer, "accept", rb_socket_accept, 0);
52
+ }
53
+
@@ -0,0 +1,21 @@
1
+ /*
2
+ * supplement/socket.h -- Socket methods
3
+ */
4
+
5
+ #ifndef __SUPPLEMENT_SOCKET_H__
6
+ #define __SUPPLEMENT_SOCKET_H__
7
+
8
+ #if HAVE_HEADER_RUBY_H
9
+ #include <ruby.h>
10
+ #elif HAVE_HEADER_RUBY_RUBY_H
11
+ #include <ruby/ruby.h>
12
+ #endif
13
+
14
+
15
+ extern VALUE rb_socket_accept( VALUE);
16
+
17
+
18
+ extern void Init_socket( void);
19
+
20
+ #endif
21
+
data/lib/supplement.c CHANGED
@@ -667,8 +667,8 @@ rb_str_axe( int argc, VALUE *argv, VALUE str)
667
667
  e = rb_str_strlen( ell);
668
668
  #endif
669
669
  if (newlen > e) {
670
- ret = rb_str_substr( str, 0, newlen - e);
671
- rb_str_append( ret, ell);
670
+ ret = rb_str_substr( str, 0, newlen - e);
671
+ rb_str_append( ret, ell);
672
672
  } else
673
673
  ret = rb_str_substr( str, 0, newlen);
674
674
  OBJ_INFECT( ret, str);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supplement
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.13'
4
+ version: '2.14'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-18 00:00:00.000000000 Z
11
+ date: 2022-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autorake
@@ -53,6 +53,8 @@ files:
53
53
  - lib/supplement/locked.c
54
54
  - lib/supplement/locked.h
55
55
  - lib/supplement/roman.rb
56
+ - lib/supplement/socket.c
57
+ - lib/supplement/socket.h
56
58
  - lib/supplement/terminal.c
57
59
  - lib/supplement/terminal.h
58
60
  homepage: http://www.bertram-scharpf.de/software/supplement