supplement 2.19 → 2.20

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: 8f12d6981c0181c08be1fa99b15c330f37c62bffba70104e9995a928980e5976
4
- data.tar.gz: 57eb53eaab47856e6d7209f1a4a236b3e4f0e4c8fd29c59f29b3ef126b0ecb1c
3
+ metadata.gz: 8787714cfe43e572f3ea76d897be6f62902bef77397723210e77cc05e9da3ffe
4
+ data.tar.gz: ba6d8f69cbdc98f9573bc67af364272cc69400935d94e21a058e2836b0c989f5
5
5
  SHA512:
6
- metadata.gz: 955e84edf5e769cf40dcf7cb476048cc8f3273b1cc32b1aa594b5b0992b3b2a3defcd272903fd09c47eb22cffa0a1037d9a8030657d62177ef21da13acf74c64
7
- data.tar.gz: dd6313b98731e9129b63924867f880bd105b2a6f2e5879d6797dfded3fc262a78a8ee23f4c8efc0d2fb9462c926cf4effe6a7294dcd56d5001578a5e7a96a1ce
6
+ metadata.gz: 6e0f5c4e4ff4c1e515be996e30ff7f8437c13079718b832233bd591a9418e55c4f939522dec7023b8d1eb18b6b8c446f82316a3c82bf26530e3f5db2e74a9352
7
+ data.tar.gz: 6811a569b15b096aeada5c792cb0474944735be1967c02a6d0f8489e56b30f191507af03e5cede067b1b27c87f9aa243030691209ef7f5370981310c0ba40e7c
data/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  = supplement Ruby Gem
2
2
 
3
3
 
4
- Copyright (C) 2009-2020, Bertram Scharpf <software@bertram-scharpf.de>.
4
+ Copyright (C) 2009-2024, Bertram Scharpf <software@bertram-scharpf.de>.
5
5
  All rights reserved.
6
6
 
7
7
  Redistribution and use in source and binary forms, with or without
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.19 -- Useful Ruby enhancements
1
+ = supplement 2.20 -- Useful Ruby enhancements
2
2
 
3
3
 
4
4
  Some simple Ruby extensions.
data/lib/mkrf_conf CHANGED
@@ -13,39 +13,17 @@ Autorake.configure {
13
13
  if RUBY_VERSION < "2.7" then
14
14
  if RUBY_VERSION < "2.6" then
15
15
  enable :dir_children
16
- if RUBY_VERSION < "1.9.2" then
17
- enable :array_select_bang
18
- enable :file_size
19
- if RUBY_VERSION < "1.9" then
20
- enable :string_ord
21
- enable :string_clear
22
- if RUBY_VERSION < "1.8.7" then
23
- enable :array_index_with_block
24
- enable :kernel_tap
25
- enable :string_start_with
26
- enable :thread_exclusive
27
- end
28
- end
29
- end
30
16
  end
31
17
  else
32
18
  enable :super_kwargs
33
19
  end
34
20
 
35
- if RUBY_VERSION < "1.9" then
36
- have_header "ruby.h"
37
- have_header "st.h"
38
- have_header "rubyio.h"
39
- have_header "re.h"
40
- have_header "rubysig.h"
41
- else
42
- have_header "ruby/ruby.h"
43
- have_header "ruby/st.h"
44
- have_header "ruby/io.h"
45
- have_header "ruby/re.h"
21
+ have_header "ruby/ruby.h"
22
+ have_header "ruby/st.h"
23
+ have_header "ruby/io.h"
24
+ have_header "ruby/re.h"
46
25
 
47
- have_function "rb_thread_wait_for"
48
- end
26
+ have_function "rb_thread_wait_for"
49
27
 
50
28
  have_function "cbrt"
51
29
 
data/lib/process.c CHANGED
@@ -5,11 +5,7 @@
5
5
 
6
6
  #include "process.h"
7
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
8
+ #include <ruby/ruby.h>
13
9
 
14
10
  #include <sys/time.h>
15
11
  #include <sys/resource.h>
@@ -5,11 +5,7 @@
5
5
  #ifndef __SUPPLEMENT_FILESYS_H__
6
6
  #define __SUPPLEMENT_FILESYS_H__
7
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
8
+ #include <ruby/ruby.h>
13
9
 
14
10
 
15
11
  extern VALUE rb_fsstat_s_alloc( VALUE);
@@ -5,11 +5,7 @@
5
5
  #ifndef __SUPPLEMENT_ITIMER_H__
6
6
  #define __SUPPLEMENT_ITIMER_H__
7
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
8
+ #include <ruby/ruby.h>
13
9
 
14
10
 
15
11
  extern VALUE rb_process_setitimer( int, VALUE *, VALUE);
@@ -4,11 +4,7 @@
4
4
 
5
5
  #include "locked.h"
6
6
 
7
- #if HAVE_HEADER_RUBYIO_H
8
- #include <rubyio.h>
9
- #elif HAVE_HEADER_RUBY_IO_H
10
- #include <ruby/io.h>
11
- #endif
7
+ #include <ruby/io.h>
12
8
 
13
9
  #include <sys/file.h>
14
10
 
@@ -32,11 +28,6 @@
32
28
  VALUE
33
29
  rb_locked_init( int argc, VALUE *argv, VALUE self)
34
30
  {
35
- #ifdef HAVE_HEADER_RUBY_H
36
- OpenFile *fptr;
37
- #else
38
- rb_io_t *fptr;
39
- #endif
40
31
  #ifdef HAVE_FUNC_RB_THREAD_WAIT_FOR
41
32
  struct timeval time;
42
33
  #endif
@@ -47,15 +38,10 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
47
38
  #else
48
39
  rb_call_super( argc, argv);
49
40
  #endif
50
- GetOpenFile( self, fptr);
51
41
 
52
- op = fptr->mode & FMODE_WRITABLE ? LOCK_EX : LOCK_SH;
42
+ op = rb_io_mode( self) & FMODE_WRITABLE ? LOCK_EX : LOCK_SH;
53
43
  op |= LOCK_NB;
54
- #ifdef HAVE_HEADER_RUBY_H
55
- while (flock( fileno( fptr->f), op) < 0) {
56
- #else
57
- while (flock( fptr->fd, op) < 0) {
58
- #endif
44
+ while (flock( rb_io_descriptor( self), op) < 0) {
59
45
  static ID id_lock_failed = 0;
60
46
 
61
47
  switch (errno) {
@@ -81,11 +67,7 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
81
67
  }
82
68
  break;
83
69
  default:
84
- #ifdef HAVE_HEADER_RUBY_H
85
- rb_sys_fail( fptr->path);
86
- #else
87
- rb_sys_fail_str( fptr->pathv);
88
- #endif
70
+ rb_sys_fail_str( rb_io_path( self));
89
71
  break;
90
72
  }
91
73
  }
@@ -103,18 +85,7 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
103
85
  VALUE
104
86
  rb_locked_close( VALUE self)
105
87
  {
106
- #ifdef HAVE_HEADER_RUBY_H
107
- OpenFile *fptr;
108
- #else
109
- rb_io_t *fptr;
110
- #endif
111
-
112
- GetOpenFile( self, fptr);
113
- #ifdef HAVE_HEADER_RUBY_H
114
- flock( fileno( fptr->f), LOCK_UN);
115
- #else
116
- flock( fptr->fd, LOCK_UN);
117
- #endif
88
+ flock( rb_io_descriptor( self), LOCK_UN);
118
89
  rb_call_super( 0, NULL);
119
90
  return Qnil;
120
91
  }
@@ -5,11 +5,7 @@
5
5
  #ifndef __SUPPLEMENT_FILESYS_H__
6
6
  #define __SUPPLEMENT_FILESYS_H__
7
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
8
+ #include <ruby/ruby.h>
13
9
 
14
10
  VALUE rb_locked_init( int argc, VALUE *argv, VALUE self);
15
11
  VALUE rb_locked_close( VALUE self);
@@ -2,11 +2,7 @@
2
2
  * supplement/socket.c -- Socket methods
3
3
  */
4
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
5
+ #include <ruby/io.h>
10
6
 
11
7
 
12
8
  static ID id_accept_orig;
@@ -5,11 +5,7 @@
5
5
  #ifndef __SUPPLEMENT_SOCKET_H__
6
6
  #define __SUPPLEMENT_SOCKET_H__
7
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
8
+ #include <ruby/ruby.h>
13
9
 
14
10
 
15
11
  extern VALUE rb_socket_accept( VALUE);
@@ -4,11 +4,7 @@
4
4
 
5
5
  #include "terminal.h"
6
6
 
7
- #if HAVE_HEADER_RUBYIO_H
8
- #include <rubyio.h>
9
- #elif HAVE_HEADER_RUBY_IO_H
10
- #include <ruby/io.h>
11
- #endif
7
+ #include <ruby/io.h>
12
8
 
13
9
  #include <sys/ioctl.h>
14
10
  #include <termios.h>
@@ -17,11 +13,7 @@ static VALUE io_unget( VALUE);
17
13
  static VALUE io_reset( VALUE);
18
14
 
19
15
 
20
- #ifndef RUBY_VM
21
- #define RB_SYS_FAIL( fptr) rb_sys_fail( ((OpenFile *) fptr)->path);
22
- #else
23
- #define RB_SYS_FAIL( fptr) rb_sys_fail_str( ((rb_io_t *) fptr)->pathv);
24
- #endif
16
+ #define RB_SYS_FAIL( io) rb_sys_fail_str( rb_io_path( io));
25
17
 
26
18
  /*
27
19
  * call-seq:
@@ -35,30 +27,20 @@ static VALUE io_reset( VALUE);
35
27
  VALUE
36
28
  rb_io_unget( int argc, VALUE *argv, VALUE io)
37
29
  {
38
- #ifndef RUBY_VM
39
- OpenFile *fptr;
40
- #else
41
- rb_io_t *fptr;
42
- #endif
43
30
  int fd;
44
31
  struct termios oldtio, newtio;
45
32
  void *v[5];
46
33
 
47
- GetOpenFile( io, fptr);
48
- #ifndef RUBY_VM
49
- fd = fileno( fptr->f);
50
- #else
51
- fd = fptr->fd;
52
- #endif
34
+ fd = rb_io_descriptor( io);
53
35
 
54
36
  if (tcgetattr( fd, &oldtio) < 0)
55
- RB_SYS_FAIL( fptr);
37
+ RB_SYS_FAIL( io);
56
38
  newtio = oldtio;
57
39
  newtio.c_iflag &= ~ICRNL;
58
40
  if (tcsetattr( fd, TCSANOW, &newtio) < 0)
59
- RB_SYS_FAIL( fptr);
41
+ RB_SYS_FAIL( io);
60
42
 
61
- v[0] = &fd, v[1] = fptr, v[2] = &oldtio,
43
+ v[0] = &fd, v[1] = (void *) io, v[2] = &oldtio,
62
44
  v[3] = &argc, v[4] = (void *) argv;
63
45
  return rb_ensure( io_unget, (VALUE) v, io_reset, (VALUE) v);
64
46
  }
@@ -80,7 +62,7 @@ io_unget( VALUE v)
80
62
  p = RSTRING_PTR(str);
81
63
  for (i = RSTRING_LEN(str); i; --i, ++p)
82
64
  if (ioctl( *(int *) vp[0], TIOCSTI, p) < 0)
83
- RB_SYS_FAIL( vp[1]);
65
+ RB_SYS_FAIL( (VALUE) vp[1]);
84
66
  }
85
67
  return Qnil;
86
68
  }
@@ -91,7 +73,7 @@ io_reset( VALUE v)
91
73
  void **vp = (void **) v;
92
74
 
93
75
  if (tcsetattr( *(int *) vp[0], TCSANOW, (struct termios *) vp[2]) < 0)
94
- RB_SYS_FAIL( vp[1]);
76
+ RB_SYS_FAIL( (VALUE) vp[1]);
95
77
 
96
78
  return Qnil;
97
79
  }
@@ -109,24 +91,14 @@ io_reset( VALUE v)
109
91
  VALUE
110
92
  rb_io_wingeom( VALUE self)
111
93
  {
112
- #ifndef RUBY_VM
113
- OpenFile *fptr;
114
- #else
115
- rb_io_t *fptr;
116
- #endif
117
94
  int fd;
118
95
  struct winsize w;
119
96
  VALUE r;
120
97
 
121
- GetOpenFile( self, fptr);
122
- #ifndef RUBY_VM
123
- fd = fileno( fptr->f);
124
- #else
125
- fd = fptr->fd;
126
- #endif
98
+ fd = rb_io_descriptor( self);
127
99
 
128
100
  if (ioctl( fd, TIOCGWINSZ, &w) < 0)
129
- RB_SYS_FAIL( fptr);
101
+ RB_SYS_FAIL( self);
130
102
  r = rb_ary_new2( 4);
131
103
  rb_ary_store( r, 0, INT2NUM( w.ws_col));
132
104
  rb_ary_store( r, 1, INT2NUM( w.ws_row));
@@ -5,11 +5,7 @@
5
5
  #ifndef __SUPPLEMENT_TERMINAL_H__
6
6
  #define __SUPPLEMENT_TERMINAL_H__
7
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
8
+ #include <ruby/ruby.h>
13
9
 
14
10
 
15
11
  extern VALUE rb_io_unget( int, VALUE *, VALUE);
data/lib/supplement.c CHANGED
@@ -6,21 +6,9 @@
6
6
 
7
7
  #include "process.h"
8
8
 
9
- #if HAVE_HEADER_ST_H
10
- #include <st.h>
11
- #elif HAVE_HEADER_RUBY_ST_H
12
- #include <ruby/st.h>
13
- #endif
14
- #if HAVE_HEADER_RUBYIO_H
15
- #include <rubyio.h>
16
- #elif HAVE_HEADER_RUBY_IO_H
17
- #include <ruby/io.h>
18
- #endif
19
- #if HAVE_HEADER_RE_H
20
- #include <re.h>
21
- #elif HAVE_HEADER_RUBY_RE_H
22
- #include <ruby/re.h>
23
- #endif
9
+ #include <ruby/st.h>
10
+ #include <ruby/io.h>
11
+ #include <ruby/re.h>
24
12
 
25
13
  #ifdef FEATURE_THREAD_EXCLUSIVE
26
14
  #ifdef HAVE_HEADER_RUBYSIG_H
@@ -29,13 +17,6 @@
29
17
  #endif
30
18
 
31
19
 
32
- #ifdef HAVE_HEADER_RUBY_H
33
- /* Oh what a bug! */
34
- #define R_MATCH( obj) RMATCH( obj)
35
- #else
36
- #endif
37
-
38
-
39
20
  static VALUE supplement_index_blk( VALUE);
40
21
  static VALUE supplement_index_ref( VALUE, VALUE);
41
22
  static VALUE supplement_rindex_blk( VALUE);
@@ -44,10 +25,6 @@ static VALUE supplement_rindex_ref( VALUE, VALUE);
44
25
  static VALUE supplement_index_val( VALUE, VALUE);
45
26
  static VALUE supplement_rindex_val( VALUE, VALUE);
46
27
  #endif
47
- #ifdef FEATURE_ARRAY_SELECT_BANG
48
- static VALUE supplement_reject( VALUE);
49
- static VALUE supplement_invert_yield( VALUE);
50
- #endif
51
28
  static VALUE supplement_do_unumask( VALUE);
52
29
  #ifdef FEATURE_THREAD_EXCLUSIVE
53
30
  static VALUE bsruby_set_thread_critical( VALUE);
@@ -58,9 +35,6 @@ static VALUE bsruby_set_thread_critical( VALUE);
58
35
  static ID id_delete_at;
59
36
  static ID id_cmp;
60
37
  static ID id_eqq;
61
- #ifdef FEATURE_ARRAY_SELECT_BANG
62
- static ID id_reject_bang;
63
- #endif
64
38
  static ID id_mkdir;
65
39
  static ID id_index;
66
40
 
@@ -189,6 +163,33 @@ rb_krn_with( VALUE obj)
189
163
  }
190
164
 
191
165
 
166
+ /*
167
+ * Document-class: Module
168
+ */
169
+
170
+ /*
171
+ * call-seq:
172
+ * plain_name -> str
173
+ *
174
+ * The last part of a `::`-separated Module name path.
175
+ */
176
+
177
+ VALUE
178
+ rb_module_plain_name( VALUE cls)
179
+ {
180
+ VALUE n;
181
+ VALUE i;
182
+
183
+ n = rb_str_dup( rb_funcall( cls, rb_intern( "name"), 0));
184
+ i = rb_funcall( n, rb_intern( "rindex"), 1, rb_str_new( "::", 2));
185
+ if (!NIL_P( i)) {
186
+ i = rb_funcall( i, rb_intern( "+"), 1, INT2FIX( 2));
187
+ rb_funcall( n, rb_intern( "slice!"), 2, INT2FIX( 0), i);
188
+ }
189
+ return n;
190
+ }
191
+
192
+
192
193
  /*
193
194
  * Document-class: NilClass
194
195
  */
@@ -301,11 +302,7 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
301
302
  int l;
302
303
  int r;
303
304
 
304
- #ifdef HAVE_HEADER_RUBY_H
305
- n = l = RSTRING_LEN( str);
306
- #else
307
305
  n = l = rb_str_strlen( str);
308
- #endif
309
306
  if (rb_scan_args( argc, argv, "01", &val) == 1) {
310
307
  if (!NIL_P( val)) {
311
308
  int v = NUM2INT( val);
@@ -318,17 +315,6 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
318
315
  }
319
316
  }
320
317
  rb_str_modify( str);
321
- #ifdef HAVE_HEADER_RUBY_H
322
- if (n > 0) {
323
- r = l - n;
324
- val = rb_str_new5( str, RSTRING_PTR( str), n);
325
- memmove( RSTRING_PTR( str), RSTRING_PTR( str) + n, r);
326
- } else {
327
- r = l + n;
328
- val = rb_str_new5( str, RSTRING_PTR( str) + r, -n);
329
- }
330
- RSTRING_LEN( str) = r;
331
- #else
332
318
  if (n > 0) {
333
319
  r = 0;
334
320
  } else if (n < 0) {
@@ -339,7 +325,6 @@ rb_str_eat( int argc, VALUE *argv, VALUE str)
339
325
  val = rb_str_substr( str, r, n);
340
326
  if (!NIL_P(val))
341
327
  rb_str_update( str, r, n, rb_str_new( NULL, 0));
342
- #endif
343
328
  return val;
344
329
  }
345
330
 
@@ -361,27 +346,17 @@ VALUE
361
346
  rb_str_cut_bang( VALUE str, VALUE len)
362
347
  {
363
348
  int l;
364
- #ifdef HAVE_HEADER_RUBY_H
365
- #else
366
349
  int n;
367
- #endif
368
350
 
369
351
  rb_str_modify( str);
370
352
  l = NUM2INT( len);
371
353
  if (l < 0)
372
354
  l = 0;
373
- #ifdef HAVE_HEADER_RUBY_H
374
- if (l < RSTRING_LEN( str)) {
375
- RSTRING_LEN( str) = l;
376
- return str;
377
- }
378
- #else
379
355
  n = rb_str_strlen( str);
380
356
  if (l < n) {
381
357
  rb_str_update( str, l, n - l, rb_str_new( NULL, 0));
382
358
  return str;
383
359
  }
384
- #endif
385
360
  return Qnil;
386
361
  }
387
362
 
@@ -449,11 +424,7 @@ rb_str_rest( int argc, VALUE *argv, VALUE str)
449
424
  beg = rb_scan_args( argc, argv, "01", &n) == 1 ? NUM2LONG( n) : 1;
450
425
  if (beg < 0)
451
426
  beg = 0;
452
- #ifdef HAVE_HEADER_RUBY_H
453
- l = RSTRING_LEN( str);
454
- #else
455
427
  l = rb_str_strlen( str);
456
- #endif
457
428
  return rb_str_substr( str, beg, l - beg);
458
429
  }
459
430
 
@@ -474,11 +445,7 @@ rb_str_tail( int argc, VALUE *argv, VALUE str)
474
445
  long l, beg, len;
475
446
 
476
447
  len = rb_scan_args( argc, argv, "01", &n) == 1 ? NUM2LONG( n) : 1;
477
- #ifdef HAVE_HEADER_RUBY_H
478
- l = RSTRING_LEN( str);
479
- #else
480
448
  l = rb_str_strlen( str);
481
- #endif
482
449
  beg = l - len;
483
450
  if (beg < 0)
484
451
  beg = 0, len = l;
@@ -541,11 +508,8 @@ rb_str_starts_with_p( VALUE str, VALUE oth)
541
508
  char *s, *o;
542
509
  VALUE ost;
543
510
 
544
- #ifdef HAVE_HEADER_RUBY_H
545
- #else
546
511
  if (!rb_str_comparable( str, oth))
547
512
  return Qnil;
548
- #endif
549
513
  ost = rb_string_value( &oth);
550
514
  i = RSTRING_LEN( ost);
551
515
  if (i > RSTRING_LEN( str))
@@ -556,11 +520,7 @@ rb_str_starts_with_p( VALUE str, VALUE oth)
556
520
  if (*s != *o)
557
521
  return Qnil;
558
522
  }
559
- #ifdef HAVE_HEADER_RUBY_H
560
- return INT2FIX( RSTRING_LEN( ost));
561
- #else
562
523
  return INT2FIX( rb_str_strlen( ost));
563
- #endif
564
524
  }
565
525
 
566
526
 
@@ -584,11 +544,8 @@ rb_str_ends_with_p( VALUE str, VALUE oth)
584
544
  char *s, *o;
585
545
  VALUE ost;
586
546
 
587
- #ifdef HAVE_HEADER_RUBY_H
588
- #else
589
547
  if (!rb_str_comparable( str, oth))
590
548
  return Qnil;
591
- #endif
592
549
  ost = rb_string_value( &oth);
593
550
  i = RSTRING_LEN( ost);
594
551
  if (i > RSTRING_LEN( str))
@@ -598,11 +555,7 @@ rb_str_ends_with_p( VALUE str, VALUE oth)
598
555
  for (; i; i--)
599
556
  if (*--s != *--o)
600
557
  return Qnil;
601
- #ifdef HAVE_HEADER_RUBY_H
602
- return INT2FIX( RSTRING_LEN( str) - RSTRING_LEN( ost));
603
- #else
604
558
  return INT2FIX( rb_str_strlen( str) - rb_str_strlen( ost));
605
- #endif
606
559
  }
