File Coverage

blib/lib/DBIx/Class/DeploymentHandler/VersionStorage/Deprecated/VersionResultSet.pm
Criterion Covered Total %
statement 28 28 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 3 3 100.0
total 40 40 100.0


line stmt bran cond sub pod time code
1             package DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet;
2             $DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet::VERSION = '0.002233';
3             # ABSTRACT: (DEPRECATED) Predefined searches to find what you want from the version storage
4              
5 1     1   645 use strict;
  1         2  
  1         29  
6 1     1   5 use warnings;
  1         2  
  1         29  
7              
8 1     1   5 use parent 'DBIx::Class::ResultSet';
  1         2  
  1         7  
9              
10 1     1   74 use Try::Tiny;
  1         2  
  1         74  
11 1     1   464 use Time::HiRes 'gettimeofday';
  1         1183  
  1         4  
12              
13             sub version_storage_is_installed {
14 2     2 1 28 my $self = shift;
15 2     1   92 try { $self->count; 1 } catch { undef }
  1         3128  
  1         10616  
16 2         19 }
17              
18             sub database_version {
19 2     2 1 28 my $self = shift;
20 2         20 $self->search(undef, {
21             order_by => { -desc => 'installed' },
22             rows => 1
23             })->get_column('version')->next;
24             }
25              
26             # this is why it's deprecated guys... Serially.
27             sub create {
28 3     3 1 9 my $self = shift;
29 3         7 my $args = shift;
30              
31 3         18 my @tm = gettimeofday();
32 3         45 my @dt = gmtime ($tm[0]);
33              
34             $self->next::method({
35 3         9 %{$args},
  3         75  
36             installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f",
37             $dt[5] + 1900,
38             $dt[4] + 1,
39             $dt[3],
40             $dt[2],
41             $dt[1],
42             $dt[0],
43             $tm[1] / 1000, # convert to millisecs, format as up/down rounded int above
44             ),
45             });
46             }
47              
48             1;
49              
50             # vim: ts=2 sw=2 expandtab
51              
52             __END__
53              
54             =pod
55              
56             =head1 NAME
57              
58             DBIx::Class::DeploymentHandler::VersionStorage::Deprecated::VersionResultSet - (DEPRECATED) Predefined searches to find what you want from the version storage
59              
60             =head1 DEPRECATED
61              
62             This component has been suplanted by
63             L<DBIx::Class::DeploymentHandler::VersionStorage::Standard::VersionResultSet>.
64             In the next major version (1) we will begin issuing a warning on it's use.
65             In the major version after that (2) we will remove it entirely.
66              
67             =head1 METHODS
68              
69             =head2 version_storage_is_installed
70              
71             True if (!!!) the version storage has been installed
72              
73             =head2 database_version
74              
75             The version of the database
76              
77             =head2 create
78              
79             Overridden to default C<installed> to the current time. (take a look, it's yucky)
80              
81             =head1 AUTHOR
82              
83             Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2019 by Arthur Axel "fREW" Schmidt.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut