supplement 2.12 → 2.14

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: cf8795db0b5ca032a21f2c9d6c094000045ba76d82bf2f02f454f3b040c7892c
4
- data.tar.gz: da36d7c646e056c082d2ac66b62a9025b33730f5baac26b412816fb8f6c37fca
3
+ metadata.gz: 87a39a1087d00c8d9b259a074c1fdd969e9a76b2fa3dda7b497b909178b16798
4
+ data.tar.gz: 41649aa614f380e9af051d9bf4d6e47d44b6c2bb359a6b774c19e42c9d714364
5
5
  SHA512:
6
- metadata.gz: 833fe634e70363e0d6ba5336f52c526b36680a2dd264c635dcd1a01ad54ddbc567a5e7080a2b8e40e1e34025fadb7a07b274e0d4a988972cd69cfd45865adff3
7
- data.tar.gz: 14eab88565eca8d88a7144d9a00f2ced1c7b9f38d6427bc96daa833a50a5fe5001bf85e1557bfc48b85f8951928dad1fa1959c58e151344474c386acf8dc944a
6
+ metadata.gz: 8219771e3227ecb9d99c1fa4eb658565dec657559181ef098cf31f8567248071c54e496c6debefeadfd05bed7ca7f5520c0ae644725be30e8e979685d6160c8b
7
+ data.tar.gz: 4488bc07f0cf1087620992e7b5c69e63b639260efd79c020957520e54e81f4f13c49e0707f3a9f4c64c99dd480b08af7fb93f9dce9f038b168dc3c2868512ac6
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.12 -- 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|
data/lib/process.c CHANGED
@@ -40,7 +40,6 @@ rb_process_renice( int argc, VALUE *argv, VALUE obj)
40
40
  else
41
41
  pid = NUM2INT( p1), prio = NUM2INT( p2);
42
42
 
43
- rb_secure(1);
44
43
  if (setpriority( PRIO_PROCESS, pid, prio) < 0)
45
44
  rb_sys_fail(0);
46
45
 
@@ -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);
@@ -1248,7 +1248,6 @@ rb_file_s_umask( int argc, VALUE *argv, VALUE file)
1248
1248
  {
1249
1249
  int omask = 0;
1250
1250
 
1251
- rb_secure( 1);
1252
1251
  switch (argc) {
1253
1252
  case 0:
1254
1253
  omask = umask( 0777);
data/lib/supplement.h CHANGED
@@ -15,7 +15,9 @@
15
15
 
16
16
  extern VALUE rb_obj_new_string( VALUE);
17
17
  extern VALUE rb_obj_nil_if( VALUE, VALUE);
18
+ #ifdef FEATURE_KERNEL_TAP
18
19
  extern VALUE rb_krn_tap( VALUE);
20
+ #endif
19
21
  extern VALUE rb_krn_tap_bang( VALUE);
20
22
  extern VALUE rb_krn_with( VALUE);
21
23
 
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.12'
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: 2020-11-10 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