OpenGbg.pm

filter: Statementstmt 78.8% 56 / 71 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 65.2% 15 / 23 Podpod n/a totaltotal 75.5% 71 / 94 CC 1 SCAR 3.0
CC
1
Cov
79%
_build_config_file
2.0
_build_config
2.0
_build_key
2.0
CRAP 1.3
« OpenGbg/Service/AirQuality/GetLatestMeasurement.pm ↑ Summary OpenGbg/Service/TrafficCamera.pm »
1 5 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 package OpenGbg;
6  
7 # ABSTRACT: An interface to the Open Data API of Gothenburg
8 5 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 5 our $VERSION = '0.1404';
10  
11 5 ▶use OpenGbg::Elk;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 ▶use Config::Any;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use File::HomeDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use HTTP::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use Types::Standard qw/HashRef Str/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Types::Path::Tiny qw/AbsFile/;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 5 ▶use OpenGbg::Service::AirQuality;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 5 ▶use OpenGbg::Service::Bridge;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 5 ▶use OpenGbg::Service::StyrOchStall;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use OpenGbg::Service::TrafficCamera;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 5 has config_file => (
27 is => 'ro',
28 isa => AbsFile,
29 lazy => 1,
30 builder => 1,
31 init_arg => undef,
32 );
33 5 has config => (
34 is => 'ro',
35 isa => HashRef,
36 lazy => 1,
37 builder => 1,
38 init_arg => undef,
39 );
40 5 has key => (
41 is => 'ro',
42 isa => Str,
43 lazy => 1,
44 builder => 1,
45 );
46 5 has ua => (
47 is => 'ro',
48 builder => 1,
49 handles => ['get'],
50 );
51 5 has base => (
52 is => 'ro',
53 isa => Str,
54 default => 'http://data.goteborg.se/',
55 );
56  
57 5 my @services = qw/
58 air_quality
59 bridge
60 styr_och_stall
61 traffic_camera
62 /;
63 5 foreach my $service (@services) {
64 20 has $service => (
65 is => 'ro',
66 lazy => 1,
67 builder => 1,
68 );
69 }
70  
71 0 ▶sub _build_config_file {
Subroutine _build_config_file: not called CC=1 SCAR=6.9
72 0 my $home = File::HomeDir->my_home;
73 0 my $conf_file = path($home)->child('.opengbg.ini');
74 }
75 0 ▶sub _build_config {
Subroutine _build_config: not called CC=1 SCAR=6.9
76 0 my $self = shift;
77  
78 0 my $cfg = Config::Any->load_files({
79 use_ext => 1,
80 files => [ $self->config_file ],
81 });
82 0 my $entry = shift @{ $cfg };
83 0 my($filename, $config) = %{ $entry };
84 0 return $config;
85 }
86 0 ▶sub _build_key {
Subroutine _build_key: not called CC=1 SCAR=6.9
87 0 return shift->config->{'API'}{'key'};
88 }
89 0 ▶sub _build_ua {
Subroutine _build_ua: not called CC=1 SCAR=6.9
90 0 return HTTP::Tiny->new(agent => 'OpenGbg-Browser');
91 }
92  
93 0 ▶sub _build_air_quality {
Subroutine _build_air_quality: not called CC=1 SCAR=6.9
94 0 return OpenGbg::Service::AirQuality->new(handler => shift);
95 }
96 0 ▶sub _build_bridge {
Subroutine _build_bridge: not called CC=1 SCAR=6.9
97 0 return OpenGbg::Service::Bridge->new(handler => shift);
98 }
99 0 ▶sub _build_styr_och_stall {
Subroutine _build_styr_och_stall: not called CC=1 SCAR=6.9
100 0 return OpenGbg::Service::StyrOchStall->new(handler => shift);
101 }
102 0 ▶sub _build_traffic_camera {
Subroutine _build_traffic_camera: not called CC=1 SCAR=6.9
103 0 return OpenGbg::Service::TrafficCamera->new(handler => shift);
104 }
105  
106 5 __PACKAGE__->meta->make_immutable;
107  
108 5 1;
109  
110 __END__
« OpenGbg/Service/AirQuality/GetLatestMeasurement.pm ↑ Summary OpenGbg/Service/TrafficCamera.pm »