Diff/State.pm

filter: Statementstmt 70.0% 21 / 30 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod n/a totaltotal 52.0% 26 / 50 CC 6 SCAR 30.7
CC
6
Cov
51%
__ANON__
42.0
__ANON__
1.1
BEGIN
1.0
CRAP 21.5
« Diff/Role/Common.pm ↑ Summary Diff.pm »
1 package DBIx::Class::Schema::Diff::State;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 # ABSTRACT: Diff object of a single schema
6  
7 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 extends 'DBIx::Class::Schema::Diff';
9 #with 'DBIx::Class::Schema::Diff::Role::Common';
10  
11 5 ▶use RapidApp::Util ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 require DBIx::Class::Schema::Diff::Schema;
14  
15 5 ▶use Types::Standard qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 0 ▶has 'schema', is => 'ro', isa => Maybe[Str], default => sub { undef };
Subroutine __ANON__: not called CC=1 SCAR=1.2
18  
19 5 has '_schema_diff', required => 1, is => 'ro', isa => InstanceOf['DBIx::Class::Schema::Diff::Schema'];
20  
21 around BUILDARGS => sub {
22 0 ▶ my ($orig, $self, @args) = @_;
Subroutine __ANON__: not called CC=6 SCAR=37.4
23 0 ▶ my %opt = (ref($args[0]) eq 'HASH') ? %{ $args[0] } : @args; # <-- arg as hash or hashref
Branch: 1 branch
BranchTrueFalseTotal
ref $args[0] eq 'HASH' ? : 0 0 0
24
25 0 ▶ die "Must supply single 'schema' not old_schema and new_schema" if ($opt{new_schema} || $opt{old_schema});
Branch: 1 branch
BranchTrueFalseTotal
if $opt{"new_schema"} or $opt{"old_schema"} 0 0 0
Condition0%0/3
$opt{"new_schema"} or $opt{"old_schema"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opt{"new_schema"} or $opt{"old_schema"}
$opt{"new_schema"} $opt{"old_schema"}
Truth table0%0/3
A or B
A= $opt{"new_schema"}B= $opt{"old_schema"}
ABresult
1X1
011
000
26
27 0 ▶ unless($opt{_schema_diff}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opt{"_schema_diff"}) 0 0 0
28 0 ▶ my $schema = $opt{schema} or die "schema argument required";
Branch: 1 branch
BranchTrueFalseTotal
my $schema = $opt{"schema"} or die "schema argument required" 0 0 0
29 0 $opt{_schema_diff} = DBIx::Class::Schema::Diff::Schema->new(
30 new_schema => $schema,
31 old_schema => $schema,
32 new_schema_only => 1
33 )
34 }
35
36 0 return $self->$orig(%opt)
37 5 };
38  
39  
40  
41 5 1;
42  
43  
44 __END__
45  
46 =head1 NAME
47  
48 DBIx::Class::Schema::Diff::State - Diff object of a single schema
49  
50 =head1 SYNOPSIS
51  
52 use DBIx::Class::Schema::Diff::State;
53
54 my $State = DBIx::Class::Schema::Diff::State->new(
55 schema => $schema
56 );
57
58 $State = $State->filter_out('isa');
59
60 # Get all info about the schema as 'differences' (hash structure):
61 my $hash = $D->diff;
62
63 # Git a checksum/fingerprint of the schema state data:
64 my $checksum = $State->fingerprint;
65  
66 =head1 DESCRIPTION
67  
68 This class is a subclass of L<DBIx::Class::Schema::Diff> and shares the same API
69 but instead of requiring a C<old_schema> and a C<new_schema>, it requires a single
70 C<schema> and then the "diff" is returned as if *everything* changed.
71  
72 This simply provides a way to explore the state/data of a single schema using the
73 same data structure as that of a normal diff between two schemas, and supporting
74 the very powerful, chainable C<filter> and C<filter_out> methods.
75  
76 This
77  
78  
79 =head1 SEE ALSO
80  
81 =over
82  
83 =item *
84  
85 L<DBIx::Class::Schema::Diff>
86  
87 =back
88  
89 =head1 AUTHOR
90  
91 Henry Van Styn <vanstyn@cpan.org>
92  
93 =head1 COPYRIGHT AND LICENSE
94  
95 This software is copyright (c) 2020 by IntelliTree Solutions llc.
96  
97 This is free software; you can redistribute it and/or modify it under
98 the same terms as the Perl 5 programming language system itself.
99  
100 =cut
« Diff/Role/Common.pm ↑ Summary Diff.pm »