supplement 2.20 → 2.22
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 +1 -1
- data/lib/mkrf_conf +8 -5
- data/lib/supplement/date.rb +0 -50
- data/lib/supplement/locked.c +19 -0
- data/lib/supplement/terminal.c +29 -7
- data/lib/supplement.c +0 -4
- metadata +7 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe383724f7aaa07dc2be7524d3ab6e11908ede513e133251b01989572343e59
|
4
|
+
data.tar.gz: 64121897e3f8388666664d0911b74ae18a4b8c378b6c38737edc0414e5262629
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0549d67c614aad498ad70160933d2122290b864013ff73b564a57b8f80a8cceaa86c9c57dd222641be738dbf6232e0dccb78b9b3610888055fdf5706bf678f8a'
|
7
|
+
data.tar.gz: eac0f15c6799f7e096abea90146351d33c905e85d78fe0e293a83a1ce611f96b10ba5bf6bc84c3f8271ac1822a8b702794066abe9c8210a5b3dddb0a88c94849
|
data/README
CHANGED
data/lib/mkrf_conf
CHANGED
@@ -10,12 +10,15 @@ Autorake.configure {
|
|
10
10
|
|
11
11
|
extending_ruby
|
12
12
|
|
13
|
-
if RUBY_VERSION < "
|
14
|
-
if RUBY_VERSION < "2.
|
15
|
-
|
13
|
+
if RUBY_VERSION < "3.3" then
|
14
|
+
if RUBY_VERSION < "2.7" then
|
15
|
+
if RUBY_VERSION < "2.6" then
|
16
|
+
enable :dir_children
|
17
|
+
end
|
18
|
+
else
|
19
|
+
enable :super_kwargs
|
16
20
|
end
|
17
|
-
|
18
|
-
enable :super_kwargs
|
21
|
+
enable :old_io_functions
|
19
22
|
end
|
20
23
|
|
21
24
|
have_header "ruby/ruby.h"
|
data/lib/supplement/date.rb
CHANGED
@@ -72,55 +72,5 @@ class Date
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def months_forward n
|
76
|
-
res = self
|
77
|
-
n.times { res = res.next_month }
|
78
|
-
res
|
79
|
-
end
|
80
|
-
|
81
|
-
def months_backward n
|
82
|
-
res = self
|
83
|
-
n.times { res = res.prev_month }
|
84
|
-
res
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
unless DateTime.method_defined? :to_time then
|
91
|
-
|
92
|
-
class Time
|
93
|
-
def to_time ; self ; end
|
94
|
-
def to_date
|
95
|
-
jd = Date.civil_to_jd year, mon, mday, Date::ITALY
|
96
|
-
hd = Date.jd_to_ajd jd, 0, 0
|
97
|
-
Date.new! hd, 0, Date::ITALY
|
98
|
-
end
|
99
|
-
def to_datetime
|
100
|
-
jd = DateTime.civil_to_jd year, mon, mday, DateTime::ITALY
|
101
|
-
fr = DateTime.time_to_day_fraction hour, min, [sec, 59].min
|
102
|
-
fr += (Rational usec, 86400*1000000000)
|
103
|
-
of = (Rational utc_offset, 86400)
|
104
|
-
hd = DateTime.jd_to_ajd jd, fr, of
|
105
|
-
DateTime.new! hd, of, DateTime::ITALY
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
class Date
|
110
|
-
def to_time ; Time.local year, mon, mday ; end
|
111
|
-
def to_date ; self ; end
|
112
|
-
def to_datetime ; DateTime.new! Date.jd_to_ajd(jd,0,0), @of, @sg ; end
|
113
|
-
end
|
114
|
-
|
115
|
-
class DateTime
|
116
|
-
def to_time
|
117
|
-
(new_offset 0).instance_eval do
|
118
|
-
Time.utc year, mon, mday, hour, min, sec + sec_fraction
|
119
|
-
end.getlocal
|
120
|
-
end
|
121
|
-
def to_date ; Date.new! Date.jd_to_ajd(jd,0,0), 0, @sg ; end
|
122
|
-
def to_datetime ; self ; end
|
123
|
-
end
|
124
|
-
|
125
75
|
end
|
126
76
|
|
data/lib/supplement/locked.c
CHANGED
@@ -28,20 +28,35 @@
|
|
28
28
|
VALUE
|
29
29
|
rb_locked_init( int argc, VALUE *argv, VALUE self)
|
30
30
|
{
|
31
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
32
|
+
rb_io_t *fptr;
|
33
|
+
#endif
|
31
34
|
#ifdef HAVE_FUNC_RB_THREAD_WAIT_FOR
|
32
35
|
struct timeval time;
|
33
36
|
#endif
|
34
37
|
int op;
|
35
38
|
|
39
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
40
|
+
GetOpenFile( self, fptr);
|
41
|
+
#endif
|
42
|
+
|
36
43
|
#ifdef FEATURE_SUPER_KWARGS
|
37
44
|
rb_call_super_kw(argc, argv, RB_PASS_CALLED_KEYWORDS);
|
38
45
|
#else
|
39
46
|
rb_call_super( argc, argv);
|
40
47
|
#endif
|
41
48
|
|
49
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
50
|
+
op = fptr->mode & FMODE_WRITABLE ? LOCK_EX : LOCK_SH;
|
51
|
+
#else
|
42
52
|
op = rb_io_mode( self) & FMODE_WRITABLE ? LOCK_EX : LOCK_SH;
|
53
|
+
#endif
|
43
54
|
op |= LOCK_NB;
|
55
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
56
|
+
while (flock( fptr->fd, op) < 0) {
|
57
|
+
#else
|
44
58
|
while (flock( rb_io_descriptor( self), op) < 0) {
|
59
|
+
#endif
|
45
60
|
static ID id_lock_failed = 0;
|
46
61
|
|
47
62
|
switch (errno) {
|
@@ -67,7 +82,11 @@ rb_locked_init( int argc, VALUE *argv, VALUE self)
|
|
67
82
|
}
|
68
83
|
break;
|
69
84
|
default:
|
85
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
86
|
+
rb_sys_fail_str( fptr->pathv);
|
87
|
+
#else
|
70
88
|
rb_sys_fail_str( rb_io_path( self));
|
89
|
+
#endif
|
71
90
|
break;
|
72
91
|
}
|
73
92
|
}
|
data/lib/supplement/terminal.c
CHANGED
@@ -13,7 +13,13 @@ static VALUE io_unget( VALUE);
|
|
13
13
|
static VALUE io_reset( VALUE);
|
14
14
|
|
15
15
|
|
16
|
-
#
|
16
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
17
|
+
#define RB_FAIL_PATH( io, fptr) ((fptr)->pathv)
|
18
|
+
#define RB_IO_VAR( io, fptr) fptr
|
19
|
+
#else
|
20
|
+
#define RB_FAIL_PATH( io, fptr) rb_io_path( io)
|
21
|
+
#define RB_IO_VAR( io, fptr) io
|
22
|
+
#endif
|
17
23
|
|
18
24
|
/*
|
19
25
|
* call-seq:
|
@@ -27,20 +33,28 @@ static VALUE io_reset( VALUE);
|
|
27
33
|
VALUE
|
28
34
|
rb_io_unget( int argc, VALUE *argv, VALUE io)
|
29
35
|
{
|
36
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
37
|
+
rb_io_t *fptr;
|
38
|
+
#endif
|
30
39
|
int fd;
|
31
40
|
struct termios oldtio, newtio;
|
32
41
|
void *v[5];
|
33
42
|
|
43
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
44
|
+
GetOpenFile( io, fptr);
|
45
|
+
fd = fptr->fd;
|
46
|
+
#else
|
34
47
|
fd = rb_io_descriptor( io);
|
48
|
+
#endif
|
35
49
|
|
36
50
|
if (tcgetattr( fd, &oldtio) < 0)
|
37
|
-
|
51
|
+
rb_sys_fail_str( RB_FAIL_PATH( io, fptr));
|
38
52
|
newtio = oldtio;
|
39
53
|
newtio.c_iflag &= ~ICRNL;
|
40
54
|
if (tcsetattr( fd, TCSANOW, &newtio) < 0)
|
41
|
-
|
55
|
+
rb_sys_fail_str( RB_FAIL_PATH( io, fptr));
|
42
56
|
|
43
|
-
v[0] = &fd, v[1] = (void *) io, v[2] = &oldtio,
|
57
|
+
v[0] = &fd, v[1] = (void *) RB_IO_VAR( io, fptr), v[2] = &oldtio,
|
44
58
|
v[3] = &argc, v[4] = (void *) argv;
|
45
59
|
return rb_ensure( io_unget, (VALUE) v, io_reset, (VALUE) v);
|
46
60
|
}
|
@@ -62,7 +76,7 @@ io_unget( VALUE v)
|
|
62
76
|
p = RSTRING_PTR(str);
|
63
77
|
for (i = RSTRING_LEN(str); i; --i, ++p)
|
64
78
|
if (ioctl( *(int *) vp[0], TIOCSTI, p) < 0)
|
65
|
-
|
79
|
+
rb_sys_fail_str( RB_FAIL_PATH( (VALUE) vp[1], (rb_io_t *) vp[1]));
|
66
80
|
}
|
67
81
|
return Qnil;
|
68
82
|
}
|
@@ -73,7 +87,7 @@ io_reset( VALUE v)
|
|
73
87
|
void **vp = (void **) v;
|
74
88
|
|
75
89
|
if (tcsetattr( *(int *) vp[0], TCSANOW, (struct termios *) vp[2]) < 0)
|
76
|
-
|
90
|
+
rb_sys_fail_str( RB_FAIL_PATH( (VALUE) vp[1], (rb_io_t *) vp[1]));
|
77
91
|
|
78
92
|
return Qnil;
|
79
93
|
}
|
@@ -91,14 +105,22 @@ io_reset( VALUE v)
|
|
91
105
|
VALUE
|
92
106
|
rb_io_wingeom( VALUE self)
|
93
107
|
{
|
108
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
109
|
+
rb_io_t *fptr;
|
110
|
+
#endif
|
94
111
|
int fd;
|
95
112
|
struct winsize w;
|
96
113
|
VALUE r;
|
97
114
|
|
115
|
+
#ifdef FEATURE_OLD_IO_FUNCTIONS
|
116
|
+
GetOpenFile( self, fptr);
|
117
|
+
fd = fptr->fd;
|
118
|
+
#else
|
98
119
|
fd = rb_io_descriptor( self);
|
120
|
+
#endif
|
99
121
|
|
100
122
|
if (ioctl( fd, TIOCGWINSZ, &w) < 0)
|
101
|
-
|
123
|
+
rb_sys_fail_str( RB_FAIL_PATH( self, fptr));
|
102
124
|
r = rb_ary_new2( 4);
|
103
125
|
rb_ary_store( r, 0, INT2NUM( w.ws_col));
|
104
126
|
rb_ary_store( r, 1, INT2NUM( w.ws_row));
|
data/lib/supplement.c
CHANGED
@@ -508,8 +508,6 @@ rb_str_starts_with_p( VALUE str, VALUE oth)
|
|
508
508
|
char *s, *o;
|
509
509
|
VALUE ost;
|
510
510
|
|
511
|
-
if (!rb_str_comparable( str, oth))
|
512
|
-
return Qnil;
|
513
511
|
ost = rb_string_value( &oth);
|
514
512
|
i = RSTRING_LEN( ost);
|
515
513
|
if (i > RSTRING_LEN( str))
|
@@ -544,8 +542,6 @@ rb_str_ends_with_p( VALUE str, VALUE oth)
|
|
544
542
|
char *s, *o;
|
545
543
|
VALUE ost;
|
546
544
|
|
547
|
-
if (!rb_str_comparable( str, oth))
|
548
|
-
return Qnil;
|
549
545
|
ost = rb_string_value( &oth);
|
550
546
|
i = RSTRING_LEN( ost);
|
551
547
|
if (i > RSTRING_LEN( str))
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supplement
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.22'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertram Scharpf
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-04 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake
|
@@ -38,9 +37,9 @@ dependencies:
|
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '2.18'
|
41
|
-
description:
|
42
|
-
|
43
|
-
|
40
|
+
description: |
|
41
|
+
Simple methods that didn't manage to become
|
42
|
+
part of standard Ruby.
|
44
43
|
email: "<software@bertram-scharpf.de>"
|
45
44
|
executables: []
|
46
45
|
extensions:
|
@@ -71,14 +70,11 @@ files:
|
|
71
70
|
- lib/supplement/socket.h
|
72
71
|
- lib/supplement/terminal.c
|
73
72
|
- lib/supplement/terminal.h
|
74
|
-
homepage:
|
73
|
+
homepage: https://github.com/BertramScharpf/ruby-supplement
|
75
74
|
licenses:
|
76
75
|
- BSD-2-Clause
|
77
76
|
metadata: {}
|
78
|
-
post_install_message:
|
79
77
|
rdoc_options:
|
80
|
-
- "--charset"
|
81
|
-
- utf-8
|
82
78
|
- "--main"
|
83
79
|
- README
|
84
80
|
require_paths:
|
@@ -95,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
91
|
version: '0'
|
96
92
|
requirements:
|
97
93
|
- Ruby and the autorake gem
|
98
|
-
rubygems_version: 3.
|
99
|
-
signing_key:
|
94
|
+
rubygems_version: 3.6.2
|
100
95
|
specification_version: 4
|
101
96
|
summary: Simple Ruby extensions
|
102
97
|
test_files: []
|