supplement 2.14 → 2.16

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: 87a39a1087d00c8d9b259a074c1fdd969e9a76b2fa3dda7b497b909178b16798
4
- data.tar.gz: 41649aa614f380e9af051d9bf4d6e47d44b6c2bb359a6b774c19e42c9d714364
3
+ metadata.gz: 6ba64230cdc82b400a4999ac0981145a2d1e4d59344b940adeafa1e036efb5ba
4
+ data.tar.gz: b4d43816094e6fffae62522754729237fcc41f0f58790c9753e388a94093645d
5
5
  SHA512:
6
- metadata.gz: 8219771e3227ecb9d99c1fa4eb658565dec657559181ef098cf31f8567248071c54e496c6debefeadfd05bed7ca7f5520c0ae644725be30e8e979685d6160c8b
7
- data.tar.gz: 4488bc07f0cf1087620992e7b5c69e63b639260efd79c020957520e54e81f4f13c49e0707f3a9f4c64c99dd480b08af7fb93f9dce9f038b168dc3c2868512ac6
6
+ metadata.gz: 449788ae54c3681d99470dcde71117550f835e4646508c75421dc22f6e17632a7ec6ab5614b3a269dc959e0b27b4a83873f5f795ec2b87a25f13cfcab45c8f12
7
+ data.tar.gz: 05e0431b4a23da92168e22a5e8ae57e834e28a0fb9d2e9edca9627d13255933a25cc464fd6b6bab21565248e57d51ac34ffbd0c98246e8b2050891c6db99294a
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.14 -- Useful Ruby enhancements
1
+ = supplement 2.16 -- Useful Ruby enhancements
2
2
 
3
3
 
4
4
  Some simple Ruby extensions.
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
data/lib/process.c CHANGED
@@ -19,6 +19,7 @@
19
19
 
20
20
  static VALUE rb_process_renice( int argc, VALUE *argv, VALUE obj);
21
21
  static VALUE rb_process_sync( VALUE obj);
22
+ static VALUE rb_process_alarm( int argc, VALUE *argv, VALUE obj);
22
23
 
23
24
 
24
25
  /*
@@ -62,9 +63,43 @@ rb_process_sync( VALUE obj)
62
63
  }
63
64
 
64
65
 
66
+ /*
67
+ * call-seq:
68
+ * Process.alarm( seconds = nil) -> nil
69
+ *
70
+ * Set alarm. Examples:
71
+ *
72
+ * Signal.trap :ALRM do
73
+ * puts "Three seconds have passed."
74
+ * end
75
+ * Process.alarm 3
76
+ * sleep 4
77
+ *
78
+ * begin
79
+ * Process.alarm 3
80
+ * sleep
81
+ * rescue SignalException
82
+ * $!.signm == "SIGALRM" or raise
83
+ * puts "Three seconds have passed."
84
+ * end
85
+ */
86
+
87
+ VALUE
88
+ rb_process_alarm( int argc, VALUE *argv, VALUE obj)
89
+ {
90
+ VALUE p;
91
+ unsigned int s;
92
+
93
+ s = rb_scan_args( argc, argv, "01", &p) == 1 ? NUM2INT( p) : 0;
94
+ s = alarm( s);
95
+ return s ? INT2NUM( s) : Qnil;
96
+ }
97
+
98
+
65
99
  void Init_supplement_process( void)
66
100
  {
67
101
  rb_define_singleton_method( rb_mProcess, "renice", rb_process_renice, -1);
68
102
  rb_define_singleton_method( rb_mProcess, "sync", rb_process_sync, 0);
103
+ rb_define_singleton_method( rb_mProcess, "alarm", rb_process_alarm, -1);
69
104
  }
70
105
 
@@ -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
  }
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;
@@ -671,7 +670,6 @@ rb_str_axe( int argc, VALUE *argv, VALUE str)
671
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.14'
4
+ version: '2.16'
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-11-22 00:00:00.000000000 Z
11
+ date: 2023-04-16 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.0.8
84
+ rubygems_version: 3.4.10
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: Simple Ruby extensions