File Coverage

blib/lib/Reddit/Client/Link.pm
Criterion Covered Total %
statement 18 49 36.7
branch 0 4 0.0
condition n/a
subroutine 6 19 31.5
pod 7 13 53.8
total 31 85 36.4


line stmt bran cond sub pod time code
1             package Reddit::Client::Link;
2              
3 5     5   35 use strict;
  5         10  
  5         142  
4 5     5   25 use warnings;
  5         10  
  5         105  
5 5     5   23 use Carp;
  5         10  
  5         288  
6              
7             require Reddit::Client::VotableThing;
8             # is_original_content in base class
9 5     5   28 use base qw/Reddit::Client::VotableThing/;
  5         9  
  5         1034  
10 5         34 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             gallery_data
42             gilded
43             gildings
44             hidden
45             hide_score
46             is_crosspostable
47             is_gallery
48             is_meta
49             is_reddit_media_domain
50             is_robot_indexable
51             is_self
52             is_video
53             link_flair_background_color
54             link_flair_css_class
55             link_flair_richtext
56             link_flair_template_id
57             link_flair_text
58             link_flair_text_color
59             link_flair_type
60             locked
61             media
62             media_embed
63             media_metadata
64             mod_reports
65             morecomments
66             num_comments
67             num_reports
68             over_18
69             permalink
70             pwls
71             quarantine
72             removal_reason
73             removed
74             removed_by
75             removed_by_category
76             report_reasons
77             saved
78             secure_media
79             selftext
80             selftext_html
81             send_replies
82             spam
83             spoiler
84             sr_detail
85             steward_reports
86             stickied
87             subreddit
88             subreddit_id
89             subreddit_name_prefixed
90             subreddit_subscribers
91             subreddit_type
92             suggested_sort
93             thumbnail
94             thumbnail_height
95             thumbnail_width
96             title
97             total_awards_received
98             url
99             user_reports
100             view_count
101             visited
102             whitelist_status
103             wls
104 5     5   36 /;
  5         12  
105              
106 5     5   3020 use constant type => "t3";
  5         11  
  5         2728  
107              
108             sub reply {
109 0     0 0   my ($self, $text) = @_;
110 0           my $cmtid = $self->{session}->submit_comment(parent_id=>$self->{name}, text=>$text);
111 0           return $cmtid;
112             }
113             sub remove {
114 0     0 1   my $self = shift;
115 0           return $self->{session}->remove($self->{name});
116             }
117             sub spam {
118 0     0 1   my $self = shift;
119 0           return $self->{session}->spam($self->{name});
120             }
121             sub approve {
122 0     0 1   my $self = shift;
123 0           return $self->{session}->approve($self->{name});
124             }
125             sub ignore_reports {
126 0     0 1   my $self = shift;
127 0           return $self->{session}->ignore_reports($self->{name});
128             }
129             sub edit {
130 0     0 0   my ($self, $text) = @_;
131 0 0         croak 'This is not a self post' unless $self->{is_self};
132 0           my $post = $self->{session}->edit($self->{name}, $text);
133 0 0         $self->{selftext} = $text if $post;
134 0           return $post;
135             }
136             sub delete {
137 0     0 0   my $self = shift;
138 0           my $cmtid = $self->{session}->delete($self->{name});
139 0           return $cmtid;
140             }
141              
142             sub hide {
143 0     0 1   my $self = shift;
144 0           $self->{session}->hide($self->{name});
145             }
146              
147             sub unhide {
148 0     0 1   my $self = shift;
149 0           $self->{session}->unhide($self->{name});
150             }
151              
152             sub get_permalink { # deprecated
153 0     0 0   my $self = shift;
154 0           return $self->{session}->get_origin().$self->{permalink};
155             }
156             sub get_web_url {
157 0     0 0   my $self = shift;
158 0           return $self->{session}->get_origin().$self->{permalink};
159             }
160              
161             sub comments { # deprecated. Only existed briefly.
162 0     0 0   my $self = shift;
163 0           return $self->get_comments();
164             }
165             sub get_comments {
166 0     0 1   my $self = shift;
167 0           return $self->{session}->get_comments(permalink=>$self->{permalink});
168             }
169              
170             1;
171              
172             __END__