Aion-Annotation

 view release on metacpan or  search on metacpan

lib/Aion/Annotation.pm  view on Meta::CPAN


use Aion::Fs qw/find erase mkpath path mtime from_pkg to_pkg/;
use POSIX qw/strftime/;
use Time::Local qw/timelocal/;

use Aion;

with qw/Aion::Run/;

# Кодовая база для сканирования
has lib => (is => 'ro', isa => ArrayRef[Str], arg => '-l', default => LIB);

# Директория куда сохранять файлы аннотаций
has ini => (is => 'ro', isa => Str, arg => '-i', default => INI);

# Просто считать аннотации
has force => (is => 'ro', isa => Bool, arg => '-f', default => 0);

# Аннотации: annotation_name.pkg.sub_or_has_name => [[line, annotation_desc]...]
has ann => (is => 'ro', isa => HashRef[HashRef[HashRef[ArrayRef[Tuple[Int, Str]]]]], default => sub {
	my $self = shift;
	my %ann;
	return \%ann if $self->force;

	return \%ann if !-d(my $ini = $self->ini);

	while(<$ini/*.ann>) {
		my $path = $_;
		my $annotation_name = path()->{name};
		open my $f, "<:utf8", $_ or do { warn "$_ not opened: $!"; next };

lib/Aion/Annotation.pm  view on Meta::CPAN

		close $f;
	}

	\%ann
});

# Путь к файлу с комментариями
has remark_path => (is => 'ro', isa => Str, default => sub { shift->ini . "/remarks.ini" });

# Комментарии: pkg.sub_or_has_name => [[line, remark]...]
has remark => (is => 'ro', isa => HashRef[HashRef[Tuple[Int, ArrayRef[Str]]]], default => sub {
	my ($self) = @_;
	my %remark;
	return \%remark if $self->force;

	my $remark_path = $self->remark_path;
	return \%remark if !-e $remark_path;

	open my $f, "<:utf8", $remark_path or do { warn "$remark_path not opened: $!"; return \%remark };
	while(<$f>) {
		warn "$remark_path corrupt on line $.!" unless /^([\w:]+)#(\w*),(\d+)=(.*)$/;

lib/Aion/Annotation.pm  view on Meta::CPAN

	}
	close $f;

	\%remark
});

# Путь к файлу с временем последнего доступа к модулям
has modules_mtime_path => (is => 'ro', isa => Str, default => CACHE . "/modules.mtime.ini");

# Время последнего доступа к модулям: pkg => unixtime
has modules_mtime => (is => 'ro', isa => HashRef[Int], default => sub {
	my ($self) = @_;

	my %mtime;
	return \%mtime if $self->force;

	my $mtime_path = $self->modules_mtime_path;
	return \%mtime if !-e $mtime_path;

	open my $f, "<:utf8", $mtime_path or do { warn "$mtime_path not opened: $!"; return 0 };
	while(<$f>) {



( run in 0.188 second using v1.01-cache-2.11-cpan-9ff20fc0ed8 )