File Coverage

blib/lib/WebService/LiveJournal/FriendGroup.pm
Criterion Covered Total %
statement 9 31 29.0
branch n/a
condition 0 3 0.0
subroutine 3 10 30.0
pod 5 7 71.4
total 17 51 33.3


line stmt bran cond sub pod time code
1             package WebService::LiveJournal::FriendGroup;
2              
3 12     12   128 use strict;
  12         30  
  12         365  
4 12     12   58 use warnings;
  12         40  
  12         290  
5 12     12   61 use WebService::LiveJournal::Thingie;
  12         30  
  12         4494  
6             our @ISA = qw/ WebService::LiveJournal::Thingie /;
7              
8             # ABSTRACT: (Deprecated) LiveJournal friend group class
9             our $VERSION = '0.09'; # VERSION
10              
11              
12             sub new
13             {
14 0     0 0   my $ob = shift;
15 0   0       my $class = ref($ob) || $ob;
16 0           my $self = bless {}, $class;
17 0           my %arg = @_;
18 0           $self->{public} = $arg{public};
19 0           $self->{name} = $arg{name};
20 0           $self->{id} = $arg{id};
21 0           $self->{sortorder} = $arg{sortorder};
22 0           return $self;
23             }
24              
25              
26 0     0 1   sub public { $_[0]->{public} }
27 0     0 1   sub name { $_[0]->{name} }
28 0     0 1   sub id { $_[0]->{id} }
29 0     0 1   sub sortorder { $_[0]->{sortorder} }
30              
31             sub as_string {
32 0     0 0   my $self = shift;
33 0           my $name = $self->name;
34 0           my $id = $self->id;
35 0           my $mask = $self->mask;
36 0           my $bin = sprintf "%b", $mask;
37 0           "[friendgroup $name ($id $mask $bin)]";
38             }
39              
40              
41             sub mask
42             {
43 0     0 1   my $self = shift;
44 0           my $id = $self->id;
45 0           2**$id;
46             }
47              
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             WebService::LiveJournal::FriendGroup - (Deprecated) LiveJournal friend group class
59              
60             =head1 VERSION
61              
62             version 0.09
63              
64             =head1 SYNOPSIS
65              
66             use WebService::LiveJournal;
67             my $client = WebService::LiveJournal->new(
68             username => $user,
69             password => $pass,
70             );
71            
72             foreach my $group (@{ $client->get_friend_groups })
73             {
74             # $group isa WS::LJ::FriendGroup
75             ...
76             }
77              
78             Allow only members of groups "group1" and "group2" to read an event
79             specified by C<$itemid>:
80              
81             use WebService::LiveJournal;
82             my $client = WebService::LiveJournal->new(
83             username => $user,
84             password => $pass,
85             );
86            
87             my(@groups) = grep { $_->name =~ /^group[12]$/ } @{ $client->get_friend_groups };
88            
89             my $event = $client->get_event($itemid);
90             $event->set_access('group', @groups);
91             $event->update;
92              
93             =head1 DESCRIPTION
94              
95             B<NOTE>: This distribution is deprecated. It uses the outmoded XML-RPC protocol.
96             LiveJournal has also been compromised. I recommend using DreamWidth instead
97             (L<https://www.dreamwidth.org/>) which is in keeping with the original philosophy
98             LiveJournal regarding advertising.
99              
100             This class represents a friend group on the LiveJournal server.
101             Friend groups can be used to restrict the readability of events.
102              
103             =head1 ATTRIBUTES
104              
105             =head2 name
106              
107             The name of the group.
108              
109             =head2 id
110              
111             The LiveJournal internal id for the friend groups.
112             Friend groups are unique to a user, not to the server
113             itself, so to get a unique key you must combine
114             the user and the friend group id.
115              
116             =head2 public
117              
118             =head2 sortorder
119              
120             =head2 mask
121              
122             The mask used to compute the usemask when setting
123             the access control on the event. Normally you should
124             not need to use this directly.
125              
126             =head1 SEE ALSO
127              
128             L<WebService::LiveJournal>,
129              
130             =head1 AUTHOR
131              
132             Graham Ollis <plicease@cpan.org>
133              
134             =head1 COPYRIGHT AND LICENSE
135              
136             This software is copyright (c) 2013 by Graham Ollis.
137              
138             This is free software; you can redistribute it and/or modify it under
139             the same terms as the Perl 5 programming language system itself.
140              
141             =cut