Beeminder.pm untested

filter: Statementstmt 0.0% 0 / 39 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 52 CC 3 SCAR 17.5
CC
3
Cov
0%
setup
12.0
component
2.0
services
2.0
CRAP 5.8
1 package Exobrain::Beeminder;
2 use Exobrain::Config;
3 use Moose;
4 use feature qw(say); # Needed to make 5.10 happy.
5  
6 # ABSTRACT: Beeminder components for exobrain
7 our $VERSION = '1.06'; # VERSION
8  
9  
10 with 'Exobrain::Component';
11  
12 # This is the namespace everything will be installed in by default.
13 # It's automatically prepended with 'exobrain'
14  
15 sub component { "beeminder" };
16  
17 # These are the services in that namespace. So we have
18 # 'exobrain.beeminder.source' and 'exobrain.beeminder.sink'.
19  
20 sub services {
21 return (
22 source => 'Beeminder::Source',
23 sink => 'Beeminder::Sink',
24 notify => 'Beeminder::Notify',
25 )
26 }
27  
28 # This runs the setup process, and is executed by the `exobrain`
29 # cmdline tool the first time we run our code.
30  
31 sub setup {
32
33 # Load our WebService for testing.
34 eval 'require WebService::Beeminder';
35 die $@ if $@;
36  
37 say "Welcome to the Exobrain::Beeminder setup process.";
38 say "To start with we need from you is your Beeminder auth token.";
39 say "If you're logged into Beeminder, you can find it here:\n";
40 say "https://www.beeminder.com/settings/account";
41 print "\nAuth token: ";
42  
43 chomp(my $token = <STDIN>);
44  
45 # Connect to make sure that we're working. This should throw
46 # an exception if things go wrong. :)
47  
48 my $bee = WebService::Beeminder->new( token => $token );
49 my $user = $bee->user->{username};
50  
51 say "\nThanks, $user!\n";
52  
53 # Now configure our callback port.
54  
55 say "Exobrain::Beeminder can be configured to accept callbacks from Beeminder.";
56 say "For this, we need a dedicted port that can be reached from the outside world.";
57 say "To disable this functionality, provide a port of 0";
58  
59 print "\nCallback port: [default: 3000] ";
60  
61 chomp(my $port = <STDIN>);
62 if ($port eq '') { $port = 3000; }
63  
64 say "\nGreat! Writing configuration...";
65  
66 my $config =
67 "[Components]\n" .
68 "Beeminder=$VERSION\n\n" .
69  
70 "[Beeminder]\n" .
71 "auth_token = $token\n" .
72 "callback_port = $port\n"
73 ;
74  
75 my $filename = Exobrain::Config->write_config('Beeminder.ini', $config);
76  
77 say "\nConfig written to $filename. Have a nice day!";
78  
79 return;
80 }
81  
82 1;
83  
84 __END__