| 1 | # | ||||||||||||
| 2 | # This file is part of Jedi-Plugin-Session | ||||||||||||
| 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 Jedi::Plugin::Session::Role::SQLite; | ||||||||||||
| 10 | |||||||||||||
| 11 | # ABSTRACT: SQLite Backend | ||||||||||||
| 12 | |||||||||||||
| 13 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 2 | our $VERSION = '0.05'; # VERSION | |||||||||||
| 16 | |||||||||||||
| 17 | 2 | ▶ | use File::ShareDir; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 2 | ▶ | use Path::Class; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 2 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 2 | ▶ | use Jedi::Plugin::Session::Backend::SQLite; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 2 | ▶ | use Moo::Role; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | |||||||||||||
| 23 | 2 | ▶ | sub _build__jedi_session { | ||||||||||
|
Subroutine
_build__jedi_session: called CC=4 SCAR=13.9
| |||||||||||||
| 24 | 2 | my ($self) = @_; | |||||||||||
| 25 | 2 | my $class = ref $self; | |||||||||||
| 26 | my $expires_in = $self->jedi_config->{$class}{session}{expiration} | ||||||||||||
| 27 | 2 | ▶ | // '3 hours'; | ||||||||||
|
Condition50%1/2
$self->jedi_config->{$class}{"session"}{"expiration"} // "3 hours"
MC/DC0%0/1
$self->jedi_config->{$class}{"session"}{"expiration"} // "3 hours"
$self->jedi_config->{$class}{"session"}{"expiration"}
Truth table50%1/2
A
A= $self->jedi_config->{$class}{"session"}{"expiration"}
| |||||||||||||
| 28 | 2 | my $sqlite_path = $self->jedi_config->{$class}{session}{sqlite}{path}; | |||||||||||
| 29 | 2 | ▶ | if ( !defined $sqlite_path ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 1 | $sqlite_path = dir( File::ShareDir::dist_dir('Jedi-Plugin-Session') ); | |||||||||||
| 31 | } | ||||||||||||
| 32 | croak | ||||||||||||
| 33 | 2 | ▶ | "SQLite path is missing and cannot be guest. Please setup the configuration file." | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | if !defined $sqlite_path; | ||||||||||||
| 35 | 2 | my $app_dir = dir( $sqlite_path, split( /::/x, $class ) ); | |||||||||||
| 36 | 2 | my $sqlite_db_file = file( $app_dir . '.db' ); | |||||||||||
| 37 | 2 | return Jedi::Plugin::Session::Backend::SQLite->new( | |||||||||||
| 38 | database => $sqlite_db_file, | ||||||||||||
| 39 | expires_in => $expires_in, | ||||||||||||
| 40 | ); | ||||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 2 | 1; | |||||||||||
| 44 | |||||||||||||
| 45 | __END__ | ||||||||||||