ayadn 1.8.2 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/CHANGELOG.md +73 -52
- data/README.md +17 -3
- data/ayadn.gemspec +3 -4
- data/doc/01-index.md +6 -5
- data/doc/02-install.md +23 -1
- data/doc/03-first-steps.md +22 -28
- data/doc/04-options.md +1 -1
- data/doc/05-streams.md +29 -9
- data/doc/06-post.md +13 -5
- data/doc/07-actions.md +63 -1
- data/doc/08-listings.md +112 -4
- data/doc/09-accounts.md +17 -3
- data/doc/10-nicerank.md +5 -5
- data/doc/11-blacklist.md +8 -14
- data/doc/12-alias.md +1 -13
- data/doc/14-set.md +8 -110
- data/doc/15-nowplaying.md +16 -4
- data/doc/18-contact.md +14 -13
- data/doc/19-examples.md +2 -0
- data/lib/ayadn/action.rb +322 -183
- data/lib/ayadn/alias.rb +17 -45
- data/lib/ayadn/annotations.rb +1 -1
- data/lib/ayadn/api.rb +7 -8
- data/lib/ayadn/app.rb +99 -12
- data/lib/ayadn/authorize.rb +92 -57
- data/lib/ayadn/blacklist.rb +52 -62
- data/lib/ayadn/check.rb +81 -74
- data/lib/ayadn/cnx.rb +77 -26
- data/lib/ayadn/databases.rb +890 -105
- data/lib/ayadn/debug.rb +30 -89
- data/lib/ayadn/descriptions.rb +876 -329
- data/lib/ayadn/endpoints.rb +2 -2
- data/lib/ayadn/errors.rb +9 -9
- data/lib/ayadn/extend.rb +8 -1
- data/lib/ayadn/fileops.rb +10 -8
- data/lib/ayadn/mark.rb +79 -56
- data/lib/ayadn/migration.rb +427 -0
- data/lib/ayadn/nicerank.rb +74 -72
- data/lib/ayadn/nowplaying.rb +123 -60
- data/lib/ayadn/nowwatching.rb +26 -10
- data/lib/ayadn/pinboard.rb +12 -7
- data/lib/ayadn/post.rb +40 -37
- data/lib/ayadn/profile.rb +5 -2
- data/lib/ayadn/scroll.rb +20 -5
- data/lib/ayadn/search.rb +30 -22
- data/lib/ayadn/set.rb +146 -50
- data/lib/ayadn/settings.rb +66 -67
- data/lib/ayadn/status.rb +459 -234
- data/lib/ayadn/stream.rb +80 -46
- data/lib/ayadn/switch.rb +51 -47
- data/lib/ayadn/tvshow.rb +47 -15
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +119 -60
- data/lib/ayadn/workers.rb +144 -92
- data/lib/ayadn.rb +7 -8
- data/spec/mock/ayadn/accounts.sqlite +0 -0
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/unit/annotations_spec.rb +12 -13
- data/spec/unit/api_spec.rb +3 -4
- data/spec/unit/blacklistworkers_spec.rb +18 -23
- data/spec/unit/databases_spec.rb +51 -36
- data/spec/unit/endpoints_spec.rb +5 -2
- data/spec/unit/extend_spec.rb +24 -0
- data/spec/unit/nicerank_spec.rb +13 -13
- data/spec/unit/post_spec.rb +47 -36
- data/spec/unit/set_spec.rb +67 -96
- data/spec/unit/view_spec.rb +12 -6
- data/spec/unit/workers_spec.rb +38 -12
- data/tags +1285 -0
- metadata +29 -39
- data/spec/mock/aliases.db +0 -0
- data/spec/mock/blacklist.db +0 -0
- data/spec/mock/bookmarks.db +0 -0
- data/spec/mock/channels.db +0 -0
- data/spec/mock/index.db +0 -0
- data/spec/mock/nicerank.db +0 -0
- data/spec/mock/pagination.db +0 -0
- data/spec/mock/users.db +0 -0
- data/spec/unit/status_spec.rb +0 -9
data/lib/ayadn/workers.rb
CHANGED
@@ -3,23 +3,44 @@ module Ayadn
|
|
3
3
|
class Workers
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@
|
6
|
+
@thor = Thor::Shell::Color.new
|
7
|
+
@status = Status.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def table_borders
|
11
|
+
if Settings.options[:formats][:table][:borders] == true
|
12
|
+
{ :width => Settings.options[:formats][:table][:width], border_x: '—', border_i: '+', border_y: '|' }
|
13
|
+
else
|
14
|
+
{ :width => Settings.options[:formats][:table][:width], border_x: ' ', border_i: ' ', border_y: ' ' }
|
15
|
+
end
|
7
16
|
end
|
8
17
|
|
9
18
|
def build_aliases_list(list)
|
10
19
|
table = init_table
|
11
20
|
table.title = "List of your channel aliases".color(:cyan) + "".color(:white)
|
12
|
-
table.style =
|
13
|
-
|
21
|
+
table.style = table_borders()
|
22
|
+
table.headings = [ 'Channel', 'Alias' ]
|
23
|
+
list.each_with_index do |obj, index|
|
24
|
+
table << [obj[0].to_s.color(:green), obj[1].color(:red)]
|
25
|
+
if index + 1 != list.length && Settings.options[:timeline][:compact] == false
|
26
|
+
table << :separator
|
27
|
+
end
|
28
|
+
end
|
14
29
|
table
|
15
30
|
end
|
16
31
|
|
17
32
|
def build_blacklist_list(list)
|
18
33
|
table = init_table
|
19
34
|
table.title = "Your blacklist".color(:cyan) + "".color(:white)
|
20
|
-
table.style =
|
21
|
-
|
22
|
-
list.
|
35
|
+
table.style = table_borders()
|
36
|
+
table.headings = [ 'Name', 'Type' ]
|
37
|
+
list.sort!
|
38
|
+
list.each_with_index do |obj, index|
|
39
|
+
table << ["#{obj[1].capitalize}".color(:green), "#{obj[0]}".color(:red)]
|
40
|
+
if index + 1 != list.length && Settings.options[:timeline][:compact] == false
|
41
|
+
table << :separator
|
42
|
+
end
|
43
|
+
end
|
23
44
|
table
|
24
45
|
end
|
25
46
|
|
@@ -29,9 +50,9 @@ module Ayadn
|
|
29
50
|
users_list = []
|
30
51
|
list.each do |obj|
|
31
52
|
obj['name'].nil? ? name = "" : name = obj['name']
|
32
|
-
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id']}
|
53
|
+
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id'], :posts => obj['counts']['posts']}
|
33
54
|
end
|
34
|
-
table.style =
|
55
|
+
table.style = table_borders()
|
35
56
|
return users_list, table
|
36
57
|
end
|
37
58
|
|
@@ -41,50 +62,50 @@ module Ayadn
|
|
41
62
|
users_list = []
|
42
63
|
list.each do |obj|
|
43
64
|
obj['name'].nil? ? name = "" : name = obj['name']
|
44
|
-
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id']}
|
65
|
+
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id'], :posts => obj['counts']['posts']}
|
45
66
|
end
|
46
|
-
table.style =
|
67
|
+
table.style = table_borders()
|
47
68
|
return users_list, table
|
48
69
|
end
|
49
70
|
|
50
|
-
def build_followings_list(list, target) #takes a hash of users with ayadn format
|
71
|
+
def build_followings_list(list, target, options = {}) #takes a hash of users with ayadn format
|
51
72
|
table = init_table
|
52
73
|
table.title = if target == "me"
|
53
74
|
"List of users you're following".color(:cyan) + "".color(:white)
|
54
75
|
else
|
55
76
|
"List of users ".color(:cyan) + "#{target}".color(:red) + " is following ".color(:cyan) + "".color(:white)
|
56
77
|
end
|
57
|
-
table.style =
|
78
|
+
table.style = table_borders()
|
58
79
|
users_list = build_users_array(list)
|
59
|
-
build_users_list(users_list, table)
|
80
|
+
build_users_list(users_list, table, options)
|
60
81
|
end
|
61
82
|
|
62
|
-
def build_followers_list(list, target)
|
83
|
+
def build_followers_list(list, target, options = {})
|
63
84
|
table = init_table
|
64
85
|
table.title = if target == "me"
|
65
86
|
"List of your followers".color(:cyan) + "".color(:white)
|
66
87
|
else
|
67
88
|
"List of users following ".color(:cyan) + "#{target}".color(:red) + "".color(:white)
|
68
89
|
end
|
69
|
-
table.style =
|
70
|
-
build_users_list(build_users_array(list), table)
|
90
|
+
table.style = table_borders()
|
91
|
+
build_users_list(build_users_array(list), table, options)
|
71
92
|
end
|
72
93
|
|
73
|
-
def build_muted_list(list)
|
94
|
+
def build_muted_list(list, options = {})
|
74
95
|
table = init_table
|
75
96
|
table.title = "List of users you muted".color(:cyan) + "".color(:white)
|
76
|
-
table.style =
|
77
|
-
build_users_list(build_users_array(list), table)
|
97
|
+
table.style = table_borders()
|
98
|
+
build_users_list(build_users_array(list), table, options)
|
78
99
|
end
|
79
100
|
|
80
|
-
def build_blocked_list(list)
|
101
|
+
def build_blocked_list(list, options = {})
|
81
102
|
table = init_table
|
82
103
|
table.title = "List of users you blocked".color(:cyan) + "".color(:white)
|
83
|
-
table.style =
|
84
|
-
build_users_list(build_users_array(list), table)
|
104
|
+
table.style = table_borders()
|
105
|
+
build_users_list(build_users_array(list), table, options)
|
85
106
|
end
|
86
107
|
|
87
|
-
def build_users_list(list, table)
|
108
|
+
def build_users_list(list, table, options = {})
|
88
109
|
users = at(list.map {|obj| obj[:username]})
|
89
110
|
ids = list.map {|obj| obj[:id].to_i}
|
90
111
|
ranks = NiceRank.new.from_ids(ids)
|
@@ -97,9 +118,18 @@ module Ayadn
|
|
97
118
|
indexed_ranks[r['user_id']] = r
|
98
119
|
end
|
99
120
|
end
|
100
|
-
table << ['USERNAME'.color(:red), 'NAME'.color(:red), 'POSTS/DAY'.color(:red)]
|
121
|
+
table << ['USERNAME'.color(:red), 'NAME'.color(:red), 'POSTS'.color(:red), 'POSTS/DAY'.color(:red)]
|
101
122
|
table << :separator
|
102
|
-
|
123
|
+
arr = []
|
124
|
+
if options[:username]
|
125
|
+
list.sort_by! { |obj| obj[:username] }
|
126
|
+
elsif options[:name]
|
127
|
+
list.sort_by! { |obj| obj[:name].downcase }
|
128
|
+
elsif options[:posts]
|
129
|
+
list.sort_by! { |obj| [obj[:posts], obj[:username]] }
|
130
|
+
end
|
131
|
+
list.each do |obj|
|
132
|
+
obj[:name] = "" if obj[:name].nil?
|
103
133
|
unless indexed_ranks == false
|
104
134
|
details = indexed_ranks[obj[:id].to_i]
|
105
135
|
if details['user']['posts_day'] == -1
|
@@ -111,13 +141,21 @@ module Ayadn
|
|
111
141
|
posts_day = 'unknown'
|
112
142
|
end
|
113
143
|
obj[:username].length > 23 ? username = "#{obj[:username][0..20]}..." : username = obj[:username]
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
144
|
+
obj[:name].length > 23 ? name = "#{obj[:name][0..20]}..." : name = obj[:name]
|
145
|
+
arr << [ "@#{username} ".color(Settings.options[:colors][:username]), "#{name}", obj[:posts], posts_day ]
|
146
|
+
end
|
147
|
+
if options[:posts_day]
|
148
|
+
arr.sort_by! { |obj| obj[3].to_f }
|
149
|
+
end
|
150
|
+
if options[:reverse]
|
151
|
+
arr.reverse!
|
152
|
+
end
|
153
|
+
if Settings.options[:formats][:list][:reverse] == true
|
154
|
+
arr.reverse!
|
155
|
+
end
|
156
|
+
arr.each_with_index do |obj, index|
|
157
|
+
table << arr[index]
|
158
|
+
if index + 1 != arr.length && Settings.options[:timeline][:compact] == false
|
121
159
|
table << :separator
|
122
160
|
end
|
123
161
|
end
|
@@ -129,38 +167,46 @@ module Ayadn
|
|
129
167
|
# skip objects in blacklist unless force
|
130
168
|
posts = {}
|
131
169
|
data.each.with_index(1) do |post, index|
|
132
|
-
unless Settings.
|
133
|
-
if
|
134
|
-
|
135
|
-
|
170
|
+
unless Settings.global[:force] == true
|
171
|
+
if Settings.options[:blacklist][:active] == true
|
172
|
+
if Databases.is_in_blacklist?('client', post['source']['name'].downcase)
|
173
|
+
Debug.skipped({source: post['source']['name']})
|
174
|
+
next
|
175
|
+
end
|
136
176
|
end
|
137
177
|
end
|
138
|
-
unless Settings.
|
139
|
-
if
|
140
|
-
|
141
|
-
|
178
|
+
unless Settings.global[:force] == true
|
179
|
+
if Settings.options[:blacklist][:active] == true
|
180
|
+
if Databases.is_in_blacklist?('user', post['user']['username'].downcase)
|
181
|
+
Debug.skipped({user: post['user']['username']})
|
182
|
+
next
|
183
|
+
end
|
142
184
|
end
|
143
185
|
end
|
144
186
|
hashtags = extract_hashtags(post)
|
145
187
|
@skip = false
|
146
|
-
unless Settings.
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
188
|
+
unless Settings.global[:force] == true
|
189
|
+
if Settings.options[:blacklist][:active] == true
|
190
|
+
hashtags.each do |h|
|
191
|
+
if Databases.is_in_blacklist?('hashtag', h.downcase)
|
192
|
+
@skip = true
|
193
|
+
Debug.skipped({hashtag: h})
|
194
|
+
break
|
195
|
+
end
|
152
196
|
end
|
153
197
|
end
|
154
198
|
end
|
155
199
|
next if @skip
|
156
200
|
mentions= []
|
157
201
|
post['entities']['mentions'].each { |m| mentions << m['name'] }
|
158
|
-
unless Settings.
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
202
|
+
unless Settings.global[:force] == true
|
203
|
+
if Settings.options[:blacklist][:active] == true
|
204
|
+
mentions.each do |m|
|
205
|
+
if Databases.is_in_blacklist?('mention', m.downcase)
|
206
|
+
@skip = true
|
207
|
+
Debug.skipped({mention: m})
|
208
|
+
break
|
209
|
+
end
|
164
210
|
end
|
165
211
|
end
|
166
212
|
end
|
@@ -174,7 +220,7 @@ module Ayadn
|
|
174
220
|
else
|
175
221
|
rank = false
|
176
222
|
is_human = 'unknown'
|
177
|
-
real_person =
|
223
|
+
real_person = 'unknown'
|
178
224
|
end
|
179
225
|
|
180
226
|
if post['user'].has_key?('name')
|
@@ -198,6 +244,7 @@ module Ayadn
|
|
198
244
|
handle: "@#{post['user']['username']}",
|
199
245
|
type: post['user']['type'],
|
200
246
|
date: parsed_time(post['created_at']),
|
247
|
+
date_short: parsed_time_short(post['created_at']),
|
201
248
|
you_starred: post['you_starred'],
|
202
249
|
source_name: source,
|
203
250
|
source_link: post['source']['link'],
|
@@ -258,6 +305,7 @@ module Ayadn
|
|
258
305
|
posts[post['id'].to_i] = values
|
259
306
|
|
260
307
|
end
|
308
|
+
|
261
309
|
posts
|
262
310
|
end
|
263
311
|
|
@@ -268,7 +316,7 @@ module Ayadn
|
|
268
316
|
if ann['type'] == "net.app.core.oembed"
|
269
317
|
if ann['value']['embeddable_url']
|
270
318
|
links << ann['value']['embeddable_url']
|
271
|
-
elsif ann['value']['url'] && Settings.options[:
|
319
|
+
elsif ann['value']['url'] && Settings.options[:channels][:links] == true
|
272
320
|
links << ann['value']['url']
|
273
321
|
end
|
274
322
|
end
|
@@ -291,7 +339,7 @@ module Ayadn
|
|
291
339
|
}
|
292
340
|
filename = "#{Settings.config[:identity][:handle]}_#{origin}_links.json"
|
293
341
|
FileOps.save_links(obj, filename)
|
294
|
-
|
342
|
+
@status.links_saved(filename)
|
295
343
|
end
|
296
344
|
|
297
345
|
def extract_hashtags(post)
|
@@ -302,37 +350,41 @@ module Ayadn
|
|
302
350
|
bucket = []
|
303
351
|
data = [data] unless data.is_a?(Array)
|
304
352
|
if options[:channels]
|
305
|
-
|
353
|
+
@thor.say_status :downloading, "list of channels and their users credentials", :yellow
|
354
|
+
@thor.say_status :info, "it could take a while if there are many results and users", :cyan
|
306
355
|
else
|
307
|
-
|
356
|
+
@thor.say_status :downloading, "the channels and their users attributes (owners, writers, editors and readers)", :yellow
|
357
|
+
@thor.say_status :info, "users are recorded in a database for later filtering and analyzing", :cyan
|
358
|
+
@thor.say_status :info, "it could take a while if there are many results", :cyan
|
308
359
|
end
|
309
360
|
chan = Struct.new(:id, :num_messages, :subscribers, :type, :owner, :annotations, :readers, :editors, :writers, :you_subscribed, :unread, :recent_message_id, :recent_message)
|
310
361
|
no_user = {}
|
362
|
+
@api = API.new
|
311
363
|
data.each do |ch|
|
312
364
|
unless ch['writers']['user_ids'].empty?
|
313
|
-
@
|
365
|
+
@thor.say_status :parsing, "channel #{ch['id']}", :cyan
|
314
366
|
usernames = []
|
315
367
|
ch['writers']['user_ids'].each do |id|
|
316
368
|
next if no_user[id]
|
317
|
-
db = Databases.
|
369
|
+
db = Databases.find_user_by_id(id)
|
318
370
|
if db.nil?
|
319
|
-
@
|
320
|
-
resp =
|
371
|
+
@thor.say_status :downloading, "user #{id}", :yellow
|
372
|
+
resp = @api.get_user(id)
|
321
373
|
|
322
374
|
if resp['meta']['code'] != 200
|
323
|
-
@
|
375
|
+
@thor.say_status :error, "can't get user #{id}'s data, skipping", :red
|
324
376
|
no_user[id] = true
|
325
377
|
next
|
326
378
|
end
|
327
379
|
|
328
380
|
the_username = resp['data']['username']
|
329
|
-
@
|
381
|
+
@thor.say_status :recording, "@#{the_username}", :yellow
|
330
382
|
|
331
383
|
usernames << "@" + the_username
|
332
384
|
Databases.add_to_users_db(id, the_username, resp['data']['name'])
|
333
385
|
else
|
334
|
-
the_username = "
|
335
|
-
@
|
386
|
+
the_username = "@#{db}"
|
387
|
+
@thor.say_status :match, "#{the_username} is already in the database", :blue
|
336
388
|
|
337
389
|
usernames << the_username
|
338
390
|
end
|
@@ -347,8 +399,6 @@ module Ayadn
|
|
347
399
|
else
|
348
400
|
unread = "No unread messages"
|
349
401
|
end
|
350
|
-
@shell.say_status :recording, "channel #{ch['id']}", :green
|
351
|
-
Databases.add_channel_object(ch)
|
352
402
|
bucket << chan.new(ch['id'], ch['counts']['messages'], ch['counts']['subscribers'], ch['type'], ch['owner'], ch['annotations'], ch['readers'], ch['editors'], writers, ch['you_subscribed'], unread, ch['recent_message_id'], ch['recent_message'])
|
353
403
|
end
|
354
404
|
puts "\e[H\e[2J"
|
@@ -359,21 +409,13 @@ module Ayadn
|
|
359
409
|
"#{string[0...10]} #{string[11...19]}"
|
360
410
|
end
|
361
411
|
|
362
|
-
def
|
363
|
-
|
364
|
-
if user == 'me'
|
365
|
-
'me'
|
366
|
-
elsif user[0] == '@'
|
367
|
-
user
|
368
|
-
else
|
369
|
-
"@#{user}"
|
370
|
-
end
|
371
|
-
end
|
412
|
+
def parsed_time_short(string)
|
413
|
+
"#{string[11...19]}"
|
372
414
|
end
|
373
415
|
|
374
416
|
def get_original_id(post_id, resp)
|
375
417
|
if resp['data']['repost_of']
|
376
|
-
|
418
|
+
@status.redirecting
|
377
419
|
id = resp['data']['repost_of']['id']
|
378
420
|
Errors.repost(post_id, id)
|
379
421
|
return id
|
@@ -388,7 +430,7 @@ module Ayadn
|
|
388
430
|
channel_id = Databases.get_channel_id(orig)
|
389
431
|
if channel_id.nil?
|
390
432
|
Errors.warn("Alias '#{orig}' doesn't exist.")
|
391
|
-
|
433
|
+
@status.no_alias
|
392
434
|
exit
|
393
435
|
end
|
394
436
|
end
|
@@ -405,9 +447,9 @@ module Ayadn
|
|
405
447
|
|
406
448
|
def get_real_post_id post_id
|
407
449
|
id = post_id.to_i
|
408
|
-
if id
|
450
|
+
if id <= 200
|
409
451
|
resp = get_post_from_index(id)
|
410
|
-
post_id = resp[
|
452
|
+
post_id = resp['id']
|
411
453
|
end
|
412
454
|
post_id
|
413
455
|
end
|
@@ -435,7 +477,7 @@ module Ayadn
|
|
435
477
|
args
|
436
478
|
end
|
437
479
|
|
438
|
-
def add_arobases_to_usernames args
|
480
|
+
def add_arobases_to_usernames args
|
439
481
|
args.map do |username|
|
440
482
|
if username == 'me'
|
441
483
|
who_am_i
|
@@ -447,16 +489,26 @@ module Ayadn
|
|
447
489
|
end
|
448
490
|
end
|
449
491
|
|
492
|
+
def at usernames
|
493
|
+
usernames.map do |user|
|
494
|
+
if user == 'me'
|
495
|
+
'me'
|
496
|
+
elsif user[0] == '@'
|
497
|
+
user
|
498
|
+
else
|
499
|
+
"@#{user}"
|
500
|
+
end
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
450
504
|
def who_am_i
|
451
|
-
|
452
|
-
active = db['ACTIVE']
|
453
|
-
db[active][:handle]
|
505
|
+
Databases.active_account(Amalgalite::Database.new(Dir.home + "/ayadn/accounts.sqlite"))[2]
|
454
506
|
end
|
455
507
|
|
456
508
|
def extract_users(resp)
|
457
509
|
users_hash = {}
|
458
510
|
resp['data'].each do |item|
|
459
|
-
users_hash[item['id']] = [item['username'], item['name'], item['you_follow'], item['follows_you']]
|
511
|
+
users_hash[item['id']] = [item['username'], item['name'], item['you_follow'], item['follows_you'], item['counts']['posts']]
|
460
512
|
end
|
461
513
|
users_hash
|
462
514
|
end
|
@@ -543,6 +595,10 @@ module Ayadn
|
|
543
595
|
at(arr)
|
544
596
|
end
|
545
597
|
|
598
|
+
def self.epoch_to_date(epoch)
|
599
|
+
Time.at(epoch).to_time
|
600
|
+
end
|
601
|
+
|
546
602
|
private
|
547
603
|
|
548
604
|
def def_str(word, reg_split)
|
@@ -564,13 +620,9 @@ module Ayadn
|
|
564
620
|
|
565
621
|
def build_users_array(list)
|
566
622
|
users = list.map do |key, value|
|
567
|
-
{:username => value[0], :name => value[1], :you_follow => value[2], :follows_you => value[3], :id => key}
|
568
|
-
end
|
569
|
-
if Settings.options[:formats][:list][:reverse]
|
570
|
-
return users.reverse
|
571
|
-
else
|
572
|
-
return users
|
623
|
+
{:username => value[0], :name => value[1], :you_follow => value[2], :follows_you => value[3], :id => key, :posts => value[4]}
|
573
624
|
end
|
625
|
+
return users
|
574
626
|
end
|
575
627
|
|
576
628
|
def extract_checkins(post)
|
data/lib/ayadn.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require_relative 'ayadn/version'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# end
|
4
|
+
begin
|
5
|
+
%w{rest_client json thor rainbow/ext/string terminal-table yaml logger fileutils io/console unicode_utils/char_type readline amalgalite fast_cache}.each { |r| require "#{r}" }
|
6
|
+
rescue LoadError => e
|
7
|
+
puts "\nAYADN: Error while loading Gems\n\n"
|
8
|
+
puts "RUBY: #{e}\n\n"
|
9
|
+
exit
|
10
|
+
end
|
12
11
|
|
13
12
|
require_relative 'ayadn/app'
|
Binary file
|
Binary file
|
@@ -9,15 +9,13 @@ describe Ayadn::Annotations do
|
|
9
9
|
{
|
10
10
|
timeline: {
|
11
11
|
directed: 1,
|
12
|
-
deleted: 0,
|
13
12
|
html: 0,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
show_debug: false
|
13
|
+
source: true,
|
14
|
+
symbols: true,
|
15
|
+
name: true,
|
16
|
+
date: true,
|
17
|
+
spinner: true,
|
18
|
+
debug: false
|
21
19
|
},
|
22
20
|
counts: {
|
23
21
|
default: 50,
|
@@ -54,12 +52,13 @@ describe Ayadn::Annotations do
|
|
54
52
|
mentions: :red,
|
55
53
|
source: :cyan,
|
56
54
|
symbols: :green,
|
57
|
-
debug: :red
|
55
|
+
debug: :red,
|
56
|
+
excerpt: :green
|
58
57
|
},
|
59
58
|
backup: {
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
posts: false,
|
60
|
+
messages: false,
|
61
|
+
lists: false
|
63
62
|
},
|
64
63
|
scroll: {
|
65
64
|
timer: 3
|
@@ -68,7 +67,7 @@ describe Ayadn::Annotations do
|
|
68
67
|
threshold: 2.1,
|
69
68
|
cache: 48,
|
70
69
|
filter: true,
|
71
|
-
|
70
|
+
unranked: false
|
72
71
|
},
|
73
72
|
nowplaying: {},
|
74
73
|
movie: {
|
data/spec/unit/api_spec.rb
CHANGED
@@ -8,7 +8,6 @@ describe Ayadn::API do
|
|
8
8
|
},
|
9
9
|
timeline: {
|
10
10
|
directed: 1,
|
11
|
-
deleted: 0,
|
12
11
|
html: 0,
|
13
12
|
annotations: 1
|
14
13
|
}
|
@@ -19,10 +18,10 @@ describe Ayadn::API do
|
|
19
18
|
expect(Ayadn::API.build_query({count: 12})).to match /count=12/
|
20
19
|
end
|
21
20
|
it 'returns a URL with directed=0' do
|
22
|
-
expect(Ayadn::API.build_query({directed: 0})).to match /
|
21
|
+
expect(Ayadn::API.build_query({directed: 0})).to match /directed_posts=0/
|
23
22
|
end
|
24
|
-
it 'returns a URL with html=
|
25
|
-
expect(Ayadn::API.build_query({html: 1})).to match /html=
|
23
|
+
it 'returns a URL with html=0 anyway' do
|
24
|
+
expect(Ayadn::API.build_query({html: 1})).to match /html=0/
|
26
25
|
end
|
27
26
|
end
|
28
27
|
describe "#check_response_meta_code" do
|
@@ -14,13 +14,14 @@ describe Ayadn::BlacklistWorkers do
|
|
14
14
|
symbols: :green,
|
15
15
|
index: :blue,
|
16
16
|
date: :cyan,
|
17
|
-
link: :magenta
|
17
|
+
link: :magenta,
|
18
|
+
excerpt: :green
|
18
19
|
},
|
19
20
|
timeline: {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
name: true,
|
22
|
+
date: true,
|
23
|
+
symbols: true,
|
24
|
+
source: true
|
24
25
|
},
|
25
26
|
formats: {table: {width: 75}},
|
26
27
|
counts: {
|
@@ -37,7 +38,6 @@ describe Ayadn::BlacklistWorkers do
|
|
37
38
|
version: 'wee',
|
38
39
|
paths: {
|
39
40
|
db: 'spec/mock/',
|
40
|
-
pagination: 'spec/mock/',
|
41
41
|
log: 'spec/mock'
|
42
42
|
}
|
43
43
|
})
|
@@ -53,17 +53,17 @@ describe Ayadn::BlacklistWorkers do
|
|
53
53
|
it "adds a client to the blacklist" do
|
54
54
|
k = Ayadn::BlacklistWorkers.new
|
55
55
|
k.add(['source', 'Zapier'])
|
56
|
-
expect(Ayadn::Databases.
|
56
|
+
expect(Ayadn::Databases.is_in_blacklist?('client', 'zapier')).to eq true
|
57
57
|
end
|
58
58
|
it "adds a hashtag to the blacklist" do
|
59
59
|
k = Ayadn::BlacklistWorkers.new
|
60
60
|
k.add(['tag', 'tv'])
|
61
|
-
expect(Ayadn::Databases.
|
61
|
+
expect(Ayadn::Databases.is_in_blacklist?('hashtag', 'tv')).to eq true
|
62
62
|
end
|
63
63
|
it "adds a mention to the blacklist" do
|
64
64
|
k = Ayadn::BlacklistWorkers.new
|
65
65
|
k.add(['mentions', 'yolo'])
|
66
|
-
expect(Ayadn::Databases.
|
66
|
+
expect(Ayadn::Databases.is_in_blacklist?('mention', 'yolo')).to eq true
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,49 +71,44 @@ describe Ayadn::BlacklistWorkers do
|
|
71
71
|
it "removes a client from the blacklist" do
|
72
72
|
k = Ayadn::BlacklistWorkers.new
|
73
73
|
k.add(['client', 'IFTTT'])
|
74
|
-
expect(Ayadn::Databases.
|
74
|
+
expect(Ayadn::Databases.is_in_blacklist?('client', 'ifttt')).to eq true
|
75
75
|
|
76
76
|
k = Ayadn::BlacklistWorkers.new
|
77
77
|
k.remove(['client', 'IFTTT'])
|
78
|
-
expect(Ayadn::Databases.
|
78
|
+
expect(Ayadn::Databases.is_in_blacklist?('client', 'ifttt')).to eq false
|
79
79
|
end
|
80
80
|
it "removes a hashtag from the blacklist" do
|
81
81
|
k = Ayadn::BlacklistWorkers.new
|
82
82
|
k.add(['hashtag', 'Sports'])
|
83
|
-
expect(Ayadn::Databases.
|
83
|
+
expect(Ayadn::Databases.is_in_blacklist?('hashtag', 'sports')).to eq true
|
84
84
|
|
85
85
|
k = Ayadn::BlacklistWorkers.new
|
86
86
|
k.remove(['hashtag', 'Sports'])
|
87
|
-
expect(Ayadn::Databases.
|
87
|
+
expect(Ayadn::Databases.is_in_blacklist?('hashtag', 'sports')).to eq false
|
88
88
|
end
|
89
89
|
it "removes a mention from the blacklist" do
|
90
90
|
k = Ayadn::BlacklistWorkers.new
|
91
91
|
k.add(['mention', 'mrTest'])
|
92
|
-
expect(Ayadn::Databases.
|
92
|
+
expect(Ayadn::Databases.is_in_blacklist?('mention', 'mrtest')).to eq true
|
93
93
|
|
94
94
|
k = Ayadn::BlacklistWorkers.new
|
95
95
|
k.remove(['mention', 'mrTest'])
|
96
|
-
expect(Ayadn::Databases.
|
96
|
+
expect(Ayadn::Databases.is_in_blacklist?('mention', 'mrtest')).to eq false
|
97
97
|
end
|
98
98
|
it "removes a user from the blacklist" do
|
99
99
|
k = Ayadn::BlacklistWorkers.new
|
100
100
|
k.add(['user', 'mrTest'])
|
101
|
-
expect(Ayadn::Databases.
|
101
|
+
expect(Ayadn::Databases.is_in_blacklist?('user', 'mrtest')).to eq true
|
102
102
|
|
103
103
|
k = Ayadn::BlacklistWorkers.new
|
104
104
|
k.remove(['account', 'mrTest'])
|
105
|
-
expect(Ayadn::Databases.
|
105
|
+
expect(Ayadn::Databases.is_in_blacklist?('user', 'mrtest')).to eq false
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
after do
|
110
110
|
File.delete('spec/mock/ayadn.log')
|
111
111
|
Ayadn::Databases.open_databases
|
112
|
-
Ayadn::Databases.
|
113
|
-
Ayadn::Databases.users.clear
|
114
|
-
Ayadn::Databases.pagination.clear
|
115
|
-
Ayadn::Databases.index.clear
|
116
|
-
Ayadn::Databases.aliases.clear
|
117
|
-
Ayadn::Databases.close_all
|
112
|
+
Ayadn::Databases.clear_blacklist
|
118
113
|
end
|
119
114
|
end
|