ayadn 3.0 → 4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/CHANGELOG.md +12 -4
- data/README.md +2 -5
- data/ayadn.gemspec +0 -2
- data/doc/01-index.md +0 -3
- data/doc/02-install.md +0 -4
- data/doc/06-post.md +0 -16
- data/doc/{18-contact.md → 16-contact.md} +0 -0
- data/doc/{19-examples.md → 17-examples.md} +0 -0
- data/doc/18-develop.md +165 -0
- data/lib/ayadn/action.rb +206 -396
- data/lib/ayadn/alias.rb +1 -1
- data/lib/ayadn/annotations.rb +15 -27
- data/lib/ayadn/api.rb +39 -28
- data/lib/ayadn/app.rb +19 -29
- data/lib/ayadn/authorize.rb +22 -13
- data/lib/ayadn/blacklist.rb +6 -19
- data/lib/ayadn/channel_object.rb +75 -0
- data/lib/ayadn/check.rb +19 -11
- data/lib/ayadn/cnx.rb +9 -15
- data/lib/ayadn/databases.rb +15 -27
- data/lib/ayadn/debug.rb +9 -9
- data/lib/ayadn/descriptions.rb +1 -99
- data/lib/ayadn/diagnostics.rb +16 -15
- data/lib/ayadn/endpoints.rb +18 -22
- data/lib/ayadn/errors.rb +1 -1
- data/lib/ayadn/fileops.rb +12 -12
- data/lib/ayadn/filtered_post_object.rb +11 -0
- data/lib/ayadn/ids.rb +0 -3
- data/lib/ayadn/logs.rb +4 -4
- data/lib/ayadn/mark.rb +34 -30
- data/lib/ayadn/nicerank.rb +7 -7
- data/lib/ayadn/nowplaying.rb +8 -22
- data/lib/ayadn/pinboard.rb +8 -12
- data/lib/ayadn/post.rb +18 -18
- data/lib/ayadn/post_object.rb +118 -0
- data/lib/ayadn/preferences_object.rb +290 -0
- data/lib/ayadn/profile.rb +2 -2
- data/lib/ayadn/scroll.rb +58 -67
- data/lib/ayadn/search.rb +22 -15
- data/lib/ayadn/set.rb +93 -83
- data/lib/ayadn/settings.rb +25 -33
- data/lib/ayadn/status.rb +24 -26
- data/lib/ayadn/stream.rb +68 -66
- data/lib/ayadn/stream_object.rb +56 -0
- data/lib/ayadn/switch.rb +2 -2
- data/lib/ayadn/user_object.rb +116 -0
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +255 -278
- data/lib/ayadn/workers.rb +172 -174
- data/spec/integration/action_spec.rb +55 -34
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/unit/annotations_spec.rb +54 -41
- data/spec/unit/api_spec.rb +78 -7
- data/spec/unit/blacklistworkers_spec.rb +92 -20
- data/spec/unit/databases_spec.rb +117 -36
- data/spec/unit/endpoints_spec.rb +82 -10
- data/spec/unit/nicerank_spec.rb +56 -27
- data/spec/unit/post_spec.rb +94 -21
- data/spec/unit/set_spec.rb +141 -210
- data/spec/unit/view_spec.rb +105 -32
- data/spec/unit/workers_spec.rb +143 -52
- metadata +12 -37
- data/doc/16-movie.md +0 -39
- data/doc/17-tvshow.md +0 -46
- data/lib/ayadn/nowwatching.rb +0 -118
- data/lib/ayadn/tvshow.rb +0 -162
data/lib/ayadn/workers.rb
CHANGED
@@ -2,17 +2,15 @@
|
|
2
2
|
module Ayadn
|
3
3
|
class Workers
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@status = Status.new
|
5
|
+
def initialize status = Status.new
|
6
|
+
@status = status
|
9
7
|
end
|
10
8
|
|
11
9
|
def table_borders
|
12
|
-
if Settings.options
|
13
|
-
{ :width => Settings.options
|
10
|
+
if Settings.options.formats.table.borders
|
11
|
+
{ :width => Settings.options.formats.table.width, border_x: '—', border_i: '+', border_y: '|' }
|
14
12
|
else
|
15
|
-
{ :width => Settings.options
|
13
|
+
{ :width => Settings.options.formats.table.width, border_x: ' ', border_i: ' ', border_y: ' ' }
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
@@ -23,7 +21,7 @@ module Ayadn
|
|
23
21
|
table.headings = [ 'Channel', 'Alias' ]
|
24
22
|
list.each_with_index do |obj, index|
|
25
23
|
table << [obj[0].to_s.color(:green), obj[1].color(:red)]
|
26
|
-
if index + 1 != list.length && Settings.options
|
24
|
+
if index + 1 != list.length && !Settings.options.timeline.compact
|
27
25
|
table << :separator
|
28
26
|
end
|
29
27
|
end
|
@@ -38,7 +36,7 @@ module Ayadn
|
|
38
36
|
list.sort!
|
39
37
|
list.each_with_index do |obj, index|
|
40
38
|
table << ["#{obj[1].capitalize}".to_s.force_encoding("UTF-8").color(:green), "#{obj[0]}".to_s.force_encoding("UTF-8").color(:red)]
|
41
|
-
if index + 1 != list.length && Settings.options
|
39
|
+
if index + 1 != list.length && !Settings.options.timeline.compact
|
42
40
|
table << :separator
|
43
41
|
end
|
44
42
|
end
|
@@ -46,27 +44,13 @@ module Ayadn
|
|
46
44
|
end
|
47
45
|
|
48
46
|
def build_reposted_list(list, target)
|
49
|
-
|
50
|
-
|
51
|
-
users_list = []
|
52
|
-
list.each do |obj|
|
53
|
-
obj['name'].nil? ? name = "" : name = obj['name'].to_s.force_encoding("UTF-8")
|
54
|
-
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id'], :posts => obj['counts']['posts']}
|
55
|
-
end
|
56
|
-
table.style = table_borders()
|
57
|
-
return users_list, table
|
47
|
+
title = "List of users who reposted post ".color(:cyan) + "#{target}".color(:red) + "".color(:white)
|
48
|
+
build_reposted_or_starred_list(list, title)
|
58
49
|
end
|
59
50
|
|
60
51
|
def build_starred_list(list, target)
|
61
|
-
|
62
|
-
|
63
|
-
users_list = []
|
64
|
-
list.each do |obj|
|
65
|
-
obj['name'].nil? ? name = "" : name = obj['name'].to_s.force_encoding("UTF-8")
|
66
|
-
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id'], :posts => obj['counts']['posts']}
|
67
|
-
end
|
68
|
-
table.style = table_borders()
|
69
|
-
return users_list, table
|
52
|
+
title = "List of users who starred post ".color(:cyan) + "#{target}".color(:red) + "".color(:white)
|
53
|
+
build_reposted_or_starred_list(list, title)
|
70
54
|
end
|
71
55
|
|
72
56
|
def build_followings_list(list, target, options = {}) #takes a hash of users with ayadn format
|
@@ -124,62 +108,60 @@ module Ayadn
|
|
124
108
|
obj[:name] = "" if obj[:name].nil?
|
125
109
|
obj[:username].length > 23 ? username = "#{obj[:username][0..20]}..." : username = obj[:username]
|
126
110
|
obj[:name].length > 23 ? name = "#{obj[:name][0..20]}..." : name = obj[:name]
|
127
|
-
arr << [ "@#{username} ".color(Settings.options
|
111
|
+
arr << [ "@#{username} ".color(Settings.options.colors.username), "#{name.to_s.force_encoding('UTF-8')}", obj[:posts] ]
|
128
112
|
end
|
129
113
|
if options[:reverse]
|
130
114
|
arr.reverse!
|
131
115
|
end
|
132
|
-
if Settings.options
|
116
|
+
if Settings.options.formats.list.reverse
|
133
117
|
arr.reverse!
|
134
118
|
end
|
135
119
|
arr.each_with_index do |obj, index|
|
136
120
|
table << arr[index]
|
137
|
-
if index + 1 != arr.length && Settings.options
|
121
|
+
if index + 1 != arr.length && !Settings.options.timeline.compact
|
138
122
|
table << :separator
|
139
123
|
end
|
140
124
|
end
|
141
125
|
table
|
142
126
|
end
|
143
127
|
|
144
|
-
|
145
|
-
def build_posts(data, niceranks = {})
|
128
|
+
def build_posts(posts, niceranks = {})
|
146
129
|
# skip objects in blacklist unless force
|
147
|
-
|
148
|
-
|
149
|
-
unless Settings.global
|
150
|
-
if Settings.options
|
151
|
-
if Databases.is_in_blacklist?('client', post
|
152
|
-
Debug.skipped({source: post
|
130
|
+
results = []
|
131
|
+
posts.each.with_index(1) do |post, index|
|
132
|
+
unless Settings.global.force
|
133
|
+
if Settings.options.blacklist.active
|
134
|
+
if Databases.is_in_blacklist?('client', post.source.name.downcase)
|
135
|
+
Debug.skipped({source: post.source.name})
|
153
136
|
next
|
154
137
|
end
|
155
138
|
end
|
156
139
|
end
|
157
|
-
unless Settings.global
|
158
|
-
if Settings.options
|
159
|
-
if Databases.is_in_blacklist?('user', post
|
160
|
-
Debug.skipped({user: post
|
140
|
+
unless Settings.global.force
|
141
|
+
if Settings.options.blacklist.active
|
142
|
+
if Databases.is_in_blacklist?('user', post.user.username.downcase)
|
143
|
+
Debug.skipped({user: post.user.username})
|
161
144
|
next
|
162
145
|
end
|
163
146
|
end
|
164
147
|
end
|
165
148
|
hashtags = extract_hashtags(post)
|
166
149
|
@skip = false
|
167
|
-
unless Settings.global
|
168
|
-
if Settings.options
|
169
|
-
hashtags.each do |
|
170
|
-
if Databases.is_in_blacklist?('hashtag',
|
150
|
+
unless Settings.global.force
|
151
|
+
if Settings.options.blacklist.active
|
152
|
+
hashtags.each do |tag|
|
153
|
+
if Databases.is_in_blacklist?('hashtag', tag.downcase)
|
171
154
|
@skip = true
|
172
|
-
Debug.skipped({hashtag:
|
155
|
+
Debug.skipped({hashtag: tag})
|
173
156
|
break
|
174
157
|
end
|
175
158
|
end
|
176
159
|
end
|
177
160
|
end
|
178
161
|
next if @skip
|
179
|
-
mentions=
|
180
|
-
|
181
|
-
|
182
|
-
if Settings.options[:blacklist][:active] == true
|
162
|
+
mentions = extract_mentions(post)
|
163
|
+
unless Settings.global.force
|
164
|
+
if Settings.options.blacklist.active
|
183
165
|
mentions.each do |m|
|
184
166
|
if Databases.is_in_blacklist?('mention', m.downcase)
|
185
167
|
@skip = true
|
@@ -190,9 +172,9 @@ module Ayadn
|
|
190
172
|
end
|
191
173
|
end
|
192
174
|
next if @skip
|
193
|
-
unless Settings.global
|
194
|
-
if Settings.options
|
195
|
-
post
|
175
|
+
unless Settings.global.force
|
176
|
+
if Settings.options.blacklist.active
|
177
|
+
post.text.split(" ").each do |word|
|
196
178
|
target_word = word.gsub(/[~:-;,?!\'&`^=+<>*%()\/"“”’°£$€.…]/, "")
|
197
179
|
if Databases.is_in_blacklist?('word', target_word.downcase)
|
198
180
|
Debug.skipped({word: target_word})
|
@@ -205,108 +187,105 @@ module Ayadn
|
|
205
187
|
next if @skip
|
206
188
|
|
207
189
|
# create custom objects from ADN response
|
208
|
-
|
209
|
-
|
210
|
-
|
190
|
+
filtered = FilteredPost.new(post)
|
191
|
+
|
192
|
+
user_id_int = post.user.id.to_i
|
193
|
+
if niceranks[user_id_int]
|
194
|
+
filtered.nicerank = niceranks[user_id_int][:rank]
|
195
|
+
filtered.is_human = niceranks[user_id_int][:is_human]
|
211
196
|
else
|
212
|
-
|
213
|
-
is_human = 'unknown'
|
197
|
+
filtered.nicerank = false
|
198
|
+
filtered.is_human = 'unknown'
|
214
199
|
end
|
215
200
|
|
216
|
-
if post
|
217
|
-
name = post
|
201
|
+
if !post.user.name.blank?
|
202
|
+
filtered.name = post.user.name.force_encoding("UTF-8")
|
218
203
|
else
|
219
|
-
name = "(no name)"
|
204
|
+
filtered.name = "(no name)"
|
220
205
|
end
|
221
206
|
|
222
|
-
source = post
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
values[:checkins], values[:has_checkins] = extract_checkins(post)
|
248
|
-
|
249
|
-
if post['repost_of']
|
250
|
-
values[:is_repost] = true
|
251
|
-
values[:repost_of] = post['repost_of']['id']
|
252
|
-
values[:original_poster] = post['repost_of']['user']['username']
|
207
|
+
source = post.source.name.force_encoding("UTF-8")
|
208
|
+
|
209
|
+
filtered.count = index
|
210
|
+
filtered.id = post.id.to_i
|
211
|
+
filtered.thread_id = post.thread_id
|
212
|
+
filtered.username = post.user.username
|
213
|
+
filtered.user_id = post.user.id.to_i
|
214
|
+
filtered.handle = "@#{post.user.username}"
|
215
|
+
filtered.type = post.user.type
|
216
|
+
filtered.date = parsed_time(post.created_at)
|
217
|
+
filtered.date_short = parsed_time_short(post.created_at)
|
218
|
+
filtered.you_starred = post.you_starred
|
219
|
+
filtered.source_name = source
|
220
|
+
filtered.source_link = post.source.link
|
221
|
+
filtered.canonical_url = post.canonical_url
|
222
|
+
filtered.tags = hashtags
|
223
|
+
filtered.links = extract_links(post)
|
224
|
+
filtered.mentions = mentions
|
225
|
+
filtered.directed_to = mentions.first || false
|
226
|
+
filtered.checkins, filtered.has_checkins = extract_checkins(post)
|
227
|
+
|
228
|
+
if !post.repost_of.nil?
|
229
|
+
filtered.is_repost = true
|
230
|
+
filtered.repost_of = post.repost_of.id
|
231
|
+
filtered.original_poster = post.repost_of.user.username
|
253
232
|
else
|
254
|
-
|
255
|
-
|
256
|
-
|
233
|
+
filtered.is_repost = false
|
234
|
+
filtered.repost_of = nil
|
235
|
+
filtered.original_poster = post.user.username
|
257
236
|
end
|
258
237
|
|
259
|
-
unless post
|
260
|
-
|
261
|
-
|
238
|
+
unless post.text.blank?
|
239
|
+
filtered.raw_text = post.text
|
240
|
+
filtered.text = colorize_text(post.text, mentions, hashtags)
|
262
241
|
else
|
263
|
-
|
264
|
-
|
242
|
+
filtered.raw_text = ""
|
243
|
+
filtered.text = "(no text)"
|
265
244
|
end
|
266
245
|
|
267
|
-
unless post
|
268
|
-
|
269
|
-
|
246
|
+
unless post.num_stars.nil? || post.num_stars == 0
|
247
|
+
filtered.is_starred = true
|
248
|
+
filtered.num_stars = post.num_stars
|
270
249
|
else
|
271
|
-
|
272
|
-
|
250
|
+
filtered.is_starred = false
|
251
|
+
filtered.num_stars = 0
|
273
252
|
end
|
274
253
|
|
275
|
-
if post
|
276
|
-
|
254
|
+
if !post.num_replies.nil?
|
255
|
+
filtered.num_replies = post.num_replies
|
277
256
|
else
|
278
|
-
|
257
|
+
filtered.num_replies = 0
|
279
258
|
end
|
280
259
|
|
281
|
-
if post
|
282
|
-
|
283
|
-
|
260
|
+
if !post.reply_to.nil?
|
261
|
+
filtered.is_reply = true
|
262
|
+
filtered.reply_to = post.reply_to
|
284
263
|
else
|
285
|
-
|
286
|
-
|
264
|
+
filtered.is_reply = false
|
265
|
+
filtered.reply_to = nil
|
287
266
|
end
|
288
|
-
if post
|
289
|
-
|
267
|
+
if !post.num_reposts.nil?
|
268
|
+
filtered.num_reposts = post.num_reposts
|
290
269
|
else
|
291
|
-
|
270
|
+
filtered.num_reposts = 0
|
292
271
|
end
|
293
272
|
|
294
|
-
|
273
|
+
results << filtered
|
295
274
|
|
296
275
|
end
|
297
276
|
|
298
|
-
|
277
|
+
results
|
299
278
|
end
|
300
279
|
|
301
280
|
def extract_links(post)
|
302
|
-
links = post
|
303
|
-
unless post
|
304
|
-
post
|
305
|
-
if ann
|
306
|
-
if ann
|
307
|
-
links << ann
|
308
|
-
elsif ann
|
309
|
-
links << ann
|
281
|
+
links = post.entities.links.map { |l| l.url }
|
282
|
+
unless post.annotations.blank?
|
283
|
+
post.annotations.each do |ann|
|
284
|
+
if ann.type == "net.app.core.oembed"
|
285
|
+
if ann.value['embeddable_url']
|
286
|
+
links << ann.value['embeddable_url']
|
287
|
+
elsif ann.value['url'] && Settings.options.channels.links
|
288
|
+
links << ann.value['url']
|
310
289
|
end
|
311
290
|
end
|
312
291
|
end
|
@@ -322,26 +301,26 @@ module Ayadn
|
|
322
301
|
'origin' => origin,
|
323
302
|
'args' => args,
|
324
303
|
'created_at' => Time.now,
|
325
|
-
'username' => Settings.config
|
304
|
+
'username' => Settings.config.identity.handle
|
326
305
|
},
|
327
306
|
'data' => links
|
328
307
|
}
|
329
|
-
filename = "#{Settings.config
|
308
|
+
filename = "#{Settings.config.identity.handle}_#{origin}_links.json"
|
330
309
|
FileOps.save_links(obj, filename)
|
331
310
|
@status.links_saved(filename)
|
332
311
|
end
|
333
312
|
|
334
313
|
def extract_hashtags(post)
|
335
|
-
post
|
314
|
+
post.entities.hashtags.map { |h| h.name }
|
336
315
|
end
|
337
316
|
|
338
317
|
def extract_mentions(post)
|
339
|
-
post
|
318
|
+
post.entities.mentions.map { |m| m.name }
|
340
319
|
end
|
341
320
|
|
342
|
-
def build_channels(
|
321
|
+
def build_channels(stream, options = {})
|
343
322
|
bucket = []
|
344
|
-
|
323
|
+
stream = [stream] unless stream.is_a?(Array)
|
345
324
|
if options[:channels]
|
346
325
|
@status.say_yellow :downloading, "list of channels and their users credentials"
|
347
326
|
@status.say_info "it could take a while if there are many results and users"
|
@@ -350,19 +329,21 @@ module Ayadn
|
|
350
329
|
@status.say_info "users are recorded in a database for later filtering and analyzing"
|
351
330
|
@status.say_info "it could take a while if there are many results"
|
352
331
|
end
|
332
|
+
|
353
333
|
chan = Struct.new(:id, :num_messages, :subscribers, :type, :owner, :annotations, :readers, :editors, :writers, :you_subscribed, :unread, :recent_message_id, :recent_message)
|
334
|
+
|
354
335
|
no_user = {}
|
355
|
-
|
356
|
-
|
357
|
-
unless ch
|
358
|
-
@status.say_cyan :parsing, "channel #{ch
|
336
|
+
api = API.new
|
337
|
+
stream.each do |ch|
|
338
|
+
unless ch.writers.user_ids.empty?
|
339
|
+
@status.say_cyan :parsing, "channel #{ch.id}"
|
359
340
|
usernames = []
|
360
|
-
ch
|
341
|
+
ch.writers.user_ids.each do |id|
|
361
342
|
next if no_user[id]
|
362
343
|
db = Databases.find_user_by_id(id)
|
363
344
|
if db.nil?
|
364
345
|
@status.say_yellow :downloading, "user #{id}"
|
365
|
-
resp =
|
346
|
+
resp = api.get_user(id)
|
366
347
|
|
367
348
|
if resp['meta']['code'] != 200
|
368
349
|
@status.say_error "can't get user #{id}'s data, skipping"
|
@@ -382,22 +363,26 @@ module Ayadn
|
|
382
363
|
usernames << the_username
|
383
364
|
end
|
384
365
|
end
|
385
|
-
usernames << Settings.config
|
366
|
+
usernames << Settings.config.identity.handle unless usernames.length == 1 && usernames.first == Settings.config[:identity][:handle]
|
386
367
|
writers = usernames.join(", ")
|
387
368
|
else
|
388
|
-
writers = Settings.config
|
369
|
+
writers = Settings.config.identity.handle
|
389
370
|
end
|
390
|
-
if ch
|
371
|
+
if ch.has_unread
|
391
372
|
unread = "This channel has unread message(s)"
|
392
373
|
else
|
393
374
|
unread = "No unread messages"
|
394
375
|
end
|
395
|
-
bucket << chan.new(ch
|
376
|
+
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)
|
396
377
|
end
|
397
|
-
|
378
|
+
clear_screen
|
398
379
|
bucket
|
399
380
|
end
|
400
381
|
|
382
|
+
def clear_screen
|
383
|
+
puts "\e[H\e[2J"
|
384
|
+
end
|
385
|
+
|
401
386
|
def parsed_time(string)
|
402
387
|
"#{string[0...10]} #{string[11...19]}"
|
403
388
|
end
|
@@ -513,8 +498,8 @@ module Ayadn
|
|
513
498
|
reg_sentence = '^.+[\r\n]*'
|
514
499
|
handles, words, sentences = [], [], []
|
515
500
|
mentions.each {|username| handles << "@#{username}"}
|
516
|
-
hashtag_color = Settings.options
|
517
|
-
mention_color = Settings.options
|
501
|
+
hashtag_color = Settings.options.colors.hashtags
|
502
|
+
mention_color = Settings.options.colors.mentions
|
518
503
|
text.scan(/#{reg_sentence}/) do |sentence|
|
519
504
|
sentence.split(' ').each do |word|
|
520
505
|
|
@@ -537,7 +522,7 @@ module Ayadn
|
|
537
522
|
slices.each do |tag|
|
538
523
|
has_h = true if hashtags.include?(tag.downcase.scan(/[[:alpha:]0-9_]/).join(''))
|
539
524
|
end
|
540
|
-
if has_h
|
525
|
+
if has_h
|
541
526
|
if slices.length > 1
|
542
527
|
words << slices.join('#').gsub(/#{reg_tag}/, '#\1'.color(hashtag_color))
|
543
528
|
else
|
@@ -569,7 +554,7 @@ module Ayadn
|
|
569
554
|
sentences << words.join(' ')
|
570
555
|
words = Array.new
|
571
556
|
end
|
572
|
-
if Settings.options
|
557
|
+
if Settings.options.timeline.compact
|
573
558
|
without_linebreaks = sentences.keep_if { |s| s != "" }
|
574
559
|
without_linebreaks.join("\n")
|
575
560
|
else
|
@@ -579,14 +564,14 @@ module Ayadn
|
|
579
564
|
|
580
565
|
def links_from_posts(stream)
|
581
566
|
links = []
|
582
|
-
stream
|
567
|
+
stream.posts.each do |post|
|
583
568
|
extract_links(post).each {|l| links << l}
|
584
569
|
end
|
585
570
|
links.uniq
|
586
571
|
end
|
587
572
|
|
588
573
|
def all_but_me usernames
|
589
|
-
arr = usernames.select {|user| user != 'me'}
|
574
|
+
arr = usernames.select { |user| user != 'me' && user != Settings.config.identity.username }
|
590
575
|
at(arr)
|
591
576
|
end
|
592
577
|
|
@@ -596,6 +581,18 @@ module Ayadn
|
|
596
581
|
|
597
582
|
private
|
598
583
|
|
584
|
+
def build_reposted_or_starred_list list, title
|
585
|
+
table = init_table
|
586
|
+
table.title = title
|
587
|
+
users_list = []
|
588
|
+
list.each do |obj|
|
589
|
+
obj['name'].nil? ? name = "" : name = obj['name'].to_s.force_encoding("UTF-8")
|
590
|
+
users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you'], :id => obj['id'], :posts => obj['counts']['posts']}
|
591
|
+
end
|
592
|
+
table.style = table_borders()
|
593
|
+
return users_list, table
|
594
|
+
end
|
595
|
+
|
599
596
|
def def_str(word, reg_split)
|
600
597
|
splitted = word.split(/#{reg_split}/) if word =~ /#{reg_split}/
|
601
598
|
if splitted
|
@@ -609,7 +606,7 @@ module Ayadn
|
|
609
606
|
|
610
607
|
def init_table
|
611
608
|
Terminal::Table.new do |t|
|
612
|
-
t.style = { :width => Settings.options
|
609
|
+
t.style = { :width => Settings.options.formats.table.width }
|
613
610
|
end
|
614
611
|
end
|
615
612
|
|
@@ -623,38 +620,39 @@ module Ayadn
|
|
623
620
|
def extract_checkins(post)
|
624
621
|
has_checkins = false
|
625
622
|
checkins = {}
|
626
|
-
unless post
|
627
|
-
post
|
628
|
-
|
623
|
+
unless post.annotations.blank?
|
624
|
+
post.annotations.each do |anno|
|
625
|
+
anno_value = anno.value
|
626
|
+
case anno.type
|
629
627
|
when "net.app.core.checkin", "net.app.ohai.location"
|
630
628
|
has_checkins = true
|
631
629
|
checkins = {
|
632
|
-
name:
|
633
|
-
address:
|
634
|
-
address_extended:
|
635
|
-
locality:
|
636
|
-
postcode:
|
637
|
-
country_code:
|
638
|
-
website:
|
639
|
-
telephone:
|
630
|
+
name: anno_value['name'],
|
631
|
+
address: anno_value['address'],
|
632
|
+
address_extended: anno_value['address_extended'],
|
633
|
+
locality: anno_value['locality'],
|
634
|
+
postcode: anno_value['postcode'],
|
635
|
+
country_code: anno_value['country_code'],
|
636
|
+
website: anno_value['website'],
|
637
|
+
telephone: anno_value['telephone']
|
640
638
|
}
|
641
|
-
unless
|
642
|
-
unless
|
643
|
-
checkins[:categories] =
|
639
|
+
unless anno_value['categories'].nil?
|
640
|
+
unless anno_value['categories'][0].nil?
|
641
|
+
checkins[:categories] = anno_value['categories'][0]['labels'].join(", ")
|
644
642
|
end
|
645
643
|
end
|
646
|
-
unless
|
647
|
-
checkins[:factual_id] =
|
644
|
+
unless anno_value['factual_id'].nil?
|
645
|
+
checkins[:factual_id] = anno_value['factual_id']
|
648
646
|
end
|
649
|
-
unless
|
650
|
-
checkins[:longitude] =
|
651
|
-
checkins[:latitude] =
|
647
|
+
unless anno_value['longitude'].nil?
|
648
|
+
checkins[:longitude] = anno_value['longitude']
|
649
|
+
checkins[:latitude] = anno_value['latitude']
|
652
650
|
end
|
653
|
-
unless
|
654
|
-
checkins[:title] =
|
651
|
+
unless anno_value['title'].nil?
|
652
|
+
checkins[:title] = anno_value['title']
|
655
653
|
end
|
656
|
-
unless
|
657
|
-
checkins[:region] =
|
654
|
+
unless anno_value['region'].nil?
|
655
|
+
checkins[:region] = anno_value['region']
|
658
656
|
end
|
659
657
|
end
|
660
658
|
end
|