blib/lib/YAPC/Russia.pm

filter: Statementstmt 86.6% 39 / 45 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 81.8% 9 / 11 Podpod 100% 4 / 4 totaltotal 86.3% 57 / 66 CC 5 SCAR 5.9
CC
5
Cov
86%
new
3.0
get_dates
2.0
get_place
2.0
CRAP 1.8
↑ Summary
1 package YAPC::Russia;
2 1 $YAPC::Russia::VERSION = '4.0.0';
3 # ABSTRACT: Perl conference YAPC::Russia
4  
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use open qw(:std :utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Moment;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16  
17 3 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
18 3 my ($class, %params) = @_;
19  
20 3 my $self = {};
21 3 bless $self, $class;
22  
23 3 $self->{_year} = delete $params{year};
24 3 ▶ croak 'No "year"' if not defined $self->{_year};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_year"} 1 2 3
25  
26 2 ▶ croak 'Got unknown params: ' . join(', ', keys %params) if %params;
Branch: 1 branch
BranchTrueFalseTotal
if %params 0 2 2
27  
28 2 $self->{_data} = $self->_get_data_for_year($self->{_year});
29  
30 1 return $self;
31 }
32  
33  
34 1 ▶sub get_dates {
Subroutine get_dates: called CC=2 SCAR=6.9
Pod documented
35 1 my ($self) = @_;
36  
37 1 my @dates;
38 1 foreach my $d (@{$self->{_data}->{dates}}) {
39 2 push @dates, Moment->new( dt => "$d 00:00:00");
40 }
41  
42 1 return @dates;
43 }
44  
45  
46 0 ▶sub get_place {
Subroutine get_place: not called CC=1 SCAR=6.9
Pod documented
47 0 my ($self) = @_;
48  
49 0 return $self->{_data}->{place};
50 }
51  
52  
53 0 ▶sub is_live {
Subroutine is_live: not called CC=1 SCAR=6.9
Pod documented
54 0 my ($self) = @_;
55  
56 0 my $today_d = Moment->now()->get_d();
57  
58 0 return grep { $_->get_d() eq $today_d } $self->get_dates();
59 }
60  
61 2 ▶sub _get_data_for_year {
Subroutine _get_data_for_year: called CC=2 SCAR=6.9
62 2 my ($self, $year) = @_;
63  
64 2 my %data = (
65 2014 => {
66 dates => [qw(2014-06-13 2014-06-14)],
67 place => {
68 city => 'Saint Petersburg',
69 name_ru => 'Место Роста',
70 address_ru => 'Курляндская, дом 5',
71 site => 'http://mestorosta.biz',
72 phone => '+7 812 648-13-81',
73 foursquare => 'https://foursquare.com/v/%D0%BC%D0%B5%D1%81%D1%82%D0%BE-%D1%80%D0%BE%D1%81%D1%82%D0%B0/50fe895ce4b0382948fd8148',
74 }
75 },
76 2015 => {
77 dates => [qw(2015-05-16 2015-05-17)],
78 place => {
79 city => 'Moscow',
80 name_ru => 'Mail.ru',
81 address_ru => 'Ленинградский проспект 39, стр. 79',
82 foursquare => 'https://foursquare.com/v/mailru-hq/4b980acdf964a520532835e3',
83 }
84 },
85 2016 => {
86 dates => [qw(2016-06-25)],
87 place => {
88 city => 'Moscow',
89 name_ru => 'Mail.ru',
90 address_ru => 'Ленинградский проспект 39, стр. 79',
91 foursquare => 'https://foursquare.com/v/mailru-hq/4b980acdf964a520532835e3',
92 }
93 },
94 );
95  
96 2 ▶ if (exists $data{$year}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data{$year}) { } 1 1 2
97 1 return $data{$year};
98 } else {
99 1 croak 'Sorry, no data for year "' . $year . '"';
100 }
101 }
102  
103 1 1;
104  
105 __END__
↑ Summary