Activity.pm

filter: Statementstmt 46.6% 14 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 100% 1 / 1 totaltotal 44.1% 19 / 43 CC 4 SCAR 17.5
CC
4
Cov
39%
__ANON__
12.0
changed_files
6.0
BEGIN
1.0
CRAP 5.8
« Database/Model/FileHashes.pm ↑ Summary Database/DB.pm »
1 package Daje::Workflow::FileChanged::Activity;
2 1 ▶use Mojo::Base 'Daje::Workflow::Common::Activity::Base', -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use Daje::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Daje::Tools::Filechanged;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Daje::Workflow::FileChanged::Database::Model::FileHashes;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # NAME
9 #
10 # Daje::Workflow::FileChanged::Activity - It's new $module
11 #
12 # SYNOPSIS
13 # ========
14 # use Daje::Workflow::FileChanged::Activity;
15 #
16 # my $activity = Daje::Workflow::FileChanged::Activity->new(
17 # db => $db,
18 # context => $context,
19 # error => $error,
20 # );
21 #
22 # $activity->changed_files();
23 #
24 #
25 # DESCRIPTION
26 # ===========
27 #
28 # Daje::Workflow::FileChanged::Activity is ...
29 #
30 # LICENSE
31 #
32 # Copyright (C) janeskil1525.
33 #
34 # This library is free software; you can redistribute it and/or modify
35 # it under the same terms as Perl itself.
36 #
37 #
38 # LICENSE
39 # =======
40 #
41 # Copyright (C) janeskil1525.
42 #
43 # This library is free software; you can redistribute it and/or modify
44 # it under the same terms as Perl itself.
45 #
46 # AUTHOR
47 # ======
48 # janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
49 #
50  
51  
52 1 our $VERSION = "0.03";
53  
54 0 ▶sub changed_files($self) {
Subroutine changed_files: not called CC=2 SCAR=17.9
Pod documented
55  
56 0 my @changed_files;
57 my $filelist = Daje::Config->new(
58 path => $self->context->{context}->{source_dir}
59 0 )->load_list();
60  
61 0 $self->model->insert_history(
62 $filelist->size . " files found", "Daje::Workflow::FileChanged::Activity", 0
63 );
64  
65 0 my $filehash = Daje::Workflow::FileChanged::Database::Model::FileHashes->new(
66 db => $self->db
67 );
68 0 my $changed = Daje::Tools::Filechanged->new();
69 0 ▶ $filelist->each(sub ($file, $num) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
70 0 my $hash_data = $filehash->load_hash($file);
71 0 ▶ unless (defined $hash_data) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash_data) { } 0 0 0
72 0 my $hash = $changed->load_new_hash($file);
73 0 $filehash->save_hash($file, $hash);
74 0 push (@changed_files, $file);
75 } else {
76 0 ▶ if($changed->is_file_changed($file, $hash_data)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed->is_file_changed($file, $hash_data)) 0 0 0
77 0 push (@changed_files, $file);
78 }
79 }
80 0 });
81  
82 0 $self->model->insert_history(
83 scalar(@changed_files) . " changed files found", "Daje::Workflow::FileChanged::Activity", 0
84 );
85  
86 0 ▶ if (@changed_files > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@changed_files > 0) 0 0 0
87 0 $self->context->{context}->{changed_files} = \@changed_files;
88 }
89 }
90  
91 1 1;
92 __END__
« Database/Model/FileHashes.pm ↑ Summary Database/DB.pm »