File Coverage

lib/WebService/Steam/User.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package WebService::Steam::User;
2              
3 1     1   2840 use DateTime;
  1         154489  
  1         37  
4 1     1   9 use IO::All;
  1         2  
  1         11  
5 1     1   415 use Moose;
  0            
  0            
6             use Moose::Util::TypeConstraints;
7             use WebService::Steam;
8              
9             subtype 'SteamBool', as 'Bool';
10             coerce 'SteamBool', from 'Str', via { /^online$/ };
11              
12             has banned => ( is => 'ro', isa => 'Bool' , init_arg => 'vacBanned' );
13             has custom_url => ( is => 'ro', isa => 'Str' , init_arg => 'customURL' );
14             has __groups => ( is => 'ro', isa => 'ArrayRef' , init_arg => 'group' );
15             has _groups => ( isa => 'ArrayRef[WebService::Steam::Group]' ,
16             handles => { groups => 'elements' } ,
17             lazy_build => 1 ,
18             traits => [ 'Array' ] );
19             has headline => ( is => 'ro', isa => 'Str' );
20             has id => ( is => 'ro', isa => 'Int' , init_arg => 'steamID64' );
21             has limited => ( is => 'ro', isa => 'Bool' , init_arg => 'isLimitedAccount' );
22             has location => ( is => 'ro', isa => 'Str' );
23             has name => ( is => 'ro', isa => 'Str' , init_arg => 'realname' );
24             has nick => ( is => 'ro', isa => 'Str' , init_arg => 'steamID' );
25             has online => ( is => 'ro', isa => 'SteamBool', init_arg => 'onlineState', coerce => 1 );
26             has rating => ( is => 'ro', isa => 'Num' , init_arg => 'steamRating' );
27             has _registered => ( is => 'ro', isa => 'Str' , init_arg => 'memberSince' );
28             has registered => ( is => 'ro', isa => 'DateTime' , lazy_build => 1 );
29             has summary => ( is => 'ro', isa => 'Str' );
30              
31             sub path { "http://steamcommunity.com/@{[ $_[1] =~ /^\d+$/ ? 'profiles' : 'id' ]}/$_[1]/?xml=1" }
32              
33             sub _build__groups { [ WebService::Steam::steam_group( map $$_{ groupID64 }, @{ $_[0]->__groups } ) ] }
34              
35             sub _build_registered
36             {
37             my ( $month, $day, $year ) = split /,? /, $_[0]->_registered;
38              
39             my %months;
40             @months{ qw/January Febuary March April May June July August September October November December/ } = ( 1..12 );
41            
42             DateTime->new( year => $year, month => $months{ $month }, day => $day );
43             }
44              
45             __PACKAGE__->meta->make_immutable;
46              
47             1;
48            
49             =head1 NAME
50              
51             WebService::Steam::User
52              
53             =head1 ATTRIBUTES
54              
55             =head2 banned
56              
57             A boolean of the user's VAC banned status.
58              
59             =head2 custom_url
60              
61             A string of the user's custom URL
62              
63             =head2 headline
64              
65             A string of the user's headline
66              
67             =head2 id
68              
69             An integer of the user's ID
70              
71             =head2 limited
72              
73             =head2 location
74              
75             =head2 name
76              
77             A string of the user's real life name.
78              
79             =head2 nick
80              
81             A string of the user's chosen nick name.
82              
83             =head2 online
84              
85             A boolean of the user's current online status.
86              
87             =head2 rating
88              
89             =head2 registered
90              
91             A L<DateTime> of when the user registered their Steam account.
92              
93             =head2 summary
94              
95             =head2 groups