Class: Ayadn::Check

Inherits:
Object show all
Defined in:
lib/ayadn/check.rb

Instance Method Summary collapse

Constructor Details

#initializeCheck

Returns a new instance of Check.



6
7
8
# File 'lib/ayadn/check.rb', line 6

def initialize
  @status = Status.new
end

Instance Method Details

#already_reposted(resp) ⇒ Object



105
106
107
108
109
110
# File 'lib/ayadn/check.rb', line 105

def already_reposted(resp)
  if resp['data']['you_reposted']
    @status.already_reposted
    exit
  end
end

#already_starred(resp) ⇒ Object



98
99
100
101
102
103
# File 'lib/ayadn/check.rb', line 98

def already_starred(resp)
  if resp['data']['you_starred']
    @status.already_starred
    exit
  end
end

#auto_save_followers(list) ⇒ Object



18
19
20
# File 'lib/ayadn/check.rb', line 18

def auto_save_followers(list)
  FileOps.save_followers_list(list) if Settings.options[:backup][:lists]
end

#auto_save_followings(list) ⇒ Object



22
23
24
# File 'lib/ayadn/check.rb', line 22

def auto_save_followings(list)
  FileOps.save_followings_list(list) if Settings.options[:backup][:lists]
end

#auto_save_muted(list) ⇒ Object



14
15
16
# File 'lib/ayadn/check.rb', line 14

def auto_save_muted(list)
  FileOps.save_muted_list(list) if Settings.options[:backup][:lists]
end

#bad_post_id(post_id) ⇒ Object



58
59
60
61
62
63
# File 'lib/ayadn/check.rb', line 58

def bad_post_id post_id
  unless post_id.is_integer?
    @status.error_missing_post_id
    exit
  end
end

#bad_post_ids(post_ids) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/ayadn/check.rb', line 65

def bad_post_ids(post_ids)
  post_ids.each do |id|
    unless id.is_integer?
      @status.error_missing_post_id
      exit
    end
  end
end

#has_been_blocked(username, resp) ⇒ Object



128
129
130
131
132
133
134
# File 'lib/ayadn/check.rb', line 128

def has_been_blocked(username, resp)
  if resp['meta']['code'] == 200
    @status.blocked(username)
  else
    @status.not_blocked(username)
  end
end

#has_been_deleted(post_id, resp) ⇒ Object



152
153
154
155
156
157
158
# File 'lib/ayadn/check.rb', line 152

def has_been_deleted(post_id, resp)
  if resp['meta']['code'] == 200
    @status.deleted(post_id)
  else
    @status.not_deleted(post_id)
  end
end

#has_been_followed(username, resp) ⇒ Object



144
145
146
147
148
149
150
# File 'lib/ayadn/check.rb', line 144

def has_been_followed(username, resp)
  if resp['meta']['code'] == 200
    @status.followed(username)
  else
    @status.not_followed(username)
  end
end

#has_been_muted(username, resp) ⇒ Object



136
137
138
139
140
141
142
# File 'lib/ayadn/check.rb', line 136

def has_been_muted(username, resp)
  if resp['meta']['code'] == 200
    @status.muted(username)
  else
    @status.not_muted(username)
  end
end

#has_been_reposted(post_id, resp) ⇒ Object



120
121
122
123
124
125
126
# File 'lib/ayadn/check.rb', line 120

def has_been_reposted(post_id, resp)
  if resp['meta']['code'] == 200
    @status.reposted(post_id)
  else
    @status.not_reposted(post_id)
  end
end

#has_been_starred(post_id, resp) ⇒ Object



112
113
114
115
116
117
118
# File 'lib/ayadn/check.rb', line 112

def has_been_starred(post_id, resp)
  if resp['meta']['code'] == 200
    @status.starred(post_id)
  else
    @status.not_starred(post_id)
  end
end

#has_been_unblocked(username, resp) ⇒ Object



168
169
170
171
172
173
174
# File 'lib/ayadn/check.rb', line 168

def has_been_unblocked(username, resp)
  if resp['meta']['code'] == 200
    @status.unblocked(username)
  else
    @status.not_unblocked(username)
  end
end

#has_been_unfollowed(username, resp) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/ayadn/check.rb', line 82

def has_been_unfollowed(username, resp)
  if resp['meta']['code'] == 200
    @status.unfollowed(username)
  else
    @status.not_unfollowed(username)
  end
end

#has_been_unmuted(username, resp) ⇒ Object



90
91
92
93
94
95
96
# File 'lib/ayadn/check.rb', line 90

def has_been_unmuted(username, resp)
  if resp['meta']['code'] == 200
    @status.unmuted(username)
  else
    @status.not_unmuted(username)
  end
end

#has_been_unreposted(post_id, resp) ⇒ Object



184
185
186
187
188
189
190
# File 'lib/ayadn/check.rb', line 184

def has_been_unreposted(post_id, resp)
  if resp['meta']['code'] == 200
    @status.unreposted(post_id)
  else
    @status.not_unreposted(post_id)
  end
end

#has_been_unstarred(post_id, resp) ⇒ Object



176
177
178
179
180
181
182
# File 'lib/ayadn/check.rb', line 176

def has_been_unstarred(post_id, resp)
  if resp['meta']['code'] == 200
    @status.unstarred(post_id)
  else
    @status.not_unstarred(post_id)
  end
end

#message_has_been_deleted(message_id, resp) ⇒ Object



160
161
162
163
164
165
166
# File 'lib/ayadn/check.rb', line 160

def message_has_been_deleted(message_id, resp)
  if resp['meta']['code'] == 200
    @status.deleted_m(message_id)
  else
    @status.not_deleted_m(message_id)
  end
end

#no_data(stream, target) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/ayadn/check.rb', line 33

def no_data stream, target
  if stream['data'].empty?
    Errors.warn "In action/#{target}: no data"
    @status.empty_list
    exit
  end
end

#no_new_posts(stream, options, title) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/ayadn/check.rb', line 41

def no_new_posts stream, options, title
  if options[:new] == true
    unless Databases.has_new?(stream, title)
      @status.no_new_posts
      exit
    end
  end
end

#no_post(stream, post_id) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/ayadn/check.rb', line 50

def no_post stream, post_id
  if stream['meta']['code'] == 404
    @status.post_404(post_id)
    Errors.info("Impossible to find #{post_id}")
    exit
  end
end

#no_user(stream, username) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/ayadn/check.rb', line 74

def no_user stream, username
  if stream['meta']['code'] == 404
    @status.user_404(username)
    Errors.info("User #{username} doesn't exist")
    exit
  end
end

#no_username(username) ⇒ Object



26
27
28
29
30
31
# File 'lib/ayadn/check.rb', line 26

def no_username username
  if username.empty?
    @status.error_missing_username
    exit
  end
end

#same_username(stream) ⇒ Object



10
11
12
# File 'lib/ayadn/check.rb', line 10

def same_username(stream)
  stream['data']['username'] == Settings.config[:identity][:username]
end