supplement 2.13 → 2.15

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: 3d2e9e61df27643fc4cebe593ba085cbbfb26a3fbcc87094c5a80c9ea10b2cf2
4
- data.tar.gz: b6d88bb52fe8e8655f2df9d0c567b164fe81f5f1c935f27cfbdfd553201c1116
3
+ metadata.gz: f7d2c8a62b912713a7bd3fde72cee97061910e0ee58e24486244bf08300b53aa
4
+ data.tar.gz: f08f0bd64339672d195765b8815f9d25e26274b0253897ceb54cc5f475dbd768
5
5
  SHA512:
6
- metadata.gz: 87a0fd7dad676d4f8920506c796ca047fbcf4d3ce751377e12b5b5e4174e82e474ef405ded030289dc310a469f5b35eef517ccf00382a44f2626f32f18b63d7a
7
- data.tar.gz: d023c6da1c77ab1b56acc978da9b107d7a9c76f6988a87ec9babfb2429dd56331ef69dc10ad72bdad86bb53387a5cccb311bb0405e13dc952bac3125482ed3f4
6
+ metadata.gz: 77e7a1dc857124d246dea1254da88d575cf2284513cc2cda5ee43ef600e9bb1a498b7e6669961142c3b70259e7090edb75800a5802add6275abf80b70e6bf86f
7
+ data.tar.gz: 4ee842477fe6b142c9956267d0347bf5b9fd19da879ba52bf69f079108e3492a4a1c3674568940c20975e201a536518364f56b5c0c7ac1084392dbefb4fa69f0
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.13 -- Useful Ruby enhancements
1
+ = supplement 2.15 -- 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/mkrf_conf CHANGED
@@ -15,6 +15,7 @@ Autorake.configure {
15
15
  enable :dir_children
16
16
  if RUBY_VERSION < "1.9.2" then
17
17
  enable :array_select_bang
18
+ enable :file_size
18
19
  if RUBY_VERSION < "1.9" then
19
20
  enable :string_ord
20
21
  enable :string_clear
@@ -354,7 +354,6 @@ rb_fsstat_inspect( VALUE self)
354
354
  rb_str_append( str, rb_inspect( (*member[i].func)( self)));
355
355
  }
356
356
  rb_str_buf_cat2( str, ">");
357
- OBJ_INFECT( str, self);
358
357
 
359
358
  return str;
360
359
  }
@@ -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
@@ -328,7 +328,6 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
328
328
  val = rb_str_new5( str, RSTRING_PTR( str) + r, -n);
329
329
  }
330
330
  RSTRING_LEN( str) = r;
331
- OBJ_INFECT( val, str);
332
331
  #else
333
332
  if (n > 0) {
334
333
  r = 0;
@@ -667,11 +666,10 @@ rb_str_axe( int argc, VALUE *argv, VALUE str)
667
666
  e = rb_str_strlen( ell);
668
667
  #endif
669
668
  if (newlen > e) {
670
- ret = rb_str_substr( str, 0, newlen - e);
671
- rb_str_append( ret, ell);
669
+ ret = rb_str_substr( str, 0, newlen - e);
670
+ rb_str_append( ret, ell);
672
671
  } else
673
672
  ret = rb_str_substr( str, 0, newlen);
674
- OBJ_INFECT( ret, str);
675
673
  } else
676
674
  ret = str;
677
675
  return ret;
@@ -1189,6 +1187,9 @@ rb_hash_notempty_p( VALUE hash)
1189
1187
  * Document-class: File
1190
1188
  */
1191
1189
 
1190
+
1191
+ #ifdef FEATURE_FILE_SIZE
1192
+
1192
1193
  /*
1193
1194
  * call-seq:
1194
1195
  * size -> integer
@@ -1223,6 +1224,8 @@ rb_file_size( VALUE obj)
1223
1224
  return INT2FIX( st.st_size);
1224
1225
  }
1225
1226
 
1227
+ #endif
1228
+
1226
1229
 
1227
1230
  /*
1228
1231
  * call-seq:
@@ -1568,7 +1571,9 @@ void Init_supplement( void)
1568
1571
 
1569
1572
  rb_define_method( rb_cHash, "notempty?", rb_hash_notempty_p, 0);
1570
1573
 
1574
+ #ifdef FEATURE_FILE_SIZE
1571
1575
  rb_define_method( rb_cFile, "size", rb_file_size, 0);
1576
+ #endif
1572
1577
  rb_define_singleton_method( rb_cFile, "umask", rb_file_s_umask, -1);
1573
1578
 
1574
1579
  rb_define_singleton_method( rb_cDir, "current", rb_dir_s_current, 0);
data/lib/supplement.h CHANGED
@@ -66,7 +66,9 @@ extern VALUE rb_num_cbrt( VALUE);
66
66
 
67
67
  extern VALUE rb_hash_notempty_p( VALUE);
68
68
 
69
+ #ifdef FEATURE_FILE_SIZE
69
70
  extern VALUE rb_file_size( VALUE);
71
+ #endif
70
72
  extern VALUE rb_file_s_umask( int, VALUE *, VALUE);
71
73
  extern VALUE rb_dir_s_current( VALUE);
72
74
  extern VALUE rb_dir_s_mkdir_bang( int, VALUE *, VALUE);
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.15'
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-12-24 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