File Coverage

blib/lib/Sentry/DSN.pm
Criterion Covered Total %
statement 36 37 97.3
branch 3 4 75.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 47 52 90.3


line stmt bran cond sub pod time code
1             package Sentry::DSN;
2 5     5   252576 use Mojo::Base -base, -signatures;
  5         11  
  5         80  
3              
4 5     5   8124 use Mojo::URL;
  5         286603  
  5         42  
5              
6             has _url => undef;
7             has protocol => sub ($self) { $self->_url->protocol };
8             has user => sub ($self) { $self->_parse_user($self->_url->userinfo) };
9             has pass => sub ($self) { $self->_parse_pass($self->_url->userinfo) };
10             has host => sub ($self) { $self->_url->host };
11             has port => sub ($self) { $self->_url->port };
12             has path => sub ($self) { $self->_parse_path($self->_url->path) };
13             has project_id => sub ($self) { $self->_parse_project_id($self->_url->path) };
14             has host_port => sub ($self) { $self->_url->host_port };
15              
16 22     22 0 276389 sub parse ($package, $url) {
  22         72  
  22         31  
  22         35  
17 22   33     171 return $url && Sentry::DSN->new(_url => Mojo::URL->new($url));
18             }
19              
20 11     11   89 sub _parse_user ($self, $auth) {
  11         16  
  11         16  
  11         13  
21 11         91 my @info = split /:/, $auth;
22 11         75 return $info[0];
23             }
24              
25 11     11   63 sub _parse_pass ($self, $auth) {
  11         12  
  11         15  
  11         14  
26 11         36 my @info = split /:/, $auth;
27 11         52 return $info[1];
28             }
29              
30 2     2   30 sub _parse_path ($self, $path) {
  2         3  
  2         3  
  2         2  
31 2 100       6 if ($path =~ m{\A (.+) / \d+ \z}xms) {
32 1         414 return $1;
33             }
34              
35 1         108 return '';
36             }
37              
38 11     11   171 sub _parse_project_id ($self, $path) {
  11         39  
  11         17  
  11         15  
39 11 50       34 if ($path =~ m{(\d+) /? \z}xms) {
40 11         1126 return $1;
41             }
42              
43 0           return undef;
44             }
45              
46             1;