#!/usr/bin/perl
our
$VERSION
=
'0.999_001'
;
Readonly
my
$LOCALTIME_YEAR_FIELD_NUMBER
=> 5;
Readonly
my
$LOCALTIME_YEAR_OFFSET
=> 1900;
my
$this_year
=
(
localtime
)[
$LOCALTIME_YEAR_FIELD_NUMBER
] +
$LOCALTIME_YEAR_OFFSET
;
my
$copyrights_found
= 0;
find({
wanted
=> \
&check_file
,
no_chdir
=> 1},
'lib'
);
foreach
(
grep
{ m/^readme/ixms } read_dir(
q<.>
) ) {
check_file();
}
ok(
$copyrights_found
!= 0,
'found a copyright statement'
);
sub
check_file {
return
if
(! -f
$_
);
return
if
not
m<
^
(?: README.*
| .*/scripts/[^/]+
| .*/script/[^/]+
| .*/bin/[^/]+
| .*\.(?:
pl
| pm
| html
| 3pm
| [13]
)
)
$
>xms;
my
$content
= read_file(
$_
);
my
@copyright_years
=
$content
=~ m<
(?: copyright(?:\s\(c\))? | \(c\) )
\s*
(?: \d{4} \\? [-,]\s*)*
(\d{4})
>gixms;
if
(0 <
grep
{
$_
eq
$this_year
}
@copyright_years
) {
pass(
$_
);
}
elsif
(0 ==
@copyright_years
) {
pass(
"$_, no copyright found"
);
}
else
{
fail(
"$_ copyrights: @copyright_years"
);
}
return
$copyrights_found
+=
@copyright_years
;
}