File Coverage

blib/lib/Reddit/Client/Link.pm
Criterion Covered Total %
statement 18 51 35.2
branch 0 8 0.0
condition n/a
subroutine 6 19 31.5
pod 7 13 53.8
total 31 91 34.0


line stmt bran cond sub pod time code
1             package Reddit::Client::Link;
2              
3 5     5   35 use strict;
  5         57  
  5         195  
4 5     5   31 use warnings;
  5         10  
  5         129  
5 5     5   25 use Carp;
  5         12  
  5         320  
6              
7             require Reddit::Client::VotableThing;
8             # is_original_content in base class
9 5     5   29 use base qw/Reddit::Client::VotableThing/;
  5         10  
  5         1049  
10 5         46 use fields qw/
11             approved_at_utc
12             approved_by
13             archived
14             author
15             author_flair_background_color
16             author_flair_css_class
17             author_flair_richtext
18             author_flair_template_id
19             author_flair_text
20             author_flair_text_color
21             author_flair_type
22             author_fullname
23             author_patreon_flair
24             author_premium
25             awarders
26             banned_at_utc
27             banned_by
28             brand_safe
29             can_gild
30             can_mod_post
31             category
32             clicked
33             content_categories
34             contest_mode
35             created
36             created_utc
37             crosspost_parent
38             discussion_type
39             distinguished
40             domain
41             gilded
42             gildings
43             hidden
44             hide_score
45             is_crosspostable
46             is_meta
47             is_reddit_media_domain
48             is_robot_indexable
49             is_self
50             is_video
51             link_flair_background_color
52             link_flair_css_class
53             link_flair_richtext
54             link_flair_template_id
55             link_flair_text
56             link_flair_text_color
57             link_flair_type
58             locked
59             media
60             media_embed
61             mod_reports
62             morecomments
63             num_comments
64             num_reports
65             over_18
66             permalink
67             pwls
68             quarantine
69             removal_reason
70             removed
71             removed_by
72             removed_by_category
73             report_reasons
74             saved
75             secure_media
76             selftext
77             selftext_html
78             send_replies
79             spam
80             spoiler
81             sr_detail
82             steward_reports
83             stickied
84             subreddit
85             subreddit_id
86             subreddit_name_prefixed
87             subreddit_subscribers
88             subreddit_type
89             suggested_sort
90             thumbnail
91             thumbnail_height
92             thumbnail_width
93             title
94             total_awards_received
95             url
96             user_reports
97             view_count
98             visited
99             whitelist_status
100             wls
101 5     5   39 /;
  5         10  
102              
103 5     5   2839 use constant type => "t3";
  5         11  
  5         2768  
104              
105             sub reply {
106 0     0 0   my ($self, $text) = @_;
107 0 0         $text || croak "need comment text";
108 0           my $cmtid = $self->{session}->submit_comment(parent_id=>$self->{name}, text=>$text);
109 0 0         return "t1_".$cmtid if $cmtid;
110 0           return $cmtid;
111             }
112             sub remove {
113 0     0 1   my $self = shift;
114 0           return $self->{session}->remove($self->{name});
115             }
116             sub spam {
117 0     0 1   my $self = shift;
118 0           return $self->{session}->spam($self->{name});
119             }
120             sub approve {
121 0     0 1   my $self = shift;
122 0           return $self->{session}->approve($self->{name});
123             }
124             sub ignore_reports {
125 0     0 1   my $self = shift;
126 0           return $self->{session}->ignore_reports($self->{name});
127             }
128             sub edit {
129 0     0 0   my ($self, $text) = @_;
130 0 0         croak 'This is not a self post' unless $self->{is_self};
131 0           my $post = $self->{session}->edit($self->{name}, $text);
132 0 0         $self->{selftext} = $text if $post;
133 0           return $post;
134             }
135             sub delete {
136 0     0 0   my $self = shift;
137 0           my $cmtid = $self->{session}->delete($self->{name});
138 0           return $cmtid;
139             }
140              
141             sub hide {
142 0     0 1   my $self = shift;
143 0           $self->{session}->hide($self->{name});
144             }
145              
146             sub unhide {
147 0     0 1   my $self = shift;
148 0           $self->{session}->unhide($self->{name});
149             }
150              
151             sub get_permalink { # deprecated
152 0     0 0   my $self = shift;
153 0           return $self->{session}->get_origin().$self->{permalink};
154             }
155             sub get_web_url {
156 0     0 0   my $self = shift;
157 0           return $self->{session}->get_origin().$self->{permalink};
158             }
159              
160             sub comments { # deprecated. Only existed briefly.
161 0     0 0   my $self = shift;
162 0           return $self->get_comments();
163             }
164             sub get_comments {
165 0     0 1   my $self = shift;
166 0           return $self->{session}->get_comments(permalink=>$self->{permalink});
167             }
168              
169             1;
170              
171             __END__