File Coverage

lib/XML/Loy/OStatus.pm
Criterion Covered Total %
statement 24 26 92.3
branch 4 6 66.6
condition n/a
subroutine 10 11 90.9
pod 6 6 100.0
total 44 49 89.8


line stmt bran cond sub pod time code
1             package XML::Loy::OStatus;
2 1     1   658 use strict;
  1         3  
  1         31  
3 1     1   14 use warnings;
  1         2  
  1         32  
4              
5 1         5 use XML::Loy with => (
6             prefix => 'ostatus',
7             namespace => 'http://ostatus.org/schema/1.0/'
8 1     1   6 );
  1         1  
9              
10 1     1   8 use Carp qw/carp/;
  1         2  
  1         386  
11              
12             # No constructor
13             sub new {
14 0     0 1 0 carp 'Only use ' . __PACKAGE__ . ' as an extension to Atom';
15 0         0 return;
16             };
17              
18              
19             # Add 'attention' link
20             sub attention {
21 2     2 1 13 shift->_ostatus_link( attention => @_ );
22             };
23              
24              
25             # Add 'conversation' link
26             sub conversation {
27 2     2 1 11 shift->_ostatus_link( conversation => @_ );
28             };
29              
30              
31             # Link elements
32             sub _ostatus_link {
33 4     4   7 my $self = shift;
34 4         9 my $rel = 'ostatus:' . shift;
35              
36             # Get href from link element
37 4 100       8 unless (@_) {
38 2 50       7 my $att = $self->link($rel) or return;
39 2 50       50 $att = $att->[0] or return;
40 2         15 return $att->attr('href');
41             };
42              
43             # Create new link element
44 2         8 return $self->link(
45             rel => $rel,
46             href => shift,
47             @_
48             );
49             };
50              
51              
52             # OStatus activity 'leave'
53             sub verb_leave {
54 1     1 1 4 shift->verb( __PACKAGE__->_namespace . 'leave');
55             };
56              
57              
58             # OStatus activity 'unfollow'
59             sub verb_unfollow {
60 1     1 1 6 shift->verb( __PACKAGE__->_namespace . 'unfollow');
61             };
62              
63              
64             # OStatus activity 'unfavorite'
65             sub verb_unfavorite {
66 1     1 1 4 shift->verb( __PACKAGE__->_namespace . 'unfavorite');
67             };
68              
69              
70             1;
71              
72              
73             __END__