---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
blib/lib/App/KeePass2.pm 49.0 0.0 n/a 61.5 100.0 100.0 46.5
Total 49.0 0.0 n/a 61.5 100.0 100.0 46.5
---------------------------- ------ ------ ------ ------ ------ ------ ------
Run: t/00-compile.t
Perl version: 5.16.3
OS: linux
Start: Fri May 10 15:18:51 2013
Finish: Fri May 10 15:18:51 2013
Run: t/000-report-versions.t
Perl version: 5.16.3
OS: linux
Start: Fri May 10 15:18:51 2013
Finish: Fri May 10 15:18:51 2013
Run: t/author-critic.t
Perl version: 5.16.3
OS: linux
Start: Fri May 10 15:18:52 2013
Finish: Fri May 10 15:18:54 2013
Run: t/release-pod-coverage.t
Perl version: 5.16.3
OS: linux
Start: Fri May 10 15:18:55 2013
Finish: Fri May 10 15:18:55 2013
Run: t/release-unused-vars.t
Perl version: 5.16.3
OS: linux
Start: Fri May 10 15:18:55 2013
Finish: Fri May 10 15:18:56 2013
Run: t/release-unused-vars.t
Perl version: 5.16.3
OS: linux
Start: Fri May 10 15:18:55 2013
Finish: Fri May 10 15:18:56 2013
blib/lib/App/KeePass2.pm
line err stmt bran cond sub pod time code
1 #
2 # This file is part of App-KeePass2
3 #
4 # This software is copyright (c) 2013 by celogeek <me@celogeek.com>.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package App::KeePass2;
10
11 # ABSTRACT: KeePass2 commandline tools
12
13 2 2 157190 use strict;
2 6
2 111
14 2 2 6 use warnings;
2 4
2 90
15 our $VERSION = '0.02'; # VERSION
16 2 2 427 use Moo;
2 14286
2 25
17 2 2 1977 use MooX::Options;
2 969
2 28
18 2 2 119740 use File::KeePass;
2 20915
2 50
19 2 2 543 use IO::Prompt;
2 22896
2 30
20 2 2 80 use Carp;
2 2
2 68
21 2 2 647 use Data::Printer;
2 22868
2 32
22
23 option 'file' => (
24 doc => 'Your keepass2 file',
25 is => 'ro',
26 short => 'f',
27 required => 1,
28 format => 's',
29 );
30
31 option 'create' => (
32 doc => 'Create a keepass2 file',
33 is => 'ro',
34 short => 'c',
35 );
36
37 option 'dump' => (
38 doc => 'Dump a keepass2 file',
39 is => 'ro',
40 short => 'd',
41 );
42
43 has _fkp => (
44 is => 'ro',
45 default => sub {
46 File::KeePass->new;
47 }
48 );
49
50 sub run {
51 *** 0 0 1 my ($self) = @_;
52 *** 0 0 $self->_create, return if ( $self->create );
53 *** 0 0 $self->_dump, return if ( $self->dump );
54 *** 0 return;
55 }
56
57 sub _get_master_key {
58 *** 0 0 my ($self) = @_;
59 *** 0 return "" . prompt( "Master Password : ", -e => "*", -tty );
60 }
61
62 sub _get_confirm_key {
63 *** 0 0 my ($self) = @_;
64 *** 0 return "" . prompt( "Confirm Password : ", -e => "*", -tty );
65 }
66
67 sub _create {
68 *** 0 0 my ($self) = @_;
69 *** 0 $self->_fkp->clear;
70 *** 0 my $root
71 = $self->_fkp->add_group( { title => 'My Passwords', icon => 52 } );
72 *** 0 my $gid = $root->{'id'};
73 *** 0 $self->_fkp->add_group(
74 { title => 'Internet', group => $gid, icon => 1 } );
75 *** 0 $self->_fkp->add_group(
76 { title => 'Private', group => $gid, icon => 58 } );
77 *** 0 $self->_fkp->add_group( { title => 'Bank', group => $gid, icon => 66 } );
78 *** 0 0 $self->_fkp->unlock if $self->_fkp->is_locked;
79 *** 0 my $master = $self->_get_master_key;
80 *** 0 my $confirm = $self->_get_confirm_key;
81 *** 0 0 croak "Your master password is different from the confirm password !"
82 if $master ne $confirm;
83 *** 0 $self->_fkp->save_db( $self->file, $master );
84 *** 0 return;
85 }
86
87 sub _dump {
88 *** 0 0 my ($self) = @_;
89 *** 0 $self->_fkp->load_db( $self->file, $self->_get_master_key );
90 *** 0 p( $self->_fkp->groups );
91 *** 0 return;
92 }
93 1;
94
95 __END__
Branches
--------
line err % true false branch
----- --- ------ ------ ------ ------
52 *** 0 0 0 if $self->create
53 *** 0 0 0 if $self->dump
78 *** 0 0 0 if $self->_fkp->is_locked
81 *** 0 0 0 if $master ne $confirm
Covered Subroutines
-------------------
Subroutine Count Pod Location
---------------- ----- --- ---------------------------
BEGIN 2 blib/lib/App/KeePass2.pm:13
BEGIN 2 blib/lib/App/KeePass2.pm:14
BEGIN 2 blib/lib/App/KeePass2.pm:16
BEGIN 2 blib/lib/App/KeePass2.pm:17
BEGIN 2 blib/lib/App/KeePass2.pm:18
BEGIN 2 blib/lib/App/KeePass2.pm:19
BEGIN 2 blib/lib/App/KeePass2.pm:20
BEGIN 2 blib/lib/App/KeePass2.pm:21
Uncovered Subroutines
---------------------
Subroutine Count Pod Location
---------------- ----- --- ---------------------------
_create 0 blib/lib/App/KeePass2.pm:68
_dump 0 blib/lib/App/KeePass2.pm:88
_get_confirm_key 0 blib/lib/App/KeePass2.pm:63
_get_master_key 0 blib/lib/App/KeePass2.pm:58
run 0 1 blib/lib/App/KeePass2.pm:51