supplement 2.32 → 2.33

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: 9a7108dafb3707ef51a08d12ac718a6c00358bae7b3f98e32448886f8d9dd29b
4
- data.tar.gz: d389cf607de0a21d6b4cd3a02550a25200f68205cbaad22ed442025123420bed
3
+ metadata.gz: 9a1c02a87bc3156c7468abf0618da0dc18769fc09335605638e62515ebfc4b3c
4
+ data.tar.gz: e73d0a28b4f10dafdaea31aa8aa55f85e29db0ecb5d392512ad0429a280a1e1d
5
5
  SHA512:
6
- metadata.gz: e4006b5753eff8a4cce364b2e26a0717493948177e2476818113b7a62070fdf69ff71bc72105a14cf7d02a639471a282e99181e7f702f618678db63483dc7e1e
7
- data.tar.gz: ae9e62b121909a5cdfb63abea92a3abd2ca71bf887a6364806dd2af55c7e44796bfcaa09cafb326f14f27ffa84332817630c8fb4aced20995220d4b43af0f5b5
6
+ metadata.gz: ca470be4d0d6f934d0adc74d249b52a1c682a38928848d03ea78ba3ef564cae49f2de61540b6e886fc8e08340085dacfd55d1516a9eab6bbc2c6dc3bfa227c79
7
+ data.tar.gz: 2c00ea6c30f2a6aa3b7f456d05c8f58895b12821590f928263e32e411d151ffe7e702b9b090cb954d677a628a5fc161217675b2a3496ae472230286300a3ca6a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # supplement 2.32 -- Useful Ruby enhancements
1
+ # supplement 2.33 -- Useful Ruby enhancements
2
2
 
3
3
  Some simple Ruby extensions.
4
4
 
data/lib/mkrf_conf CHANGED
@@ -11,7 +11,7 @@ Autorake.configure {
11
11
  extending_ruby
12
12
 
13
13
  if RUBY_VERSION < "3.3" then # Always false after March 2026
14
- enable :some_calls
14
+ # enable :old_feature
15
15
  end
16
16
 
17
17
  have_header "ruby/ruby.h"
data/lib/supplement.c CHANGED
@@ -552,6 +552,43 @@ rb_str_ends_with_p( int argc, VALUE *argv, VALUE str)
552
552
  }
553
553
 
554
554
 
555
+ /*
556
+ * call-seq:
557
+ * notempy?( oth) -> nil or sym
558
+ *
559
+ * Checks whether the head is <code>oth</code>. Returns length of
560
+ * <code>oth</code> when matching.
561
+ *
562
+ * :"sys-apps".starts_with?( "sys-") #=> 4
563
+ *
564
+ * Caution! The Ruby 1.9.3 method #start_with? (note the missing s)
565
+ * just returns +true+ or +false+. Mnemonics: "s" = prepare for
566
+ * <code>#slice</code>.
567
+ */
568
+
569
+
570
+ /*
571
+ * call-seq:
572
+ * notempty? -> nil or self
573
+ *
574
+ * Returns <code>self</code> if and only if <code>str</code> is not
575
+ * empty, <code>nil</code> otherwise.
576
+ *
577
+ * :hello.notempty? #=> :hello
578
+ * :"".notempty? #=> nil
579
+ *
580
+ * This seems to be quite useless. Its only purpose is to avoid either type
581
+ * detection or error catching if other objects are asked whether they're not
582
+ * empty.
583
+ */
584
+
585
+ VALUE
586
+ rb_sym_notempty_p( VALUE sym)
587
+ {
588
+ return NUM2LONG( rb_funcall( sym, rb_intern( "length"), 0)) ? sym : Qnil;
589
+ }
590
+
591
+
555
592
  /*
556
593
  * call-seq:
557
594
  * starts_with?( oth) -> nil or int
@@ -1219,6 +1256,7 @@ void Init_supplement( void)
1219
1256
  rb_define_method( rb_cString, "axe!", rb_str_axe_bang, -1);
1220
1257
  rb_define_method( rb_cString, "starts_with?", rb_str_starts_with_p, -1);
1221
1258
  rb_define_method( rb_cString, "ends_with?", rb_str_ends_with_p, -1);
1259
+ rb_define_method( rb_cSymbol, "notempty?", rb_sym_notempty_p, 0);
1222
1260
  rb_define_method( rb_cSymbol, "starts_with?", rb_sym_starts_with_p, -1);
1223
1261
  rb_define_method( rb_cSymbol, "ends_with?", rb_sym_ends_with_p, -1);
1224
1262
 
data/lib/supplement.h CHANGED
@@ -29,6 +29,7 @@ extern VALUE rb_str_axe( int, VALUE *, VALUE);
29
29
  extern VALUE rb_str_axe_bang( int, VALUE *, VALUE);
30
30
  extern VALUE rb_str_starts_with_p( int argc, VALUE *argv, VALUE);
31
31
  extern VALUE rb_str_ends_with_p( int argc, VALUE *argv, VALUE);
32
+ extern VALUE rb_sym_notempty_p( VALUE);
32
33
  extern VALUE rb_sym_starts_with_p( int argc, VALUE *argv, VALUE);
33
34
  extern VALUE rb_sym_ends_with_p( int argc, VALUE *argv, VALUE);
34
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supplement
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.32'
4
+ version: '2.33'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf