| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Daje::Tools::Filechanged; |
|
2
|
1
|
|
|
1
|
|
242176
|
use Mojo::Base -base, -signatures; |
|
|
1
|
|
|
|
|
40969
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4177
|
use Digest::SHA qw(sha256_hex); |
|
|
1
|
|
|
|
|
4218
|
|
|
|
1
|
|
|
|
|
88
|
|
|
5
|
1
|
|
|
1
|
|
425
|
use Mojo::File; |
|
|
1
|
|
|
|
|
372901
|
|
|
|
1
|
|
|
|
|
661
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Daje::Tools::Filechanged - It's new $module |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# SYNOPSIS |
|
10
|
|
|
|
|
|
|
# ======== |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# use Daje::Tools::Filechanged; |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# my $changes = Daje::Tools::Filechanged->new( |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# )->is_file_changed( |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# $file_path_name, $old_hash |
|
19
|
|
|
|
|
|
|
# ): |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# DESCRIPTION |
|
22
|
|
|
|
|
|
|
# =========== |
|
23
|
|
|
|
|
|
|
# |
|
24
|
|
|
|
|
|
|
# Daje::Tools::Filechanged is a tool to check if two hashes are equal |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# |
|
27
|
|
|
|
|
|
|
# METHODS |
|
28
|
|
|
|
|
|
|
# ======= |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
# my $changed = $self->is_file_changed($file_path_name, $old_hash); |
|
31
|
|
|
|
|
|
|
# |
|
32
|
|
|
|
|
|
|
# Is the hashes different ? |
|
33
|
|
|
|
|
|
|
# LICENSE |
|
34
|
|
|
|
|
|
|
# ======= |
|
35
|
|
|
|
|
|
|
# |
|
36
|
|
|
|
|
|
|
# Copyright (C) janeskil1525. |
|
37
|
|
|
|
|
|
|
# |
|
38
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or modify |
|
39
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
|
40
|
|
|
|
|
|
|
# |
|
41
|
|
|
|
|
|
|
# AUTHOR |
|
42
|
|
|
|
|
|
|
# ====== |
|
43
|
|
|
|
|
|
|
# |
|
44
|
|
|
|
|
|
|
# janeskil1525 janeskil1525@gmail.com |
|
45
|
|
|
|
|
|
|
# |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Is the hashes different ? |
|
50
|
0
|
|
|
0
|
0
|
|
sub is_file_changed($self, $file_path_name, $old_hash) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $result = 0; |
|
52
|
0
|
|
|
|
|
|
my $path = Mojo::File->new($file_path_name); |
|
53
|
0
|
|
|
|
|
|
my $new_hash = $self->load_new_hash($path); |
|
54
|
0
|
0
|
|
|
|
|
$old_hash = "" unless defined $old_hash; |
|
55
|
0
|
0
|
|
|
|
|
if ($new_hash ne $old_hash) { |
|
56
|
0
|
|
|
|
|
|
$result = 1; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
0
|
|
|
|
|
|
return $result; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Load new hash |
|
62
|
0
|
|
|
0
|
0
|
|
sub load_new_hash($self, $path) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $file_content = $path->slurp; |
|
64
|
0
|
|
|
|
|
|
my $hash = sha256_hex($file_content); |
|
65
|
0
|
|
|
|
|
|
return $hash; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |