supplement 2.2.1 → 2.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6b5d372865ed49ef9c9a89c8c6292ff75212e19
4
+ data.tar.gz: d61db700555cb028544141714d4864ae49bdcb14
5
+ SHA512:
6
+ metadata.gz: 01af2b60382616cdb9a4ea45e308d59d1a0442862a2891e2cbcfdd55b3b91f302b6004258c5240ebb8aacb166af64f2702e31b079fe25a5ec9b9ce25cc7a4e8d
7
+ data.tar.gz: ffecfdfcee1fd8f374e4d26845570e29b3c6bae3dfbc1291d03a376d06f8edefce103a7735a00d4e67bc07919db0f1bee8f1a3346f5ee88341789ea321e40b9e
data/README CHANGED
@@ -1,4 +1,4 @@
1
- = supplement 2.2.1 -- Useful Ruby enhancements
1
+ = supplement 2.3 -- Useful Ruby enhancements
2
2
 
3
3
  Some simple Ruby extensions.
4
4
 
@@ -163,7 +163,7 @@ VALUE
163
163
  rb_krn_tap_bang( VALUE obj)
164
164
  {
165
165
  if (!NIL_P( obj))
166
- rb_yield( obj);
166
+ rb_yield( obj);
167
167
  return obj;
168
168
  }
169
169
 
@@ -524,7 +524,7 @@ rb_str_starts_with_p( VALUE str, VALUE oth)
524
524
  #ifdef HAVE_HEADER_RUBY_H
525
525
  #else
526
526
  if (!rb_str_comparable( str, oth))
527
- return Qnil;
527
+ return Qnil;
528
528
  #endif
529
529
  ost = rb_string_value( &oth);
530
530
  i = RSTRING_LEN( ost);
@@ -567,7 +567,7 @@ rb_str_ends_with_p( VALUE str, VALUE oth)
567
567
  #ifdef HAVE_HEADER_RUBY_H
568
568
  #else
569
569
  if (!rb_str_comparable( str, oth))
570
- return Qnil;
570
+ return Qnil;
571
571
  #endif
572
572
  ost = rb_string_value( &oth);
573
573
  i = RSTRING_LEN( ost);
@@ -815,18 +815,18 @@ rb_num_cbrt( VALUE num)
815
815
 
816
816
  n = RFLOAT_VALUE( rb_Float( num));
817
817
  if ((neg = n < 0))
818
- n = -n;
818
+ n = -n;
819
819
  n = sqrt( sqrt( n));
820
820
  i = 2;
821
821
  for (;;) {
822
- double w = n;
823
- int j;
824
-
825
- for (j=i;j;--j) w = sqrt( w);
826
- i *= 2;
827
- w *= n;
828
- if (n == w) break;
829
- n = w;
822
+ double w = n;
823
+ int j;
824
+
825
+ for (j=i;j;--j) w = sqrt( w);
826
+ i *= 2;
827
+ w *= n;
828
+ if (n == w) break;
829
+ n = w;
830
830
  }
831
831
  return rb_float_new( neg ? -n : n);
832
832
  #endif
@@ -1391,6 +1391,30 @@ rb_match_end( int argc, VALUE *argv, VALUE match)
1391
1391
  }
1392
1392
 
1393
1393
 
1394
+ /*
1395
+ * call-seq:
1396
+ * fields( ...) -> ary
1397
+ *
1398
+ * Returns the values of some fields.
1399
+ *
1400
+ * S = Struct[ :a, :b, :c]
1401
+ * s = S[ "A", "B", "C"]
1402
+ * s.fields( :b, :a) #=> [ "B", "A"]
1403
+ */
1404
+
1405
+ VALUE
1406
+ rb_struct_fields( int argc, VALUE *argv, VALUE strct)
1407
+ {
1408
+ VALUE ary;
1409
+ int i;
1410
+
1411
+ ary = rb_ary_new2( argc);
1412
+ for (i = 0; i < argc; i++)
1413
+ rb_ary_push( ary, rb_struct_aref( strct, argv[ i]));
1414
+ return ary;
1415
+ }
1416
+
1417
+
1394
1418
  #ifdef FEATURE_THREAD_EXCLUSIVE
1395
1419
 
1396
1420
  /*
@@ -1518,6 +1542,8 @@ void Init_supplement( void)
1518
1542
  #endif
1519
1543
 
1520
1544
  rb_define_alias( rb_singleton_class( rb_cStruct), "[]", "new");
1545
+ rb_define_method( rb_cStruct, "fields", rb_struct_fields, -1);
1546
+ rb_define_alias( rb_cStruct, "fetch_values", "fields");
1521
1547
 
1522
1548
  id_delete_at = rb_intern( "delete_at");
1523
1549
  id_cmp = rb_intern( "<=>");
@@ -71,6 +71,8 @@ extern VALUE rb_dir_entries_bang( VALUE);
71
71
  extern VALUE rb_match_begin( int, VALUE *, VALUE);
72
72
  extern VALUE rb_match_end( int, VALUE *, VALUE);
73
73
 
74
+ extern VALUE rb_struct_fields( int, VALUE *, VALUE);
75
+
74
76
  #ifdef FEATURE_THREAD_EXCLUSIVE
75
77
  extern VALUE rb_thread_exclusive( void);
76
78
  #endif
@@ -101,8 +101,8 @@ rb_process_getitimer( VALUE obj)
101
101
  rb_raise( rb_eSystemCallError, "getitimer failed.");
102
102
 
103
103
  r = rb_ary_new3( 2,
104
- suppelement_timeval_sec( &it.it_interval),
105
- suppelement_timeval_sec( &it.it_value));
104
+ suppelement_timeval_sec( &it.it_interval),
105
+ suppelement_timeval_sec( &it.it_value));
106
106
  return r;
107
107
  }
108
108
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supplement
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
5
- prerelease:
4
+ version: '2.3'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bertram Scharpf
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: autorake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ">="
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
@@ -37,27 +34,28 @@ extra_rdoc_files:
37
34
  - README
38
35
  - LICENSE
39
36
  files:
40
- - lib/mkrf_conf
37
+ - LICENSE
38
+ - README
39
+ - examples/teatimer
41
40
  - lib/Rakefile
42
- - lib/supplement.c
43
- - lib/supplement.h
41
+ - lib/mkrf_conf
44
42
  - lib/process.c
45
43
  - lib/process.h
46
- - lib/supplement/locked.c
47
- - lib/supplement/locked.h
44
+ - lib/supplement.c
45
+ - lib/supplement.h
46
+ - lib/supplement/date.rb
48
47
  - lib/supplement/dir.rb
49
48
  - lib/supplement/filesys.c
50
49
  - lib/supplement/filesys.h
51
50
  - lib/supplement/itimer.c
52
51
  - lib/supplement/itimer.h
52
+ - lib/supplement/locked.c
53
+ - lib/supplement/locked.h
53
54
  - lib/supplement/terminal.c
54
55
  - lib/supplement/terminal.h
55
- - lib/supplement/date.rb
56
- - examples/teatimer
57
- - README
58
- - LICENSE
59
56
  homepage: http://www.bertram-scharpf.de/software/supplement
60
57
  licenses: []
58
+ metadata: {}
61
59
  post_install_message:
62
60
  rdoc_options:
63
61
  - "--charset"
@@ -67,13 +65,11 @@ rdoc_options:
67
65
  require_paths:
68
66
  - lib
69
67
  required_ruby_version: !ruby/object:Gem::Requirement
70
- none: false
71
68
  requirements:
72
69
  - - ">="
73
70
  - !ruby/object:Gem::Version
74
71
  version: '0'
75
72
  required_rubygems_version: !ruby/object:Gem::Requirement
76
- none: false
77
73
  requirements:
78
74
  - - ">="
79
75
  - !ruby/object:Gem::Version
@@ -81,8 +77,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
77
  requirements:
82
78
  - Ruby and the autorake gem
83
79
  rubyforge_project: NONE
84
- rubygems_version: 1.8.29
80
+ rubygems_version: 2.6.4
85
81
  signing_key:
86
- specification_version: 3
82
+ specification_version: 4
87
83
  summary: Simple Ruby extensions
88
84
  test_files: []