HabitRPG.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 43 CC 1 SCAR 6.9
CC
1
Cov
0%
component
2.0
services
2.0
setup
2.0
CRAP 2.0
1 package Exobrain::HabitRPG;
2 use Moose;
3 use Exobrain::Config;
4 use feature qw(say);
5  
6 # ABSTRACT: HabitRPG components for Exobrain
7 our $VERSION = '0.01'; # VERSION
8  
9 with 'Exobrain::Component';
10  
11 sub component { "habitrpg" };
12  
13 sub services {
14 return (
15 sink => 'HabitRPG::Sink',
16 );
17 }
18  
19 sub setup {
20  
21 # Load module and die swiftly on failure
22 eval 'use WebService::HabitRPG; 1;' or die $@;
23  
24 say "Welcome to the Exobrain::HabitRPG setup process.";
25 say "To complete setup, we'll need your HabitRPG API key and user ID";
26 say "These can be found on your HabitRPG settings page.";
27  
28 print "API token: ";
29 chomp( my $api = <STDIN> );
30  
31 print "User ID: ";
32 chomp( my $user = <STDIN> );
33  
34 # Check to see if we auth okay.
35  
36 my $habit = WebService::HabitRPG->new(
37 api_token => $api,
38 user_id => $user,
39 );
40
41 # Make a call to ensure we auth
42  
43 $habit->user;
44  
45 say "\nThanks! Writing configuration...";
46  
47 my $config =
48 "[Components]\n" .
49 "HabitRPG=$VERSION\n\n" .
50  
51 "[HabitRPG]\n" .
52 "api_token = $api\n" .
53 "user_id = $user\n"
54 ;
55  
56 my $filename = Exobrain::Config->write_config('HabitRPG.ini', $config);
57  
58 say "\nConfig written to $filename. Have a nice day!";
59  
60 return;
61 }
62  
63 1;
64  
65 __END__