Skip to content

Commit

Permalink
Get rid of deprecated functionality;
Browse files Browse the repository at this point in the history
Get rid of Ye Olde CVS noise;
Add Mac OS 14 support
  • Loading branch information
DrHyde committed May 1, 2024
1 parent b849bec commit e778574
Show file tree
Hide file tree
Showing 20 changed files with 51 additions and 107 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
2.00 XXXX-XX-XX

- list_* no longer have special behaviour when called in scalar context. This has
been deprecated since version 1.90;

- Add Devel::AssertOS::MacOSX::v14 (Sonoma)

1.96 2023-02-04

- Add Devel::AssertOS::MacOSX::v13
- Add Devel::AssertOS::MacOSX::v13 (Ventura)

- Add Devel::AssertOS::OSFeatures::Systemd

Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ t/int-size.t
lib/Devel/AssertOS/HWCapabilities/Int32.pm
lib/Devel/AssertOS/MacOSX/v13.pm
lib/Devel/AssertOS/OSFeatures/Systemd.pm
lib/Devel/AssertOS/MacOSX/v14.pm
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/DEC.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: DEC.pm,v 1.5 2008/11/05 22:52:34 drhyde Exp $

package Devel::AssertOS::DEC;

use Devel::CheckOS;
Expand Down
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/Linux/v2_6.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: v2_6.pm,v 1.4 2008/11/05 22:52:35 drhyde Exp $

package Devel::AssertOS::Linux::v2_6;

use Devel::CheckOS;
Expand Down
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/MacOSX/v10_4.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: v10_4.pm,v 1.4 2008/11/05 22:52:35 drhyde Exp $

package Devel::AssertOS::MacOSX::v10_4;

use Devel::CheckOS;
Expand Down
28 changes: 28 additions & 0 deletions lib/Devel/AssertOS/MacOSX/v14.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package Devel::AssertOS::MacOSX::v14;

use Devel::CheckOS;
use strict;
use warnings;
no warnings 'redefine';

our $VERSION = '1.0';

sub os_is {
Devel::CheckOS::os_is('MacOSX') &&
`sw_vers -productVersion` =~ /^14/ ? 1 : 0;
}

sub expn { "The operating system is some version of Mac OS Sonoma" }

Devel::CheckOS::die_unsupported() unless(os_is());

=head1 COPYRIGHT and LICENCE
Copyright 2023 David Cantrell
This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.
=cut

1;

2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/MicrosoftWindows.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: MicrosoftWindows.pm,v 1.6 2008/11/05 22:52:34 drhyde Exp $

package Devel::AssertOS::MicrosoftWindows;

use Devel::CheckOS;
Expand Down
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: POSIXShellRedirection.pm,v 1.3 2008/11/05 22:52:35 drhyde Exp $

package Devel::AssertOS::OSFeatures::POSIXShellRedirection;

our $VERSION = '1.4';
Expand Down
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/QNX.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: QNX.pm,v 1.2 2008/10/27 20:31:21 drhyde Exp $

package Devel::AssertOS::QNX;

use Devel::CheckOS;
Expand Down
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/Realtime.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: Realtime.pm,v 1.3 2008/11/05 22:52:34 drhyde Exp $

package Devel::AssertOS::Realtime;

use Devel::CheckOS;
Expand Down
2 changes: 0 additions & 2 deletions lib/Devel/AssertOS/Sun.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: Sun.pm,v 1.5 2008/11/05 22:52:34 drhyde Exp $

package Devel::AssertOS::Sun;

use Devel::CheckOS;
Expand Down
59 changes: 13 additions & 46 deletions lib/Devel/CheckOS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use File::Spec;

use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS %OS_ALIASES);

our $VERSION = '1.96';
our $VERSION = '2.00';

