Class: Ayadn::Check
- Inherits:
-
Object
- Object
- Ayadn::Check
- Defined in:
- lib/ayadn/check.rb
Class Method Summary collapse
- .already_reposted(resp) ⇒ Object
- .already_starred(resp) ⇒ Object
- .auto_save_followers(list) ⇒ Object
- .auto_save_followings(list) ⇒ Object
- .auto_save_muted(list) ⇒ Object
- .bad_post_id(post_id) ⇒ Object
- .has_been_blocked(username, resp) ⇒ Object
- .has_been_deleted(post_id, resp) ⇒ Object
- .has_been_followed(username, resp) ⇒ Object
- .has_been_muted(username, resp) ⇒ Object
- .has_been_reposted(post_id, resp) ⇒ Object
- .has_been_starred(post_id, resp) ⇒ Object
- .has_been_unblocked(username, resp) ⇒ Object
- .has_been_unfollowed(username, resp) ⇒ Object
- .has_been_unmuted(username, resp) ⇒ Object
- .has_been_unreposted(post_id, resp) ⇒ Object
- .has_been_unstarred(post_id, resp) ⇒ Object
- .message_has_been_deleted(message_id, resp) ⇒ Object
- .no_data(stream, target) ⇒ Object
- .no_new_posts(stream, options, title) ⇒ Object
- .no_post(stream, post_id) ⇒ Object
- .no_user(stream, username) ⇒ Object
- .no_username(username) ⇒ Object
- .same_username(stream) ⇒ Object
Class Method Details
.already_reposted(resp) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/ayadn/check.rb', line 86 def self.already_reposted(resp) if resp['data']['you_reposted'] puts "\nYou already reposted this post.\n".color(:red) exit end end |
.already_starred(resp) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/ayadn/check.rb', line 79 def self.already_starred(resp) if resp['data']['you_starred'] puts "\nYou already starred this post.\n".color(:red) exit end end |
.auto_save_followers(list) ⇒ Object
14 15 16 |
# File 'lib/ayadn/check.rb', line 14 def self.auto_save_followers(list) FileOps.save_followers_list(list) if Settings.[:backup][:auto_save_lists] end |
.auto_save_followings(list) ⇒ Object
18 19 20 |
# File 'lib/ayadn/check.rb', line 18 def self.auto_save_followings(list) FileOps.save_followings_list(list) if Settings.[:backup][:auto_save_lists] end |
.auto_save_muted(list) ⇒ Object
10 11 12 |
# File 'lib/ayadn/check.rb', line 10 def self.auto_save_muted(list) FileOps.save_muted_list(list) if Settings.[:backup][:auto_save_lists] end |
.bad_post_id(post_id) ⇒ Object
49 50 51 |
# File 'lib/ayadn/check.rb', line 49 def self.bad_post_id post_id abort(Status.error_missing_post_id) unless post_id.is_integer? end |
.has_been_blocked(username, resp) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/ayadn/check.rb', line 111 def self.has_been_blocked(username, resp) if resp['meta']['code'] == 200 puts Status.blocked(username) Logs.rec.info "Blocked #{username}." else Errors.whine(Status.not_blocked(username), resp) end end |
.has_been_deleted(post_id, resp) ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/ayadn/check.rb', line 138 def self.has_been_deleted(post_id, resp) if resp['meta']['code'] == 200 puts Status.deleted(post_id) Logs.rec.info "Deleted post #{post_id}." else Errors.whine(Status.not_deleted(post_id), resp) end end |
.has_been_followed(username, resp) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/ayadn/check.rb', line 129 def self.has_been_followed(username, resp) if resp['meta']['code'] == 200 puts Status.followed(username) Logs.rec.info "Followed #{username}." else Errors.whine(Status.not_followed(username), resp) end end |
.has_been_muted(username, resp) ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/ayadn/check.rb', line 120 def self.has_been_muted(username, resp) if resp['meta']['code'] == 200 puts Status.muted(username) Logs.rec.info "Muted #{username}." else Errors.whine(Status.not_muted(username), resp) end end |
.has_been_reposted(post_id, resp) ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/ayadn/check.rb', line 102 def self.has_been_reposted(post_id, resp) if resp['meta']['code'] == 200 puts Status.reposted(post_id) Logs.rec.info "Reposted #{post_id}." else Errors.whine(Status.not_reposted(post_id), resp) end end |
.has_been_starred(post_id, resp) ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/ayadn/check.rb', line 93 def self.has_been_starred(post_id, resp) if resp['meta']['code'] == 200 puts Status.starred(post_id) Logs.rec.info "Starred #{post_id}." else Errors.whine(Status.not_starred(post_id), resp) end end |
.has_been_unblocked(username, resp) ⇒ Object
156 157 158 159 160 161 162 163 |
# File 'lib/ayadn/check.rb', line 156 def self.has_been_unblocked(username, resp) if resp['meta']['code'] == 200 puts Status.unblocked(username) Logs.rec.info "Unblocked #{username}." else Errors.whine(Status.not_unblocked(username), resp) end end |
.has_been_unfollowed(username, resp) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/ayadn/check.rb', line 61 def self.has_been_unfollowed(username, resp) if resp['meta']['code'] == 200 puts Status.unfollowed(username) Logs.rec.info "Unfollowed #{username}." else Errors.whine(Status.not_unfollowed(username), resp) end end |
.has_been_unmuted(username, resp) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/ayadn/check.rb', line 70 def self.has_been_unmuted(username, resp) if resp['meta']['code'] == 200 puts Status.unmuted(username) Logs.rec.info "Unmuted #{username}." else Errors.whine(Status.not_unmuted(username), resp) end end |
.has_been_unreposted(post_id, resp) ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/ayadn/check.rb', line 174 def self.has_been_unreposted(post_id, resp) if resp['meta']['code'] == 200 puts Status.unreposted(post_id) Logs.rec.info "Unreposted #{post_id}." else Errors.whine(Status.not_unreposted(post_id), resp) end end |
.has_been_unstarred(post_id, resp) ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/ayadn/check.rb', line 165 def self.has_been_unstarred(post_id, resp) if resp['meta']['code'] == 200 puts Status.unstarred(post_id) Logs.rec.info "Unstarred #{post_id}." else Errors.whine(Status.not_unstarred(post_id), resp) end end |
.message_has_been_deleted(message_id, resp) ⇒ Object
147 148 149 150 151 152 153 154 |
# File 'lib/ayadn/check.rb', line 147 def self.(, resp) if resp['meta']['code'] == 200 puts Status.deleted_m() Logs.rec.info "Deleted message #{message_id}." else Errors.whine(Status.not_deleted(), resp) end end |
.no_data(stream, target) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/ayadn/check.rb', line 26 def self.no_data stream, target if stream['data'].empty? Errors.warn "In action/#{target}: no data" abort(Status.empty_list) end end |
.no_new_posts(stream, options, title) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ayadn/check.rb', line 33 def self.no_new_posts stream, , title if [:new] unless Databases.has_new?(stream, title) abort(Status.no_new_posts) end end end |
.no_post(stream, post_id) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ayadn/check.rb', line 41 def self.no_post stream, post_id if stream['meta']['code'] == 404 puts Status.post_404(post_id) Errors.info("Impossible to find #{post_id}") exit end end |
.no_user(stream, username) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/ayadn/check.rb', line 53 def self.no_user stream, username if stream['meta']['code'] == 404 puts Status.user_404(username) Errors.info("User #{username} doesn't exist") exit end end |
.no_username(username) ⇒ Object
22 23 24 |
# File 'lib/ayadn/check.rb', line 22 def self.no_username username abort(Status.error_missing_username) if username.empty? end |
.same_username(stream) ⇒ Object
6 7 8 |
# File 'lib/ayadn/check.rb', line 6 def self.same_username(stream) stream['data']['username'] == Settings.config[:identity][:username] end |