Aion-Annotation
view release on metacpan or search on metacpan
"Aion" : "1.2",
"Aion::Carp" : "1.6",
"Aion::Fs" : "v0.2.0",
"Aion::Run" : "v0.0.3",
"POSIX" : "0",
"Time::Local" : "0",
"common::sense" : "0",
"config" : "0",
"open" : "0",
"perl" : "v5.22.0",
"utf8" : "0"
}
},
"test" : {
"requires" : {
"Carp" : "0",
"Cwd" : "0",
"Data::Dumper" : "0",
"File::Basename" : "0",
"File::Find" : "0",
"File::Path" : "0",
Aion: '1.2'
Aion::Carp: '1.6'
Aion::Fs: v0.2.0
Aion::Run: v0.0.3
POSIX: '0'
Time::Local: '0'
common::sense: '0'
config: '0'
open: '0'
perl: v5.22.0
utf8: '0'
resources:
bugtracker: https://github.com/darviarush/perl-aion-annotation/issues
homepage: https://github.com/darviarush/perl-aion-annotation
repository: https://github.com/darviarush/perl-aion-annotation.git
version: 0.0.3
x_authority: cpan:DART
x_contributors:
- 'Yaroslav O. Kosmina <dart@cpan.org>'
x_serialization_backend: 'CPAN::Meta::YAML version 0.020'
x_static_install: 0
requires 'Aion', '1.2';
requires 'Aion::Carp', '1.6';
requires 'Aion::Run', '0.0.3';
requires 'Aion::Fs', '0.2.0';
requires 'POSIX';
requires 'Time::Local';
requires 'common::sense';
requires 'config';
requires 'open';
requires 'utf8';
lib/Aion/Annotation.pm view on Meta::CPAN
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 };
while(<$f>) {
warn "$path corrupt on line $.!" unless /^([\w:]+)#(\w*),(\d+)=(.*)$/;
push @{$ann{$annotation_name}{$1}{$2}}, [$3, $4];
}
close $f;
}
\%ann
});
lib/Aion/Annotation.pm view on Meta::CPAN
# ÐомменÑаÑии: 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+)=(.*)$/;
$remark{$1}{$2} = [$3, [map { s/\\(.)/$1/gr } split /\\n/, $4]];
}
close $f;
\%remark
});
# ÐÑÑÑ Ðº ÑÐ°Ð¹Ð»Ñ Ñ Ð²Ñеменем поÑледнего доÑÑÑпа к модÑлÑм
lib/Aion/Annotation.pm view on Meta::CPAN
# ÐÑÐµÐ¼Ñ Ð¿Ð¾Ñледнего доÑÑÑпа к модÑлÑм: 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>) {
warn "$mtime_path corrupt on line $.!" unless /^(?<module>[\w:]+)=(?<year>\d{4})-(?<mon>\d{2})-(?<mday>\d{2}) (?<hour>\d{2}):(?<min>\d{2}):(?<sec>\d{2})$/;
$mtime{$+{module}} = timelocal($+{sec}, $+{min}, $+{hour}, $+{mday}, $+{mon} - 1, $+{year});
}
close $f;
\%mtime
});
# СканиÑÑÐµÑ Ð¼Ð¾Ð´Ñли и ÑоÑ
ÑанÑÐµÑ Ð°Ð½Ð½Ð¾ÑаÑии
lib/Aion/Annotation.pm view on Meta::CPAN
while(<$iter>) {
my $pkg = to_pkg(substr $_, 1 + length $lib);
$exists{$pkg} = 1;
my $mtime = int mtime;
next if !$self->force && exists $modules_mtime->{$pkg} && $modules_mtime->{$pkg} == $mtime;
$modules_mtime->{$pkg} = $mtime;
delete $_->{$pkg} for values %$ann;
delete $remark->{$pkg};
open my $f, "<:utf8", $_ or do { warn "$_ not opened: $!"; next };
my @ann; my @rem;
my $save_annotation = sub {
my ($name, $pkg1) = @_;
$pkg1 //= $pkg;
push @{$ann->{$_->[0]}{$pkg1}{$name}}, $_->[1] for @ann;
$remark->{$pkg1}{$name} = [$., [@rem]] if @rem;
@ann = @rem = ();
};
while(<$f>) {
last if /^(__END__|__DATA__)\s*$/;
lib/Aion/Annotation.pm view on Meta::CPAN
mkpath($self->ini . "/");
# СоÑ
ÑанÑм анноÑаÑии и ÑдалÑем ÑÐ°Ð¹Ð»Ñ Ñ Ð°Ð½Ð½Ð¾ÑаÑиÑми, коÑоÑÑÑ
Ñже Ð½ÐµÑ Ð² пÑоекÑе
for my $annotation_name (sort keys %$ann) {
my $pkgs = $ann->{$annotation_name};
my $path = $self->annotation_path($annotation_name);
if(!keys %$pkgs) {
erase($path) if -e $path;
next;
}
open my $f, ">:utf8", $path or do { warn "$path not writed: $!" };
for my $pkg (sort keys %$pkgs) {
my $subs = $pkgs->{$pkg};
for my $sub (sort keys %$subs) {
my $annotation = $subs->{$sub};
print $f "$pkg#$sub,$_->[0]=$_->[1]\n" for @$annotation;
}
}
close $f;
}
# УдалÑем вÑеменна Ñайлов, коÑоÑÑÑ
Ñже Ð½ÐµÑ Ð² пÑоекÑе
for my $pkg (keys %$modules_mtime) {
delete $modules_mtime->{$pkg} if !exists $exists{$pkg};
}
# СоÑ
ÑанÑем вÑÐµÐ¼Ñ Ð¿Ð¾Ñледнего Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ñайлов
my $mtime_path = mkpath $self->modules_mtime_path;
open my $f, ">:utf8", $mtime_path or do { warn "$mtime_path not writed: $!" };
printf $f "%s=%s\n", $_, strftime('%Y-%m-%d %H:%M:%S', localtime $modules_mtime->{$_}) for sort grep { $modules_mtime->{$_} } keys %$modules_mtime;
close $f;
# СоÑ
ÑанÑем комменÑаÑии
my $remark_path = $self->remark_path;
open my $f, ">:utf8", $remark_path or do { warn "$remark_path not writed: $!" };
for my $pkg (sort keys %$remark) {
next if !exists $exists{$pkg};
my $subs = $remark->{$pkg};
for my $sub (sort keys %$subs) {
my ($line, $rem) = @{$subs->{$sub}};
print $f "$pkg#$sub,$line=", join("\\n", @$rem), "\n" if @$rem;
}
}
close $f;
script/aion-scan view on Meta::CPAN
#!/usr/bin/perl
use utf8;
use open qw/:std :utf8/;
use Aion::Carp;
use Aion::Annotation;
Aion::Annotation->new_from_args(\@ARGV)->scan
t/aion/annotation.t view on Meta::CPAN
use common::sense; use open qw/:std :utf8/; use Carp qw//; use Cwd qw//; use File::Basename qw//; use File::Find qw//; use File::Slurper qw//; use File::Spec qw//; use File::Path qw//; use Scalar::Util qw//; use Test::More 0.98; use String::Diff q...
# # NAME
#
# Aion::Annotation - обÑабаÑÑÐ²Ð°ÐµÑ Ð°Ð½Ð½Ð¾ÑаÑии в модÑлÑÑ
perl
#
# # VERSION
#
# 0.0.2-prealpha
#
# # SYNOPSIS
#
( run in 0.354 second using v1.01-cache-2.11-cpan-30a0b3e4e11 )