607
560
 
608
561
  #ifdef FEATURE_STRING_ORD
@@ -650,21 +603,13 @@ rb_str_axe( int argc, VALUE *argv, VALUE str)
650
603
  if (newlen < 0)
651
604
  return Qnil;
652
605
 
653
- #ifdef HAVE_HEADER_RUBY_H
654
- oldlen = RSTRING_LEN( str);
655
- #else
656
606
  oldlen = rb_str_strlen( str);
657
- #endif
658
607
  if (newlen < oldlen) {
659
608
  VALUE ell;
660
609
  long e;
661
610
 
662
611
  ell = rb_str_new2( "...");
663
- #ifdef HAVE_HEADER_RUBY_H
664
- e = RSTRING_LEN( ell);
665
- #else
666
612
  e = rb_str_strlen( ell);
667
- #endif
668
613
  if (newlen > e) {
669
614
  ret = rb_str_substr( str, 0, newlen - e);
670
615
  rb_str_append( ret, ell);
@@ -1124,42 +1069,6 @@ supplement_rindex_val( VALUE ary, VALUE val)
1124
1069
 
1125
1070
  #endif
1126
1071
 
1127
- #ifdef FEATURE_ARRAY_SELECT_BANG
1128
-
1129
- /*
1130
- * Document-method: select!
1131
- *
1132
- * call-seq:
1133
- * select! { |x| ... } -> ary
1134
- *
1135
- * Remove all items for that the block returns +nil+ or +false+.
1136
- *
1137
- */
1138
-
1139
- VALUE
1140
- rb_ary_select_bang( VALUE self)
1141
- {
1142
- return rb_iterate( &supplement_reject, self,
1143
- &supplement_invert_yield, Qnil);
1144
- }
1145
-
1146
- VALUE
1147
- supplement_reject( VALUE obj)
1148
- {
1149
- if (!id_reject_bang)
1150
- id_reject_bang = rb_intern( "reject!");
1151
- return rb_funcall( obj, id_reject_bang, 0);
1152
- }
1153
-
1154
- VALUE
1155
- supplement_invert_yield( VALUE elem)
1156
- {
1157
- return NIL_P( rb_yield( elem)) ? Qtrue : Qfalse;
1158
- }
1159
-
1160
- #endif
1161
-
1162
-
1163
1072
 
1164
1073
  /*
1165
1074
  * Document-class: Hash
@@ -1187,51 +1096,11 @@ rb_hash_notempty_p( VALUE hash)
1187
1096
  * Document-class: File
1188
1097
  */
1189
1098
 
1190
-
1191
- #ifdef FEATURE_FILE_SIZE
1192
-
1193
1099
  /*
1194
1100
  * call-seq:
1195
- * size -> integer
1196
- *
1197
- * Returns <code>file</code>'s size. A shortcut for
1198
- * <code>file.stat.size</code>. This constitutes consistency with
1199
- * <code>StringIO</code>.
1200
- *
1201
- * file.size #=> 16384
1202
- */
1203
-
1204
- VALUE
1205
- rb_file_size( VALUE obj)
1206
- {
1207
- #ifdef HAVE_HEADER_RUBY_H
1208
- OpenFile *fptr;
1209
- #else
1210
- rb_io_t *fptr;
1211
- #endif
1212
- struct stat st;
1213
-
1214
- GetOpenFile( obj, fptr);
1215
- #ifdef HAVE_HEADER_RUBY_H
1216
- if (fstat( fileno( fptr->f), &st) == -1) {
1217
- rb_sys_fail( fptr->path);
1218
- }
1219
- #else
1220
- if (fstat( fptr->fd, &st) == -1) {
1221
- rb_sys_fail_str( fptr->pathv);
1222
- }
1223
- #endif
1224
- return INT2FIX( st.st_size);
1225
- }
1226
-
1227
- #endif
1228
-
1229
-
1230
- /*
1231
- * call-seq:
1232
- * umask() -> int
1233
- * umask( int) -> int
1234
- * umask( int) { ... } -> obj
1101
+ * File.umask() -> int
1102
+ * File.umask( int) -> int
1103
+ * File.umask( int) { ... } -> obj
1235
1104
  *
1236
1105
  * Returns the current umask value for this process. If the optional
1237
1106
  * argument is given, set the umask to that value and return the
@@ -1283,7 +1152,7 @@ supplement_do_unumask( VALUE v)
1283
1152
 
1284
1153
  /*
1285
1154
  * call-seq:
1286
- * current() -> dir
1155
+ * Dir.current() -> dir
1287
1156
  *
1288
1157
  * Current directory as a Dir object.
1289
1158
  *
@@ -1299,7 +1168,7 @@ rb_dir_s_current( VALUE dir)
1299
1168
 
1300
1169
  /*
1301
1170
  * call-seq:
1302
- * mkdir!( path, modes = nil) -> str or nil
1171
+ * Dir.mkdir!( path, modes = nil) -> str or nil
1303
1172
  *
1304
1173
  * Make a directory and all subdirectories if needed.
1305
1174
  *
@@ -1548,6 +1417,8 @@ void Init_supplement( void)
1548
1417
  rb_define_method( rb_mKernel, "tap!", rb_krn_tap_bang, 0);
1549
1418
  rb_define_method( rb_mKernel, "with", rb_krn_with, 0);
1550
1419
 
1420
+ rb_define_method( rb_cModule, "plain_name", rb_module_plain_name, 0);
1421
+
1551
1422
  rb_define_method( rb_cNilClass, "notempty?", rb_nil_notempty_p, 0);
1552
1423
  rb_define_method( rb_cNilClass, "nonzero?", rb_nil_notempty_p, 0);
1553
1424
  rb_define_method( rb_cNilClass, "each_line", rb_nil_each_line, 0);
@@ -1591,15 +1462,9 @@ void Init_supplement( void)
1591
1462
  rb_define_method( rb_cArray, "index", rb_ary_index, -1);
1592
1463
  rb_define_method( rb_cArray, "rindex", rb_ary_rindex, -1);
1593
1464
  #endif
1594
- #ifdef FEATURE_ARRAY_SELECT_BANG
1595
- rb_define_method( rb_cArray, "select!", rb_ary_select_bang, 0);
1596
- #endif
1597
1465
 
1598
1466
  rb_define_method( rb_cHash, "notempty?", rb_hash_notempty_p, 0);
1599
1467
 
1600
- #ifdef FEATURE_FILE_SIZE
1601
- rb_define_method( rb_cFile, "size", rb_file_size, 0);
1602
- #endif
1603
1468
  rb_define_singleton_method( rb_cFile, "umask", rb_file_s_umask, -1);
1604
1469
 
1605
1470
  rb_define_singleton_method( rb_cDir, "current", rb_dir_s_current, 0);
@@ -1628,9 +1493,6 @@ void Init_supplement( void)
1628
1493
  id_delete_at = rb_intern( "delete_at");
1629
1494
  id_cmp = rb_intern( "<=>");
1630
1495
  id_eqq = 0;
1631
- #ifdef FEATURE_ARRAY_SELECT_BANG
1632
- id_reject_bang = 0;
1633
- #endif
1634
1496
  id_mkdir = 0;
1635
1497
  id_index = 0;
1636
1498
 
data/lib/supplement.h CHANGED
@@ -6,11 +6,7 @@
6
6
  #ifndef __SUPPELEMENT_H__
7
7
  #define __SUPPELEMENT_H__
8
8
 
9
- #if HAVE_HEADER_RUBY_H
10
- #include <ruby.h>
11
- #elif HAVE_HEADER_RUBY_RUBY_H
12
- #include <ruby/ruby.h>
13
- #endif
9
+ #include <ruby/ruby.h>
14
10
 
15
11
 
16
12
  extern VALUE rb_obj_new_string( VALUE);
@@ -21,6 +17,8 @@ extern VALUE rb_krn_tap( VALUE);
21
17
  extern VALUE rb_krn_tap_bang( VALUE);
22
18
  extern VALUE rb_krn_with( VALUE);
23
19
 
20
+ extern VALUE rb_module_plain_name( VALUE);
21
+
24
22
  extern VALUE rb_nil_notempty_p( VALUE);
25
23
  extern VALUE rb_nil_each_line( VALUE);
26
24
 
@@ -60,15 +58,9 @@ extern VALUE rb_ary_rpick( int, VALUE *, VALUE);
60
58
  extern VALUE rb_ary_index( int, VALUE *, VALUE);
61
59
  extern VALUE rb_ary_rindex( int, VALUE *, VALUE);
62
60
  #endif
63
- #ifdef FEATURE_ARRAY_SELECT_BANG
64
- extern VALUE rb_ary_select_bang( VALUE);
65
- #endif
66
61
 
67
62
  extern VALUE rb_hash_notempty_p( VALUE);
68
63
 
69
- #ifdef FEATURE_FILE_SIZE
70
- extern VALUE rb_file_size( VALUE);
71
- #endif
72
64
  extern VALUE rb_file_s_umask( int, VALUE *, VALUE);
73
65
  extern VALUE rb_dir_s_current( VALUE);
74
66
  extern VALUE rb_dir_s_mkdir_bang( int, VALUE *, VALUE);
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supplement
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.19'
4
+ version: '2.20'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-04 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '13.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: autorake
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: '2'
33
+ version: '2.18'
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '2'
40
+ version: '2.18'
27
41
  description: 'Simple methods that didn''t manage to become part of standard Ruby.
28
42
 
29
43
  '
@@ -73,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - ">="
75
89
  - !ruby/object:Gem::Version
76
- version: '0'
90
+ version: 2.0.0
77
91
  required_rubygems_version: !ruby/object:Gem::Requirement
78
92
  requirements:
79
93
  - - ">="
@@ -81,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
95
  version: '0'
82
96
  requirements:
83
97
  - Ruby and the autorake gem
84
- rubygems_version: 3.5.6
98
+ rubygems_version: 3.5.14
85
99
  signing_key:
86
100
  specification_version: 4
87
101
  summary: Simple Ruby extensions