supplement 2.32 → 2.34
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 +4 -4
- data/README.md +1 -1
- data/lib/mkrf_conf +1 -1
- data/lib/supplement.c +219 -22
- data/lib/supplement.h +6 -0
- metadata +1 -2
- data/examples/teatimer +0 -87
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b3c14cf8891cd883edf8ad0ba621aae216f01d3a935d221c89e31a25ec76f0d
|
|
4
|
+
data.tar.gz: 616736bd166c84a60ebd9ae0670863f6ba26f018f69c61caed5aff7f9d10496e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd0005f7224a3b0fd28f9e7a8c69ea6ea30c698d49253e24d006adf1a20b480b60f74161a1f939b0460e88afe9e0e9c8cf5c1d9e0b1fd0d7dfb14e66f67764e2
|
|
7
|
+
data.tar.gz: 5e8d529b3c3a78d7dbf44c033f11027032a463ca19b046e985904c4b75525876c1e00a50a6ea94247ef40579d65cfd59e25342de1abaf06048dca84427f099ff
|
data/README.md
CHANGED
data/lib/mkrf_conf
CHANGED
data/lib/supplement.c
CHANGED
|
@@ -11,22 +11,37 @@
|
|
|
11
11
|
#include <ruby/re.h>
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
#define SUPPLEMENT_VERSION "2.34"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#define SPL_CSTR(s) rb_str_new( (s), sizeof (s) - 1)
|
|
19
|
+
|
|
20
|
+
|
|
14
21
|
static long supplement_args_len_default( int, VALUE *);
|
|
15
22
|
static void supplement_ary_assure_notempty( VALUE);
|
|
16
23
|
static VALUE supplement_index_blk( VALUE);
|
|
17
24
|
static VALUE supplement_index_ref( VALUE, VALUE);
|
|
18
25
|
static VALUE supplement_rindex_blk( VALUE);
|
|
19
26
|
static VALUE supplement_rindex_ref( VALUE, VALUE);
|
|
27
|
+
static long supplement_find_nth( VALUE, VALUE, VALUE (*)( VALUE, long, VALUE));
|
|
28
|
+
static VALUE supplement_find_nth_result( VALUE, long, VALUE);
|
|
29
|
+
static VALUE supplement_delete_nth_result( VALUE, long, VALUE);
|
|
30
|
+
|
|
20
31
|
static VALUE supplement_do_unumask( VALUE);
|
|
21
32
|
|
|
22
33
|
|
|
34
|
+
static const char *supplement_scope = "::";
|
|
23
35
|
static const char *supplement_ellipse = "...";
|
|
36
|
+
static const char *supplement_dot = ".";
|
|
24
37
|
|
|
25
38
|
static ID id_delete_at = 0;
|
|
26
|
-
static ID
|
|
27
|
-
static ID
|
|
28
|
-
static ID id_mkdir
|
|
29
|
-
static ID
|
|
39
|
+
static ID id_eqq = 0;
|
|
40
|
+
static ID id_cmp = 0;
|
|
41
|
+
static ID id_mkdir = 0;
|
|
42
|
+
static ID id_abs = 0;
|
|
43
|
+
static ID id_div = 0;
|
|
44
|
+
static ID id_zero_p = 0;
|
|
30
45
|
|
|
31
46
|
|
|
32
47
|
|
|
@@ -81,8 +96,6 @@ rb_obj_new_string( VALUE obj)
|
|
|
81
96
|
VALUE
|
|
82
97
|
rb_obj_nil_if( VALUE obj, VALUE val)
|
|
83
98
|
{
|
|
84
|
-
if (!id_eqq)
|
|
85
|
-
id_eqq = rb_intern( "===");
|
|
86
99
|
return RTEST( rb_funcall( val, id_eqq, 1, obj)) ? Qnil : obj;
|
|
87
100
|
}
|
|
88
101
|
|
|
@@ -128,7 +141,7 @@ rb_module_plain_name( VALUE cls)
|
|
|
128
141
|
VALUE i;
|
|
129
142
|
|
|
130
143
|
n = rb_str_dup( rb_funcall( cls, rb_intern( "name"), 0));
|
|
131
|
-
i = rb_funcall( n, rb_intern( "rindex"), 1,
|
|
144
|
+
i = rb_funcall( n, rb_intern( "rindex"), 1, SPL_CSTR( supplement_scope));
|
|
132
145
|
if (!NIL_P( i)) {
|
|
133
146
|
i = rb_funcall( i, rb_intern( "+"), 1, INT2FIX( 2));
|
|
134
147
|
rb_funcall( n, rb_intern( "slice!"), 2, INT2FIX( 0), i);
|
|
@@ -552,6 +565,32 @@ rb_str_ends_with_p( int argc, VALUE *argv, VALUE str)
|
|
|
552
565
|
}
|
|
553
566
|
|
|
554
567
|
|
|
568
|
+
/*
|
|
569
|
+
* Document-class: Symbol
|
|
570
|
+
*/
|
|
571
|
+
|
|
572
|
+
/*
|
|
573
|
+
* call-seq:
|
|
574
|
+
* notempty? -> nil or self
|
|
575
|
+
*
|
|
576
|
+
* Returns <code>self</code> if and only if <code>str</code> is not
|
|
577
|
+
* empty, <code>nil</code> otherwise.
|
|
578
|
+
*
|
|
579
|
+
* :hello.notempty? #=> :hello
|
|
580
|
+
* :"".notempty? #=> nil
|
|
581
|
+
*
|
|
582
|
+
* This seems to be quite useless. Its only purpose is to avoid either type
|
|
583
|
+
* detection or error catching when other objects are asked whether they're
|
|
584
|
+
* not empty.
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
VALUE
|
|
588
|
+
rb_sym_notempty_p( VALUE sym)
|
|
589
|
+
{
|
|
590
|
+
return NUM2LONG( rb_funcall( sym, rb_intern( "length"), 0)) ? sym : Qnil;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
|
|
555
594
|
/*
|
|
556
595
|
* call-seq:
|
|
557
596
|
* starts_with?( oth) -> nil or int
|
|
@@ -631,6 +670,8 @@ rb_num_grammatical( VALUE num, VALUE sing, VALUE plu)
|
|
|
631
670
|
break;
|
|
632
671
|
|
|
633
672
|
default:
|
|
673
|
+
if (!id_cmp)
|
|
674
|
+
id_cmp = rb_intern( "<=>");
|
|
634
675
|
l = NUM2LONG( rb_funcall( num, id_cmp, 1, INT2FIX( 1)));
|
|
635
676
|
if (l == 0)
|
|
636
677
|
return sing;
|
|
@@ -658,6 +699,47 @@ rb_num_sqrt( VALUE num)
|
|
|
658
699
|
return rb_float_new( sqrt( RFLOAT_VALUE( rb_Float( num))));
|
|
659
700
|
}
|
|
660
701
|
|
|
702
|
+
|
|
703
|
+
/*
|
|
704
|
+
* Document-class: Integer
|
|
705
|
+
*/
|
|
706
|
+
|
|
707
|
+
/*
|
|
708
|
+
* call-seq:
|
|
709
|
+
* int.length( base = nil) -> int
|
|
710
|
+
*
|
|
711
|
+
* Length of mantissa. Default base is <code>10</code>.
|
|
712
|
+
*
|
|
713
|
+
* 1234.length #=> 4
|
|
714
|
+
*/
|
|
715
|
+
|
|
716
|
+
VALUE
|
|
717
|
+
rb_int_length( int argc, VALUE *argv, VALUE num)
|
|
718
|
+
{
|
|
719
|
+
VALUE base;
|
|
720
|
+
VALUE x;
|
|
721
|
+
long n;
|
|
722
|
+
|
|
723
|
+
if (!id_abs)
|
|
724
|
+
id_abs = rb_intern( "abs");
|
|
725
|
+
if (!id_div)
|
|
726
|
+
id_div = rb_intern( "div");
|
|
727
|
+
if (!id_zero_p)
|
|
728
|
+
id_zero_p = rb_intern( "zero?");
|
|
729
|
+
|
|
730
|
+
if (rb_scan_args( argc, argv, "01", &base) != 1)
|
|
731
|
+
base = Qnil;
|
|
732
|
+
if (NIL_P( base))
|
|
733
|
+
base = LONG2NUM( 10);
|
|
734
|
+
n = 0;
|
|
735
|
+
x = rb_funcall( num, id_abs, 0);
|
|
736
|
+
while (!RTEST(rb_funcall( x, id_zero_p, 0))) {
|
|
737
|
+
n++;
|
|
738
|
+
x = rb_funcall( x, id_div, 1, base);
|
|
739
|
+
}
|
|
740
|
+
return LONG2NUM( n);
|
|
741
|
+
}
|
|
742
|
+
|
|
661
743
|
/*
|
|
662
744
|
* Document-class: Rational
|
|
663
745
|
*/
|
|
@@ -805,8 +887,8 @@ rb_ary_indexes( VALUE ary)
|
|
|
805
887
|
* pick( ref) -> obj or nil
|
|
806
888
|
* pick { |elem| ... } -> obj or nil
|
|
807
889
|
*
|
|
808
|
-
* Deletes the element where first <code>ref === obj</code>
|
|
809
|
-
* <em>block</em> first returns
|
|
890
|
+
* Deletes the element where first <code>ref === obj</code> or the
|
|
891
|
+
* <em>block</em> first returns a true value. The result will be
|
|
810
892
|
* <code>nil</code> if nothing is found.
|
|
811
893
|
*
|
|
812
894
|
* a = %w(ant bat cat dog)
|
|
@@ -837,8 +919,6 @@ supplement_index_ref( VALUE ary, VALUE ref)
|
|
|
837
919
|
{
|
|
838
920
|
long i, j;
|
|
839
921
|
|
|
840
|
-
if (!id_eqq)
|
|
841
|
-
id_eqq = rb_intern( "===");
|
|
842
922
|
for (i = 0, j = RARRAY_LEN( ary); j > 0; i++, j--) {
|
|
843
923
|
if (RTEST( rb_funcall( ref, id_eqq, 1, RARRAY_PTR( ary)[ i])))
|
|
844
924
|
return LONG2NUM( i);
|
|
@@ -863,8 +943,8 @@ supplement_index_blk( VALUE ary)
|
|
|
863
943
|
* rpick( ref) -> obj or nil
|
|
864
944
|
* rpick { |elem| ... } -> obj or nil
|
|
865
945
|
*
|
|
866
|
-
* Deletes the element where first <code>ref === obj</code>
|
|
867
|
-
* <em>block</em> first returns
|
|
946
|
+
* Deletes the element where first <code>ref === obj</code> or the
|
|
947
|
+
* <em>block</em> first returns a true value. The result will be
|
|
868
948
|
* <code>nil</code> if nothing is found. Search from right to left.
|
|
869
949
|
*
|
|
870
950
|
* a = %w(ant cow bat cat dog)
|
|
@@ -895,8 +975,6 @@ supplement_rindex_ref( VALUE ary, VALUE ref)
|
|
|
895
975
|
{
|
|
896
976
|
long i;
|
|
897
977
|
|
|
898
|
-
if (!id_eqq)
|
|
899
|
-
id_eqq = rb_intern( "===");
|
|
900
978
|
for (i = RARRAY_LEN( ary); i;) {
|
|
901
979
|
--i;
|
|
902
980
|
if (RTEST( rb_funcall( ref, id_eqq, 1, RARRAY_PTR( ary)[ i])))
|
|
@@ -919,6 +997,119 @@ supplement_rindex_blk( VALUE ary)
|
|
|
919
997
|
}
|
|
920
998
|
|
|
921
999
|
|
|
1000
|
+
/*
|
|
1001
|
+
* call-seq:
|
|
1002
|
+
* lstrip! { |elem| ... } -> nil or self
|
|
1003
|
+
*
|
|
1004
|
+
* Strip all elements from left where the block returns a true value.
|
|
1005
|
+
* Returns <code>nil</code> when the array is empty afterwards.
|
|
1006
|
+
*
|
|
1007
|
+
* a = %w(ant bat cow dog eel fox gnu)
|
|
1008
|
+
* a.lstrip! { |e| e =~ /a/ } #=> [ "cow", "dog", "eel", "fox", "gnu"]
|
|
1009
|
+
* a.lstrip! { |e| e.length == 3 } #=> nil
|
|
1010
|
+
*/
|
|
1011
|
+
|
|
1012
|
+
VALUE
|
|
1013
|
+
rb_ary_lstrip_bang( VALUE ary)
|
|
1014
|
+
{
|
|
1015
|
+
while (RARRAY_LEN( ary) > 0 && RTEST( rb_yield( RARRAY_PTR( ary)[ 0])))
|
|
1016
|
+
rb_ary_shift( ary);
|
|
1017
|
+
return RARRAY_LEN( ary) ? ary : Qnil;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/*
|
|
1021
|
+
* call-seq:
|
|
1022
|
+
* rstrip! { |elem| ... } -> nil or self
|
|
1023
|
+
*
|
|
1024
|
+
* Strip all elements from left where the block returns a true value.
|
|
1025
|
+
* Returns <code>nil</code> when the array is empty afterwards.
|
|
1026
|
+
*
|
|
1027
|
+
* a = %w(ant bat cow dog eel fox gnu)
|
|
1028
|
+
* a.rstrip! { |e| e =~ /[ou]/ } #=> [ "ant", "bat", "cow", "dog", "eel"]
|
|
1029
|
+
* a.lstrip! { |e| e.length == 3 } #=> nil
|
|
1030
|
+
*/
|
|
1031
|
+
|
|
1032
|
+
VALUE
|
|
1033
|
+
rb_ary_rstrip_bang( VALUE ary)
|
|
1034
|
+
{
|
|
1035
|
+
while (RARRAY_LEN( ary) > 0 && RTEST( rb_yield( RARRAY_PTR( ary)[ RARRAY_LEN(ary)-1])))
|
|
1036
|
+
rb_ary_pop( ary);
|
|
1037
|
+
return RARRAY_LEN( ary) ? ary : Qnil;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
long
|
|
1042
|
+
supplement_find_nth( VALUE ary, VALUE num, VALUE (*mk_result)( VALUE, long, VALUE))
|
|
1043
|
+
{
|
|
1044
|
+
VALUE cur;
|
|
1045
|
+
long i, n;
|
|
1046
|
+
|
|
1047
|
+
n = NUM2LONG( num);
|
|
1048
|
+
for (i = 0; i < RARRAY_LEN( ary); i++) {
|
|
1049
|
+
cur = RARRAY_PTR( ary)[ i];
|
|
1050
|
+
if (RTEST( rb_yield( cur))) {
|
|
1051
|
+
if (!n)
|
|
1052
|
+
return (*mk_result)( ary, i, cur);
|
|
1053
|
+
n--;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
return Qnil;
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/*
|
|
1060
|
+
* call-seq:
|
|
1061
|
+
* find_nth( int) { |elem| ... } -> obj or nil
|
|
1062
|
+
*
|
|
1063
|
+
* Find the n-th occurrence of an element for which the block returns
|
|
1064
|
+
* a true value. When less than n elements can be found, <code>nil</code> is
|
|
1065
|
+
* returned.
|
|
1066
|
+
*
|
|
1067
|
+
* a = %w(ant bat cow dog eel fox gnu)
|
|
1068
|
+
* a.find_nth(0) { |e| e =~ /a/ } #=> "ant"
|
|
1069
|
+
* a.find_nth(1) { |e| e =~ /a/ } #=> "bat"
|
|
1070
|
+
* a.find_nth(2) { |e| e =~ /a/ } #=> nil
|
|
1071
|
+
*/
|
|
1072
|
+
|
|
1073
|
+
VALUE
|
|
1074
|
+
rb_ary_find_nth( VALUE ary, VALUE num)
|
|
1075
|
+
{
|
|
1076
|
+
return supplement_find_nth( ary, num, &supplement_find_nth_result);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
VALUE
|
|
1080
|
+
supplement_find_nth_result( VALUE ary, long i, VALUE cur)
|
|
1081
|
+
{
|
|
1082
|
+
return cur;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/*
|
|
1086
|
+
* call-seq:
|
|
1087
|
+
* delete_nth( int) { |elem| ... } -> obj or nil
|
|
1088
|
+
*
|
|
1089
|
+
* Delete the n-th occurrence of an element for which the block returns
|
|
1090
|
+
* a true value. When less than n elements can be found, nothing will be
|
|
1091
|
+
* removed and <code>nil</code> is returned.
|
|
1092
|
+
*
|
|
1093
|
+
* a = %w(ant bat cow dog eel fox gnu)
|
|
1094
|
+
* a.delete_nth(2) { |e| e =~ /a/ } #=> nil
|
|
1095
|
+
* a.delete_nth(1) { |e| e =~ /a/ } #=> "bat"
|
|
1096
|
+
* a.delete_nth(0) { |e| e =~ /a/ } #=> "ant"
|
|
1097
|
+
* a #=> ["cow", "dog", "eel", "fox", "gnu"]
|
|
1098
|
+
*/
|
|
1099
|
+
|
|
1100
|
+
VALUE
|
|
1101
|
+
rb_ary_delete_nth( VALUE ary, VALUE num)
|
|
1102
|
+
{
|
|
1103
|
+
return supplement_find_nth( ary, num, &supplement_delete_nth_result);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
VALUE
|
|
1107
|
+
supplement_delete_nth_result( VALUE ary, long i, VALUE cur)
|
|
1108
|
+
{
|
|
1109
|
+
return rb_funcall( ary, id_delete_at, 1, LONG2NUM( i));
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
|
|
922
1113
|
/*
|
|
923
1114
|
* Document-class: Hash
|
|
924
1115
|
*/
|
|
@@ -1010,7 +1201,7 @@ supplement_do_unumask( VALUE v)
|
|
|
1010
1201
|
VALUE
|
|
1011
1202
|
rb_dir_s_current( VALUE dir)
|
|
1012
1203
|
{
|
|
1013
|
-
VALUE dot =
|
|
1204
|
+
VALUE dot = SPL_CSTR( supplement_dot);
|
|
1014
1205
|
return rb_funcall_passing_block( dir, rb_intern( "open"), 1, &dot);
|
|
1015
1206
|
}
|
|
1016
1207
|
|
|
@@ -1202,6 +1393,8 @@ void Init_supplement( void)
|
|
|
1202
1393
|
rb_define_method( rb_cObject, "nil_if", rb_obj_nil_if, 1);
|
|
1203
1394
|
rb_define_method( rb_mKernel, "tap!", rb_krn_tap_bang, 0);
|
|
1204
1395
|
|
|
1396
|
+
rb_define_global_const("SUPPLEMENT_VERSION", rb_obj_freeze( SPL_CSTR(SUPPLEMENT_VERSION)));
|
|
1397
|
+
|
|
1205
1398
|
rb_define_method( rb_cModule, "plain_name", rb_module_plain_name, 0);
|
|
1206
1399
|
|
|
1207
1400
|
rb_define_method( rb_cNilClass, "notempty?", rb_nil_notempty_p, 0);
|
|
@@ -1219,12 +1412,15 @@ void Init_supplement( void)
|
|
|
1219
1412
|
rb_define_method( rb_cString, "axe!", rb_str_axe_bang, -1);
|
|
1220
1413
|
rb_define_method( rb_cString, "starts_with?", rb_str_starts_with_p, -1);
|
|
1221
1414
|
rb_define_method( rb_cString, "ends_with?", rb_str_ends_with_p, -1);
|
|
1415
|
+
rb_define_method( rb_cSymbol, "notempty?", rb_sym_notempty_p, 0);
|
|
1222
1416
|
rb_define_method( rb_cSymbol, "starts_with?", rb_sym_starts_with_p, -1);
|
|
1223
1417
|
rb_define_method( rb_cSymbol, "ends_with?", rb_sym_ends_with_p, -1);
|
|
1224
1418
|
|
|
1225
1419
|
rb_define_method( rb_cNumeric, "grammatical", rb_num_grammatical, 2);
|
|
1226
1420
|
rb_define_method( rb_cNumeric, "sqrt", rb_num_sqrt, 0);
|
|
1227
1421
|
|
|
1422
|
+
rb_define_method( rb_cInteger, "length", rb_int_length, -1);
|
|
1423
|
+
|
|
1228
1424
|
rb_define_method( rb_cRational, "inv", rb_rat_inverse, 0);
|
|
1229
1425
|
|
|
1230
1426
|
rb_define_method( rb_cArray, "notempty?", rb_ary_notempty_p, 0);
|
|
@@ -1235,6 +1431,10 @@ void Init_supplement( void)
|
|
|
1235
1431
|
rb_define_method( rb_cArray, "range", rb_ary_range, 0);
|
|
1236
1432
|
rb_define_method( rb_cArray, "pick", rb_ary_pick, -1);
|
|
1237
1433
|
rb_define_method( rb_cArray, "rpick", rb_ary_rpick, -1);
|
|
1434
|
+
rb_define_method( rb_cArray, "lstrip!", rb_ary_lstrip_bang, 0);
|
|
1435
|
+
rb_define_method( rb_cArray, "rstrip!", rb_ary_rstrip_bang, 0);
|
|
1436
|
+
rb_define_method( rb_cArray, "find_nth", rb_ary_find_nth, 1);
|
|
1437
|
+
rb_define_method( rb_cArray, "delete_nth", rb_ary_delete_nth, 1);
|
|
1238
1438
|
|
|
1239
1439
|
rb_define_method( rb_cHash, "notempty?", rb_hash_notempty_p, 0);
|
|
1240
1440
|
|
|
@@ -1250,7 +1450,7 @@ void Init_supplement( void)
|
|
|
1250
1450
|
rb_define_method( rb_cMatch, "begin", rb_match_begin, -1);
|
|
1251
1451
|
rb_define_method( rb_cMatch, "end", rb_match_end, -1);
|
|
1252
1452
|
|
|
1253
|
-
rb_define_alias(
|
|
1453
|
+
rb_define_alias( CLASS_OF( rb_cStruct), "[]", "new");
|
|
1254
1454
|
rb_define_method( rb_cStruct, "fields", rb_struct_fields, -1);
|
|
1255
1455
|
rb_define_alias( rb_cStruct, "fetch_values", "fields");
|
|
1256
1456
|
|
|
@@ -1258,11 +1458,8 @@ void Init_supplement( void)
|
|
|
1258
1458
|
rb_define_method( rb_cFalseClass, "to_bool", rb_nil_to_bool, 0);
|
|
1259
1459
|
rb_define_method( rb_cObject, "to_bool", rb_obj_to_bool, 0);
|
|
1260
1460
|
|
|
1261
|
-
id_delete_at
|
|
1262
|
-
|
|
1263
|
-
id_eqq = 0;
|
|
1264
|
-
id_mkdir = 0;
|
|
1265
|
-
id_index = 0;
|
|
1461
|
+
id_delete_at = rb_intern( "delete_at");
|
|
1462
|
+
id_eqq = rb_intern( "===");
|
|
1266
1463
|
|
|
1267
1464
|
Init_supplement_process();
|
|
1268
1465
|
}
|
data/lib/supplement.h
CHANGED
|
@@ -29,11 +29,13 @@ 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
|
|
|
35
36
|
extern VALUE rb_num_grammatical( VALUE, VALUE, VALUE);
|
|
36
37
|
extern VALUE rb_num_sqrt( VALUE);
|
|
38
|
+
extern VALUE rb_int_length( int, VALUE *, VALUE);
|
|
37
39
|
extern VALUE rb_rat_inverse( VALUE);
|
|
38
40
|
|
|
39
41
|
extern VALUE rb_ary_notempty_p( VALUE);
|
|
@@ -43,6 +45,10 @@ extern VALUE rb_ary_indexes( VALUE);
|
|
|
43
45
|
extern VALUE rb_ary_range( VALUE);
|
|
44
46
|
extern VALUE rb_ary_pick( int, VALUE *, VALUE);
|
|
45
47
|
extern VALUE rb_ary_rpick( int, VALUE *, VALUE);
|
|
48
|
+
extern VALUE rb_ary_lstrip_bang( VALUE);
|
|
49
|
+
extern VALUE rb_ary_rstrip_bang( VALUE);
|
|
50
|
+
extern VALUE rb_ary_find_nth( VALUE, VALUE);
|
|
51
|
+
extern VALUE rb_ary_delete_nth( VALUE, VALUE);
|
|
46
52
|
|
|
47
53
|
extern VALUE rb_hash_notempty_p( VALUE);
|
|
48
54
|
|
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.
|
|
4
|
+
version: '2.34'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bertram Scharpf
|
|
@@ -50,7 +50,6 @@ extra_rdoc_files:
|
|
|
50
50
|
files:
|
|
51
51
|
- LICENSE
|
|
52
52
|
- README.md
|
|
53
|
-
- examples/teatimer
|
|
54
53
|
- lib/Rakefile
|
|
55
54
|
- lib/mkrf_conf
|
|
56
55
|
- lib/process.c
|
data/examples/teatimer
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
# teatimer -- Countdown timer
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
# This is an example application for the itimer library.
|
|
8
|
-
# Example:
|
|
9
|
-
#
|
|
10
|
-
# $ teatimer 3m play bell.wav
|
|
11
|
-
# # Count down 3 minutes and the exec the player.
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
require "supplement/itimer"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TeaTimer
|
|
18
|
-
|
|
19
|
-
M = 60
|
|
20
|
-
H = 60 * M
|
|
21
|
-
|
|
22
|
-
class <<self
|
|
23
|
-
|
|
24
|
-
def from_str time
|
|
25
|
-
seconds = case time
|
|
26
|
-
when /m\z/ then Integer( $`) * M
|
|
27
|
-
when /h\z/ then Integer( $`) * H
|
|
28
|
-
else divide_colons time
|
|
29
|
-
end
|
|
30
|
-
new seconds
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def run time
|
|
34
|
-
t = from_str time
|
|
35
|
-
t.run
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private
|
|
39
|
-
|
|
40
|
-
def divide_colons time
|
|
41
|
-
a = time.split ":", -1
|
|
42
|
-
a.map! { |x| Integer( x) }
|
|
43
|
-
a.reverse!
|
|
44
|
-
r = a.shift
|
|
45
|
-
if a.first then r += M * a.shift end
|
|
46
|
-
if a.first then r += H * a.shift end
|
|
47
|
-
a.empty? or raise "Illegal time spec: #{time}."
|
|
48
|
-
r
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def initialize seconds
|
|
54
|
-
@seconds = seconds
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
class Done < Exception ; end
|
|
58
|
-
|
|
59
|
-
def run
|
|
60
|
-
trap "SIGALRM" do
|
|
61
|
-
@seconds -= 1
|
|
62
|
-
print_rest
|
|
63
|
-
raise Done if @seconds.zero?
|
|
64
|
-
end
|
|
65
|
-
Process.setitimer 1
|
|
66
|
-
print_rest
|
|
67
|
-
sleep
|
|
68
|
-
rescue Done
|
|
69
|
-
puts
|
|
70
|
-
ensure
|
|
71
|
-
trap "SIGALRM", "DEFAULT"
|
|
72
|
-
Process.setitimer nil
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
private
|
|
76
|
-
|
|
77
|
-
def print_rest
|
|
78
|
-
$stdout.print " \r%02d:%02d:%02d" %
|
|
79
|
-
[ @seconds / H, @seconds % H / M, @seconds % M]
|
|
80
|
-
$stdout.flush
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
TeaTimer.run $*.first =~ /\A\d+/ ? $*.shift : "3m"
|
|
86
|
-
exec *$* if $*.any?
|
|
87
|
-
|