supplement 2.16 → 2.18

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: 6ba64230cdc82b400a4999ac0981145a2d1e4d59344b940adeafa1e036efb5ba
4
- data.tar.gz: b4d43816094e6fffae62522754729237fcc41f0f58790c9753e388a94093645d
3
+ metadata.gz: 561912aa02f069434802b541add075b1da590f48683a2fab71ca49b3d383303d
4
+ data.tar.gz: d3c555d5ee6178288fbaa106056c25969e8e1b95aea3acb239c788a33bf333bd
5
5
  SHA512:
6
- metadata.gz: 449788ae54c3681d99470dcde71117550f835e4646508c75421dc22f6e17632a7ec6ab5614b3a269dc959e0b27b4a83873f5f795ec2b87a25f13cfcab45c8f12
7
- data.tar.gz: 05e0431b4a23da92168e22a5e8ae57e834e28a0fb9d2e9edca9627d13255933a25cc464fd6b6bab21565248e57d51ac34ffbd0c98246e8b2050891c6db99294a
6
+ metadata.gz: 62d3318a08eb07bab3c467012f13f5404237dd02444351ff982c4c387666ee1f3704b7523b3ca1b8c93e342b1d8494367929d28fc115b9c2fe4c86a198c87b2d
7
+ data.tar.gz: 4be7ab9130603ad97a223645952a2c6d388b0e483a0a8ffa89a06f64ab337f2d3d2638feefe328901d9b2330f136b098c3b35d6389e52bea0f9cf209ad7e7c6b
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.16 -- Useful Ruby enhancements
1
+ = supplement 2.18 -- Useful Ruby enhancements
2
2
 
3
3
 
4
4
  Some simple Ruby extensions.
@@ -59,7 +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
+ * TCPServer/UNIXServer.accept with a code block
63
63
  * File system stats
64
64
  * Process.renice
65
65
  * Interval timer
@@ -40,14 +40,18 @@ socket_close( VALUE v)
40
40
  void Init_socket( void)
41
41
  {
42
42
  VALUE rb_cTCPServer;
43
+ VALUE rb_cUNIXServer;
43
44
 
44
45
  id_accept_orig = rb_intern( "accept_orig");
45
46
  id_close = rb_intern( "close");
46
47
 
47
48
  rb_require( "socket");
48
- rb_cTCPServer = rb_const_get( rb_cObject, rb_intern( "TCPServer"));
49
+ rb_cTCPServer = rb_const_get( rb_cObject, rb_intern( "TCPServer"));
50
+ rb_cUNIXServer = rb_const_get( rb_cObject, rb_intern( "UNIXServer"));
49
51
 
50
- rb_define_alias( rb_cTCPServer, "accept_orig", "accept");
51
- rb_define_method( rb_cTCPServer, "accept", rb_socket_accept, 0);
52
+ rb_define_alias( rb_cTCPServer, "accept_orig", "accept");
53
+ rb_define_method( rb_cTCPServer, "accept", rb_socket_accept, 0);
54
+ rb_define_alias( rb_cUNIXServer, "accept_orig", "accept");
55
+ rb_define_method( rb_cUNIXServer, "accept", rb_socket_accept, 0);
52
56
  }
53
57
 
data/lib/supplement.c CHANGED
@@ -1511,9 +1511,34 @@ bsruby_set_thread_critical( VALUE c)
1511
1511
  */
1512
1512
 
1513
1513
 
1514
+
1515
+ /*
1516
+ * Document-class: Object
1517
+ */
1518
+
1519
+ /*
1520
+ * call-seq:
1521
+ * to_bool -> true
1522
+ *
1523
+ * Returns true for anything but +nil+ and +false+.
1524
+ */
1525
+
1526
+ VALUE
1527
+ rb_nil_to_bool( VALUE obj)
1528
+ {
1529
+ return Qfalse;
1530
+ }
1531
+
1532
+ VALUE
1533
+ rb_obj_to_bool( VALUE obj)
1534
+ {
1535
+ return Qtrue;
1536
+ }
1537
+
1538
+
1539
+
1514
1540
  void Init_supplement( void)