@ISA = qw(Exporter);
@EXPORT_OK = qw(
Expand Down Expand Up @@ -196,18 +196,13 @@ sub die_unsupported { die("OS unsupported\n"); }

=head3 list_platforms
When called in list context,
return a list of all the platforms for which the corresponding
Return a list of all the platforms for which the corresponding
Devel::AssertOS::* module is available. This includes both OSes and OS
families, and both those bundled with this module and any third-party
add-ons you have installed.
In scalar context, returns a hashref keyed by platform with the filename
of the most recent version of the supporting module that is available to you.
This behaviour is deprecated.
Unfortunately, on some platforms this list may have file case
broken. eg, some platforms might return 'freebsd' instead of 'FreeBSD'.
Unfortunately, on some platforms this list may have platform names'
case broken, eg you might see 'freebsd' instead of 'FreeBSD'.
This is because they have case-insensitive filesystems so things
should Just Work anyway.
Expand All @@ -221,13 +216,8 @@ my $re_AssertOS = qr/$case_flag ^AssertOS$/x;
my $re_Alias = qr/$case_flag ^Alias\b/x;

sub list_platforms {
# sort by mtime, so oldest last. This was necessary so that if a module
# appears twice in @INC we pick the newer one but that functionality is
# no longer needed. We do need to de-dupe the list though
my @modules = sort {
(stat($a->{file}))[9] <=> (stat($b->{file}))[9]
} grep {
$_->{module} !~ $re_Alias
my @modules = sort keys %{ {map { $_ => 1 } grep {
$_ !~ $re_Alias
} map {
my (undef, $dir_part, $file_part) = File::Spec->splitpath($_);
$file_part =~ s/\.pm$//;
Expand All @@ -240,32 +230,19 @@ sub list_platforms {
splice @dirs, 0, $i + 1;
last;
}
{
module => join('::', @dirs, $file_part),
file => File::Spec->canonpath($_)
}
join('::', @dirs, $file_part);
} _find_pm_files_in_dirs(
grep { -d }
map { File::Spec->catdir($_, qw(Devel AssertOS)) }
@INC
);
)}};

my %modules = map {
$_->{module} => $_->{file}
} @modules;

if(wantarray()) {
return sort keys %modules;
} else {
warn("Calling list_platforms in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n") unless($Devel::CheckOS::NoDeprecationWarnings::Context);
return \%modules;
}
return @modules;
}

=head3 list_family_members
Takes the name of an OS 'family' and returns a list of all its members.
In list context, you get a list, in scalar context you get an arrayref.
If called on something that isn't a family, you get an empty list (or
a ref to an empty array).
Expand All @@ -279,16 +256,10 @@ sub list_family_members {
# this will die if it's the wrong OS, but the module is loaded ...
eval qq{use Devel::AssertOS::$family};
# ... so we can now query it
my @members = eval qq{
return eval qq{
no strict 'refs';
&{"Devel::AssertOS::${family}::matches"}()
};
if(wantarray()) {
return @members;
} else {
warn("Calling list_family_members in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n") unless($Devel::CheckOS::NoDeprecationWarnings::Context);
return \@members;
}
}

=head3 register_alias
Expand Down Expand Up @@ -354,13 +325,9 @@ open source endeavours by buying me something from my wishlist:
Version 1.90 made all matches case-insensitive. This is a change in behaviour, but
if it breaks your code then your code was already broken, you just didn't know it.
=head1 DEPRECATIONS
At some point after April 2024 the C<list_family_members> and C<list_platforms>
functions will stop being sensitive to whether they are called in list context or
not, and will always return a list. From now until then calling them in non-list
context will emit a warning. You can turn that off by setting
C<$Devel::CheckOS::NoDeprecationWarnings::Context> to a true value.
As of version 2.00 the list_* functions always return plain old lists. Calling them
in scalar context was deprecated and has emitted warnings for over 2 years, since
version 1.90.
=head1 SEE ALSO
Expand Down
15 changes: 1 addition & 14 deletions t/checkos.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,8 @@ ok(!(grep { /^Alias::MacOS$/i } Devel::CheckOS::list_platforms()),
"list_platforms excludes Aliases");

eval "use lib File::Spec->catdir(qw(t otherlib))";
sleep(2);
utime time(), time(), File::Spec->catfile(qw(t otherlib Devel AssertOS AnOperatingSystem.pm));

ok(1 == (grep { /^AnOperatingSystem$/i } Devel::CheckOS::list_platforms()),
is(1, (grep { /^AnOperatingSystem$/i } Devel::CheckOS::list_platforms()),
"A platform is listed only once");
{
local $Devel::CheckOS::NoDeprecationWarnings::Context = 1;
ok(Devel::CheckOS::list_platforms->{AnOperatingSystem} eq
File::Spec->catfile(qw(t otherlib Devel AssertOS AnOperatingSystem.pm)),
"scalar list_platforms gives the most recent module for an OS");
}

is
warning { my $foo = Devel::CheckOS::list_platforms() },
"Calling list_platforms in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n",
"list_platforms in scalar context == warning";

done_testing;
2 changes: 0 additions & 2 deletions t/lib/Devel/AssertOS/AnOperatingSystem.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: AnOperatingSystem.pm,v 1.1 2007/09/30 13:49:17 drhyde Exp $

package Devel::AssertOS::AnOperatingSystem;

use Devel::CheckOS qw(die_unsupported);
Expand Down
2 changes: 0 additions & 2 deletions t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: v1.pm,v 1.2 2007/10/18 13:31:25 drhyde Exp $

package Devel::AssertOS::AnOperatingSystem::v1;

use Devel::CheckOS qw(die_unsupported);
Expand Down
2 changes: 0 additions & 2 deletions t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: v2.pm,v 1.1 2007/10/18 13:29:34 drhyde Exp $

package Devel::AssertOS::AnOperatingSystem::v2;

use Devel::CheckOS qw(die_unsupported);
Expand Down
2 changes: 0 additions & 2 deletions t/lib/Devel/AssertOS/NotAnOperatingSystem.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: NotAnOperatingSystem.pm,v 1.1 2007/09/30 13:49:17 drhyde Exp $

package Devel::AssertOS::NotAnOperatingSystem;

use Devel::CheckOS qw(die_unsupported);
Expand Down
19 changes: 0 additions & 19 deletions t/list_family_members.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,4 @@ is_deeply(
'array list_family_members works for DEC family'
);

{
local $Devel::CheckOS::NoDeprecationWarnings::Context = 1;
is_deeply(
scalar(Devel::CheckOS::list_family_members('DEC')),
[qw(OSF VMS)],
'scalar list_family_members works for DEC family'
);
is_deeply(
scalar(Devel::CheckOS::list_family_members('MicrosoftWindows')),
[qw(Cygwin MSWin32 MSYS)],
'scalar list_family_members works for MicrosoftWindows family'
);
}

is
warning { my $foo = Devel::CheckOS::list_family_members('MicrosoftWindows') },
"Calling list_family_members in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n",
"list_platforms in scalar context == warning";

done_testing;
2 changes: 0 additions & 2 deletions t/otherlib/Devel/AssertOS/AnOperatingSystem.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# $Id: AnOperatingSystem.pm,v 1.1 2008/05/29 21:55:46 drhyde Exp $

package Devel::AssertOS::AnOperatingSystem;

use Devel::CheckOS qw(die_unsupported);
Expand Down
1 change: 0 additions & 1 deletion t/pod.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# $Id: pod.t,v 1.1 2008/06/16 15:01:29 drhyde Exp $
use strict;

$^W=1;
Expand Down

0 comments on commit e778574

Please sign in to comment.