Agent/Twitter.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 36 CC 1 SCAR 6.9
CC
1
Cov
0%
component_name
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Exobrain::Agent::Twitter;
2 use Moose::Role;
3 use Net::Twitter;
4 use Method::Signatures;
5 use Date::Manip::Date;
6  
7 our $VERSION = '1.04'; # VERSION
8 # ABSTRACT: Provides common functions for twitter components
9  
10 with 'Exobrain::Agent';
11  
12 sub component_name { "Twitter" }
13  
14 has twitter => (
15 is => 'ro',
16 isa => 'Net::Twitter',
17 lazy => 1,
18 builder => '_build_twitter',
19 );
20  
21 method _build_twitter() {
22 my $config = $self->config;
23  
24 return Net::Twitter->new(
25 traits => [qw(API::RESTv1_1)],
26 consumer_key => $config->{consumer_key},
27 consumer_secret => $config->{consumer_secret},
28 access_token => $config->{access_token},
29 access_token_secret => $config->{access_token_secret},
30 ssl => 1,
31 );
32 }
33  
34 method tags(Str $text) {
35 my @tags;
36  
37 while ($text =~ m{\#(?<tag>\w+)}g) {
38 push @tags, $+{tag};
39 }
40
41 return @tags;
42 }
43  
44 method to_epoch(Str $timestamp) {
45 my $dmd = Date::Manip::Date->new;
46 $dmd->parse($timestamp) and die "Can't parse $timestamp";
47 return $dmd->printf("%s");
48 }
49  
50 1;
51  
52 __END__