1515
1541
  {
1516
- rb_define_alias( rb_cObject, "cls", "class");
1517
1542
  rb_define_method( rb_cObject, "new_string", rb_obj_new_string, 0);
1518
1543
  rb_define_method( rb_cObject, "nil_if", rb_obj_nil_if, 1);
1519
1544
  #ifdef FEATURE_KERNEL_TAP
@@ -1595,6 +1620,10 @@ void Init_supplement( void)
1595
1620
  rb_define_method( rb_cStruct, "fields", rb_struct_fields, -1);
1596
1621
  rb_define_alias( rb_cStruct, "fetch_values", "fields");
1597
1622
 
1623
+ rb_define_method( rb_cNilClass, "to_bool", rb_nil_to_bool, 0);
1624
+ rb_define_method( rb_cFalseClass, "to_bool", rb_nil_to_bool, 0);
1625
+ rb_define_method( rb_cObject, "to_bool", rb_obj_to_bool, 0);
1626
+
1598
1627
  id_delete_at = rb_intern( "delete_at");
1599
1628
  id_cmp = rb_intern( "<=>");
1600
1629
  id_eqq = 0;
data/lib/supplement.h CHANGED
@@ -45,6 +45,12 @@ extern VALUE rb_str_ord( VALUE);
45
45
  #endif
46
46
  extern VALUE rb_str_axe( int, VALUE *, VALUE);
47
47
 
48
+ extern VALUE rb_num_pos_p( VALUE);
49
+ extern VALUE rb_num_neg_p( VALUE);
50
+ extern VALUE rb_num_grammatical( VALUE, VALUE, VALUE);
51
+ extern VALUE rb_num_sqrt( VALUE);
52
+ extern VALUE rb_num_cbrt( VALUE);
53
+
48
54
  extern VALUE rb_ary_notempty_p( VALUE);
49
55
  extern VALUE rb_ary_indexes( VALUE);
50
56
  extern VALUE rb_ary_range( VALUE);
@@ -58,12 +64,6 @@ extern VALUE rb_ary_rindex( int, VALUE *, VALUE);
58
64
  extern VALUE rb_ary_select_bang( VALUE);
59
65
  #endif
60
66
 
61
- extern VALUE rb_num_pos_p( VALUE);
62
- extern VALUE rb_num_neg_p( VALUE);
63
- extern VALUE rb_num_grammatical( VALUE, VALUE, VALUE);
64
- extern VALUE rb_num_sqrt( VALUE);
65
- extern VALUE rb_num_cbrt( VALUE);
66
-
67
67
  extern VALUE rb_hash_notempty_p( VALUE);
68
68
 
69
69
  #ifdef FEATURE_FILE_SIZE
@@ -77,12 +77,15 @@ extern VALUE rb_dir_children( VALUE);
77
77
  extern VALUE rb_match_begin( int, VALUE *, VALUE);
78
78
  extern VALUE rb_match_end( int, VALUE *, VALUE);
79
79
 
80
- extern VALUE rb_struct_fields( int, VALUE *, VALUE);
81
-
82
80
  #ifdef FEATURE_THREAD_EXCLUSIVE
83
81
  extern VALUE rb_thread_exclusive( void);
84
82
  #endif
85
83
 
84
+ extern VALUE rb_struct_fields( int, VALUE *, VALUE);
85
+
86
+ extern VALUE rb_nil_to_bool( VALUE);
87
+ extern VALUE rb_obj_to_bool( VALUE);
88
+
86
89
  extern void Init_supplement( void);
87
90
 
88
91
  #endif
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.16'
4
+ version: '2.18'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bertram Scharpf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-16 00:00:00.000000000 Z
11
+ date: 2023-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autorake
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements:
83
83
  - Ruby and the autorake gem
84
- rubygems_version: 3.4.10
84
+ rubygems_version: 3.4.20
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Simple Ruby extensions