ayadn 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/ayadn/action.rb +5 -7
- data/lib/ayadn/api.rb +0 -93
- data/lib/ayadn/app.rb +1 -1
- data/lib/ayadn/cnx.rb +5 -6
- data/lib/ayadn/databases.rb +27 -0
- data/lib/ayadn/errors.rb +3 -3
- data/lib/ayadn/nicerank.rb +109 -0
- data/lib/ayadn/scroll.rb +23 -54
- data/lib/ayadn/set.rb +14 -3
- data/lib/ayadn/settings.rb +2 -1
- data/lib/ayadn/status.rb +8 -2
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +7 -5
- data/spec/mock/nicerank.db +0 -0
- data/spec/mock/nicerank.log +1 -0
- data/spec/unit/blacklistworkers_spec.rb +8 -8
- data/spec/unit/databases_spec.rb +7 -0
- data/spec/unit/workers_spec.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d182ebc33f66f34540b3b629d5ae372ca8aec63e
|
4
|
+
data.tar.gz: b80897e1c4bf6c5b534cd8c0d036dd3693c66786
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a72d7b598cca41d2c77300b6bbbf232bfce4c4bb5ade10815211ed1da4013418579b0531ed14a3b9e8c86fdba67323a8d8f3600456c53c303e2eafffece4f845
|
7
|
+
data.tar.gz: 5d5263954d304b55f093d2bb148590c0e76f36fe71fc1d2cedcb4399cb5876efcfe0d870cf4c06c0d83573daaa71d7e442fbf02c83e4f529a2e269922683836b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 1.2.6 - 'Saket'
|
2
|
+
|
3
|
+
- NiceRank enabled by default on new installs
|
4
|
+
- NiceRank cache expires after 48h by default
|
5
|
+
- NiceRank cache auto-limits to 5000 users
|
6
|
+
- Set the NiceRank cache value (in hours)
|
7
|
+
- More debug info
|
8
|
+
- Misc fixes related to recent features
|
9
|
+
|
1
10
|
# 1.2.5 - 'Bis repetita'
|
2
11
|
|
3
12
|
- Fix the NiceRank filter staying on true
|
data/lib/ayadn/action.rb
CHANGED
@@ -45,18 +45,16 @@ module Ayadn
|
|
45
45
|
def global(settings)
|
46
46
|
begin
|
47
47
|
options = settings.dup
|
48
|
-
|
48
|
+
if Settings.options[:nicerank]
|
49
|
+
options[:filter] = true if Settings.options[:nicerank][:filter] == true
|
50
|
+
end
|
49
51
|
doing(options)
|
50
52
|
stream = @api.get_global(options)
|
51
|
-
|
52
|
-
###DEBUG
|
53
|
-
#niceranks = @api.get_niceranks stream
|
54
|
-
niceranks, _ = @api.get_niceranks stream, 0
|
55
|
-
|
53
|
+
niceranks = NiceRank.new.get_ranks stream
|
56
54
|
(no_new_posts unless Databases.has_new?(stream, 'global')) if options[:new]
|
57
55
|
Databases.save_max_id(stream)
|
58
56
|
render_view(stream, options, niceranks)
|
59
|
-
Scroll.new(@api, @view).global(options
|
57
|
+
Scroll.new(@api, @view).global(options) if options[:scroll]
|
60
58
|
rescue => e
|
61
59
|
Errors.global_error("action/global", options, e)
|
62
60
|
ensure
|
data/lib/ayadn/api.rb
CHANGED
@@ -200,99 +200,6 @@ module Ayadn
|
|
200
200
|
end
|
201
201
|
end
|
202
202
|
|
203
|
-
###DEBUG
|
204
|
-
#def get_niceranks stream
|
205
|
-
def get_niceranks stream, iter
|
206
|
-
###DEBUG
|
207
|
-
@iter = iter
|
208
|
-
|
209
|
-
user_ids, table, niceranks = [], {}, {}
|
210
|
-
stream['data'].each do |post|
|
211
|
-
user_ids << post['user']['id'].to_i
|
212
|
-
table[post['user']['id'].to_i] = post['user']['username']
|
213
|
-
end
|
214
|
-
user_ids.uniq!
|
215
|
-
|
216
|
-
db_ranks = Databases.get_niceranks user_ids
|
217
|
-
get_these = []
|
218
|
-
db_ranks.each do |id,ranks|
|
219
|
-
if ranks.nil?
|
220
|
-
get_these << id
|
221
|
-
elsif (Time.now - ranks[:cached]) > 86400 # 24 hours cache
|
222
|
-
get_these << id
|
223
|
-
else
|
224
|
-
niceranks[id] = {
|
225
|
-
username: ranks[:username],
|
226
|
-
rank: ranks[:rank],
|
227
|
-
is_human: ranks[:is_human],
|
228
|
-
cached: ranks[:cached]
|
229
|
-
}
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
if Settings.options[:timeline][:show_debug] == true
|
234
|
-
puts "=====\nNiceRanks\n".color(Settings.options[:colors][:debug])
|
235
|
-
puts "From DB:\t#{niceranks}\n".color(Settings.options[:colors][:debug])
|
236
|
-
puts "To get:\t\t#{get_these}\n=====\n".color(Settings.options[:colors][:debug])
|
237
|
-
end
|
238
|
-
|
239
|
-
unless get_these.empty?
|
240
|
-
req = "http://api.search-adn.net/user/nicerank?ids=#{get_these.join(',')}"
|
241
|
-
resp = JSON.parse(CNX.get req)
|
242
|
-
|
243
|
-
#Error handling
|
244
|
-
if resp['meta']['code'] != 200
|
245
|
-
if Settings.options[:timeline][:show_debug] == true
|
246
|
-
puts "=====\nNiceRank:\tError #{resp['meta']['code']} (#{resp['meta']['time']})\n=====\n".color(Settings.options[:colors][:debug])
|
247
|
-
end
|
248
|
-
Errors.nr "REQUESTED: #{get_these.join(' ')}"
|
249
|
-
|
250
|
-
###DEBUG
|
251
|
-
@iter += 1
|
252
|
-
|
253
|
-
if niceranks
|
254
|
-
if Settings.options[:timeline][:show_debug] == true
|
255
|
-
puts "=====\nNiceRanks:\t#{niceranks}".color(Settings.options[:colors][:debug])
|
256
|
-
puts "=====\n".color(Settings.options[:colors][:debug])
|
257
|
-
end
|
258
|
-
|
259
|
-
#return niceranks
|
260
|
-
|
261
|
-
###DEBUG
|
262
|
-
return niceranks, @iter
|
263
|
-
else
|
264
|
-
|
265
|
-
# return {}
|
266
|
-
|
267
|
-
###DEBUG
|
268
|
-
return {}, @iter
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
###DEBUG
|
273
|
-
@iter += 1
|
274
|
-
|
275
|
-
resp['data'].each do |obj|
|
276
|
-
niceranks[obj['user_id']] = {
|
277
|
-
username: table[obj['user_id']],
|
278
|
-
rank: obj['rank'],
|
279
|
-
is_human: obj['is_human'],
|
280
|
-
cached: Time.now
|
281
|
-
}
|
282
|
-
end
|
283
|
-
if Settings.options[:timeline][:show_debug] == true
|
284
|
-
puts "=====\nNiceRanks:\t#{niceranks}".color(Settings.options[:colors][:debug])
|
285
|
-
puts "Resp:\t\t#{resp}".color(Settings.options[:colors][:debug])
|
286
|
-
puts "=====\n".color(Settings.options[:colors][:debug])
|
287
|
-
end
|
288
|
-
end
|
289
|
-
Databases.add_niceranks niceranks
|
290
|
-
|
291
|
-
###DEBUG
|
292
|
-
#niceranks
|
293
|
-
return niceranks, @iter
|
294
|
-
end
|
295
|
-
|
296
203
|
def get_channels
|
297
204
|
options = {:count => 200, :recent_message => 1, :annotations => 1, :before_id => nil}
|
298
205
|
get_parsed_response(Endpoints.new.channels(options))
|
data/lib/ayadn/app.rb
CHANGED
@@ -3,7 +3,7 @@ module Ayadn
|
|
3
3
|
class App < Thor
|
4
4
|
package_name "Ayadn"
|
5
5
|
|
6
|
-
%w{action api descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark}.each { |r| require_relative "#{r}" }
|
6
|
+
%w{action api descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark nicerank}.each { |r| require_relative "#{r}" }
|
7
7
|
|
8
8
|
desc "timeline", "Show your App.net timeline, aka the Unified Stream (-tl)"
|
9
9
|
map "unified" => :timeline
|
data/lib/ayadn/cnx.rb
CHANGED
@@ -33,12 +33,11 @@ module Ayadn
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.debug response, url
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
puts
|
41
|
-
puts ":::::\n".color(Settings.options[:colors][:debug])
|
36
|
+
deb = ":::::\n"
|
37
|
+
deb << "Url:\t\t#{url}\n\n"
|
38
|
+
deb << "Headers:\t#{response.headers}\n"
|
39
|
+
deb << ":::::\n"
|
40
|
+
puts deb.color(Settings.options[:colors][:debug])
|
42
41
|
end
|
43
42
|
|
44
43
|
def self.get_response_from(url)
|
data/lib/ayadn/databases.rb
CHANGED
@@ -18,6 +18,33 @@ module Ayadn
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.close_all
|
21
|
+
|
22
|
+
if @nicerank.size > 5000
|
23
|
+
limit = Time.now - 432000
|
24
|
+
@nicerank.each {|k,v| @nicerank.delete(k) if v[:cached] < limit}
|
25
|
+
if @nicerank.size > 5000
|
26
|
+
limit = Time.now - 86400
|
27
|
+
@nicerank.each {|k,v| @nicerank.delete(k) if v[:cached] < limit}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if Settings.options[:timeline][:show_debug] == true
|
32
|
+
puts "/////\nSETTINGS\n"
|
33
|
+
jj JSON.parse((Settings.config).to_json)
|
34
|
+
jj JSON.parse((Settings.options).to_json)
|
35
|
+
puts "/////\n\n"
|
36
|
+
|
37
|
+
puts ">>>>>\nDATABASES\n"
|
38
|
+
[@users, @index, @pagination, @aliases, @blacklist, @bookmarks, @nicerank].each do |db|
|
39
|
+
puts "Path:\t#{db.file}\nLength:\t#{db.size}\nSize:\t#{db.bytesize / 1024}KB"
|
40
|
+
end
|
41
|
+
puts ">>>>>\n\n"
|
42
|
+
|
43
|
+
puts "^^^^^\nTOKEN\n"
|
44
|
+
puts Settings.user_token
|
45
|
+
puts "^^^^^\n\n"
|
46
|
+
end
|
47
|
+
|
21
48
|
[@users, @index, @pagination, @aliases, @blacklist, @bookmarks, @nicerank].each do |db|
|
22
49
|
db.flush
|
23
50
|
db.compact
|
data/lib/ayadn/errors.rb
CHANGED
@@ -11,9 +11,9 @@ module Ayadn
|
|
11
11
|
Logs.rec.debug "STACK: #{caller}"
|
12
12
|
Logs.rec.error "--END--"
|
13
13
|
puts "\n(error logged in #{Settings.config[:paths][:log]}/ayadn.log)\n".color(:blue)
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
if Settings.options[:timeline][:show_debug] == true
|
15
|
+
raise error
|
16
|
+
end
|
17
17
|
exit
|
18
18
|
end
|
19
19
|
def self.error(status)
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
class NiceRank
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@url = 'http://api.search-adn.net/user/nicerank?ids='
|
7
|
+
@show_debug = Settings.options[:timeline][:show_debug]
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_ranks stream
|
11
|
+
user_ids, get_these, table, niceranks = [], [], {}, {}
|
12
|
+
|
13
|
+
stream['data'].each do |post|
|
14
|
+
user_ids << post['user']['id'].to_i
|
15
|
+
table[post['user']['id'].to_i] = post['user']['username']
|
16
|
+
end
|
17
|
+
user_ids.uniq!
|
18
|
+
|
19
|
+
db_ranks = Databases.get_niceranks user_ids
|
20
|
+
if Settings.options[:nicerank].nil?
|
21
|
+
expire = 172800 # 48h
|
22
|
+
else
|
23
|
+
if Settings.options[:nicerank][:cache].nil?
|
24
|
+
Settings.options[:nicerank][:cache] = 48
|
25
|
+
expire = 172800
|
26
|
+
else
|
27
|
+
expire = Settings.options[:nicerank][:cache] * 3600
|
28
|
+
end
|
29
|
+
end
|
30
|
+
db_ranks.each do |id, ranks|
|
31
|
+
if ranks.nil? || (Time.now - ranks[:cached]) > expire
|
32
|
+
get_these << id
|
33
|
+
else
|
34
|
+
niceranks[id] = {
|
35
|
+
username: ranks[:username],
|
36
|
+
rank: ranks[:rank],
|
37
|
+
is_human: ranks[:is_human],
|
38
|
+
cached: ranks[:cached]
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
how_many(niceranks, get_these) if @show_debug == true
|
44
|
+
|
45
|
+
unless get_these.empty?
|
46
|
+
resp = JSON.parse(CNX.get "#{@url}#{get_these.join(',')}")
|
47
|
+
|
48
|
+
if resp['meta']['code'] != 200
|
49
|
+
nr_error(resp) if @show_debug == true
|
50
|
+
Errors.nr "REQUESTED: #{get_these.join(' ')}"
|
51
|
+
Errors.nr "RESPONSE: #{resp}"
|
52
|
+
if niceranks
|
53
|
+
in_pool(niceranks) if @show_debug == true
|
54
|
+
return niceranks
|
55
|
+
else
|
56
|
+
return {}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
resp['data'].each do |obj|
|
61
|
+
niceranks[obj['user_id']] = {
|
62
|
+
username: table[obj['user_id']],
|
63
|
+
rank: obj['rank'],
|
64
|
+
is_human: obj['is_human'],
|
65
|
+
cached: Time.now
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
got(niceranks) if @show_debug == true
|
70
|
+
end
|
71
|
+
|
72
|
+
Databases.add_niceranks niceranks
|
73
|
+
|
74
|
+
niceranks
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def how_many niceranks, get_these
|
80
|
+
deb = "=====\n"
|
81
|
+
deb << "NR from DB:\t#{niceranks}\n\n"
|
82
|
+
deb << "NR to get:\t#{get_these}\n"
|
83
|
+
deb << "=====\n"
|
84
|
+
puts deb.color(Settings.options[:colors][:debug])
|
85
|
+
end
|
86
|
+
|
87
|
+
def in_pool niceranks
|
88
|
+
deb = "=====\n"
|
89
|
+
deb << "NR in pool:\t#{niceranks}\n"
|
90
|
+
deb << "=====\n"
|
91
|
+
puts deb.color(Settings.options[:colors][:debug])
|
92
|
+
end
|
93
|
+
|
94
|
+
def nr_error resp
|
95
|
+
deb = "=====\n"
|
96
|
+
deb << "NR Error:\t#{resp['meta']}"
|
97
|
+
deb << "=====\n"
|
98
|
+
puts deb.color(Settings.options[:colors][:debug])
|
99
|
+
end
|
100
|
+
|
101
|
+
def got niceranks
|
102
|
+
deb = "=====\n"
|
103
|
+
deb << "NiceRanks:\t#{niceranks}\n\n"
|
104
|
+
deb << "DB size:\t#{Databases.nicerank.size}\n"
|
105
|
+
deb << "=====\n"
|
106
|
+
puts deb.color(Settings.options[:colors][:debug])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/ayadn/scroll.rb
CHANGED
@@ -6,56 +6,37 @@ module Ayadn
|
|
6
6
|
@api = api
|
7
7
|
@view = view
|
8
8
|
@chars = %w{ | / - \\ }
|
9
|
+
@show_debug = Settings.options[:timeline][:show_debug]
|
9
10
|
end
|
10
11
|
|
11
|
-
def method_missing(meth, options
|
12
|
+
def method_missing(meth, options)
|
12
13
|
case meth.to_s
|
13
14
|
when 'trending', 'photos', 'checkins', 'replies', 'global', 'unified'
|
14
|
-
scroll_it(meth.to_s, options
|
15
|
+
scroll_it(meth.to_s, options)
|
15
16
|
else
|
16
17
|
super
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
def scroll_it(target, options
|
21
|
+
def scroll_it(target, options)
|
21
22
|
options = check_raw(options)
|
22
23
|
orig_target = target
|
23
|
-
|
24
|
-
###DEBUG
|
25
|
-
@iter = 0
|
26
|
-
@adn = 1
|
27
|
-
|
24
|
+
@nr = NiceRank.new
|
28
25
|
loop do
|
29
26
|
begin
|
30
27
|
stream = get(target, options)
|
31
28
|
|
32
|
-
|
33
|
-
@adn += 1
|
34
|
-
|
35
|
-
if options[:filter] == true
|
29
|
+
# if options[:filter] == true
|
36
30
|
unless stream['data'].empty?
|
37
|
-
|
38
|
-
#niceranks = @api.get_niceranks stream
|
39
|
-
niceranks, @iter = @api.get_niceranks stream, @iter
|
40
|
-
###DEBUG
|
41
|
-
if Settings.options[:timeline][:show_debug] == true
|
42
|
-
puts "@@@@@\nADN calls:\t#{@adn}\n".color(Settings.options[:colors][:debug])
|
43
|
-
puts "NiceRank calls:\t#{@iter}".color(Settings.options[:colors][:debug])
|
44
|
-
puts "@@@@@\n".color(Settings.options[:colors][:debug])
|
45
|
-
end
|
31
|
+
niceranks = @nr.get_ranks stream
|
46
32
|
else
|
47
33
|
niceranks = {}
|
48
34
|
end
|
49
|
-
else
|
50
|
-
|
51
|
-
end
|
35
|
+
# else
|
36
|
+
# niceranks = {}
|
37
|
+
# end
|
52
38
|
|
53
|
-
if
|
54
|
-
puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug])
|
55
|
-
puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug])
|
56
|
-
puts "Target:\t\t#{target.inspect}\n".color(Settings.options[:colors][:debug])
|
57
|
-
puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug])
|
58
|
-
end
|
39
|
+
debug_stream(stream, options, target) if @show_debug == true
|
59
40
|
|
60
41
|
target = "explore:#{target}" if explore?(target)
|
61
42
|
show_if_new(stream, options, target, niceranks)
|
@@ -76,12 +57,7 @@ module Ayadn
|
|
76
57
|
begin
|
77
58
|
stream = @api.get_mentions(username, options)
|
78
59
|
|
79
|
-
if
|
80
|
-
puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug])
|
81
|
-
puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug])
|
82
|
-
puts "Target:\t\t#{username}\n".color(Settings.options[:colors][:debug])
|
83
|
-
puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug])
|
84
|
-
end
|
60
|
+
debug_stream(stream, options, username) if @show_debug == true
|
85
61
|
|
86
62
|
show_if_new(stream, options, "mentions:#{id}")
|
87
63
|
options = save_then_return(stream, options)
|
@@ -100,12 +76,7 @@ module Ayadn
|
|
100
76
|
begin
|
101
77
|
stream = @api.get_posts(username, options)
|
102
78
|
|
103
|
-
if
|
104
|
-
puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug])
|
105
|
-
puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug])
|
106
|
-
puts "Target:\t\t#{username}\n".color(Settings.options[:colors][:debug])
|
107
|
-
puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug])
|
108
|
-
end
|
79
|
+
debug_stream(stream, options, username) if @show_debug == true
|
109
80
|
|
110
81
|
show_if_new(stream, options, "posts:#{id}")
|
111
82
|
options = save_then_return(stream, options)
|
@@ -122,12 +93,7 @@ module Ayadn
|
|
122
93
|
begin
|
123
94
|
stream = @api.get_convo(post_id, options)
|
124
95
|
|
125
|
-
if
|
126
|
-
puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug])
|
127
|
-
puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug])
|
128
|
-
puts "Target:\t\t#{post_id}\n".color(Settings.options[:colors][:debug])
|
129
|
-
puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug])
|
130
|
-
end
|
96
|
+
debug_stream(stream, options, post_id) if @show_debug == true
|
131
97
|
|
132
98
|
show_if_new(stream, options, "replies:#{post_id}")
|
133
99
|
options = save_then_return(stream, options)
|
@@ -144,12 +110,7 @@ module Ayadn
|
|
144
110
|
begin
|
145
111
|
stream = @api.get_messages(channel_id, options)
|
146
112
|
|
147
|
-
if
|
148
|
-
puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug])
|
149
|
-
puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug])
|
150
|
-
puts "Target:\t\t#{channel_id}\n".color(Settings.options[:colors][:debug])
|
151
|
-
puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug])
|
152
|
-
end
|
113
|
+
debug_stream(stream, options, channel_id) if @show_debug == true
|
153
114
|
|
154
115
|
show_if_new(stream, options, "channel:#{channel_id}")
|
155
116
|
options = save_then_return(stream, options)
|
@@ -162,6 +123,14 @@ module Ayadn
|
|
162
123
|
|
163
124
|
private
|
164
125
|
|
126
|
+
def debug_stream stream, options, target
|
127
|
+
deb = "+++++\nStream meta:\t#{stream['meta']}\n\n"
|
128
|
+
deb << "Options:\t#{options.inspect}\n\n"
|
129
|
+
deb << "Target:\t\t#{target.inspect}\n\n"
|
130
|
+
deb << "Posts:\t\t#{stream['data'].length}\n+++++\n"
|
131
|
+
puts deb.color(Settings.options[:colors][:debug])
|
132
|
+
end
|
133
|
+
|
165
134
|
def countdown
|
166
135
|
if Settings.options[:timeline][:show_spinner] == true
|
167
136
|
waiting
|
data/lib/ayadn/set.rb
CHANGED
@@ -163,7 +163,8 @@ module Ayadn
|
|
163
163
|
unless Settings.options[:nicerank]
|
164
164
|
Settings.options[:nicerank] = {
|
165
165
|
threshold: 2,
|
166
|
-
|
166
|
+
cache: 48,
|
167
|
+
filter: true,
|
167
168
|
filter_unranked: false
|
168
169
|
}
|
169
170
|
end
|
@@ -188,6 +189,9 @@ module Ayadn
|
|
188
189
|
def threshold value
|
189
190
|
Settings.options[:nicerank][:threshold] = value.to_f
|
190
191
|
end
|
192
|
+
def cache value
|
193
|
+
Settings.options[:nicerank][:cache] = Validators.cache_range value.to_i
|
194
|
+
end
|
191
195
|
end
|
192
196
|
|
193
197
|
class SetBackup
|
@@ -238,6 +242,13 @@ module Ayadn
|
|
238
242
|
abort(Status.must_be_integer)
|
239
243
|
end
|
240
244
|
end
|
245
|
+
def self.cache_range value
|
246
|
+
if value >= 3 && value <= 720
|
247
|
+
value.round
|
248
|
+
else
|
249
|
+
abort(Status.cache_range)
|
250
|
+
end
|
251
|
+
end
|
241
252
|
def self.timer(t)
|
242
253
|
t = t.to_i
|
243
254
|
t >= 1 ? t : 3
|
@@ -366,8 +377,8 @@ module Ayadn
|
|
366
377
|
def show_nicerank value
|
367
378
|
unless Settings.options[:nicerank]
|
368
379
|
Settings.options[:nicerank] = {
|
369
|
-
threshold: 2
|
370
|
-
filter:
|
380
|
+
threshold: 2,
|
381
|
+
filter: true,
|
371
382
|
filter_unranked: false
|
372
383
|
}
|
373
384
|
end
|
data/lib/ayadn/settings.rb
CHANGED
data/lib/ayadn/status.rb
CHANGED
@@ -8,10 +8,10 @@ module Ayadn
|
|
8
8
|
"\nFile downloaded in #{Settings.config[:paths][:downloads]}/#{name}\n".color(:green)
|
9
9
|
end
|
10
10
|
def self.downloading
|
11
|
-
"Downloading from ADN
|
11
|
+
"Downloading from ADN...\n\n".inverse
|
12
12
|
end
|
13
13
|
def self.posting
|
14
|
-
"Posting to ADN
|
14
|
+
"Posting to ADN...\n\n".inverse
|
15
15
|
end
|
16
16
|
def self.deleting_post(post_id)
|
17
17
|
"\nDeleting post #{post_id}".inverse
|
@@ -241,5 +241,11 @@ module Ayadn
|
|
241
241
|
view << "At any moment, starting now, hit CTRL+C to exit.\n\n".color(:yellow)
|
242
242
|
view << "\n\t--AUTO POSTING MODE ACTIVATED--\n\n".color(:red)
|
243
243
|
end
|
244
|
+
def self.reducing db
|
245
|
+
"\nPlease wait while Ayadn is pruning and compacting the #{db} database...\n".color(:cyan)
|
246
|
+
end
|
247
|
+
def self.cache_range
|
248
|
+
"\nPlease enter a number of hours between 3 and 168.\n\n".color(:red)
|
249
|
+
end
|
244
250
|
end
|
245
251
|
end
|
data/lib/ayadn/version.rb
CHANGED
data/lib/ayadn/view.rb
CHANGED
@@ -305,7 +305,7 @@ module Ayadn
|
|
305
305
|
@view = ""
|
306
306
|
posts = @workers.build_posts(data.reverse, niceranks)
|
307
307
|
|
308
|
-
posts = filter_nicerank
|
308
|
+
posts = filter_nicerank(posts, options)
|
309
309
|
|
310
310
|
posts.each do |id,content|
|
311
311
|
count = "%03d" % content[:count]
|
@@ -326,7 +326,7 @@ module Ayadn
|
|
326
326
|
@view = ""
|
327
327
|
posts = @workers.build_posts(data.reverse, niceranks)
|
328
328
|
|
329
|
-
posts = filter_nicerank
|
329
|
+
posts = filter_nicerank(posts, options)
|
330
330
|
|
331
331
|
posts.each do |id,content|
|
332
332
|
if content[:username] == Settings.config[:identity][:username]
|
@@ -460,9 +460,11 @@ module Ayadn
|
|
460
460
|
header << content[:name].color(Settings.options[:colors][:name])
|
461
461
|
end
|
462
462
|
|
463
|
-
if Settings.options[:timeline][:show_nicerank] && content[:nicerank]
|
464
|
-
|
465
|
-
|
463
|
+
if Settings.options[:timeline][:show_nicerank] && content[:nicerank]
|
464
|
+
if Settings.options[:nicerank][:filter] == true
|
465
|
+
header << " "
|
466
|
+
header << "[#{content[:nicerank]}]".color(Settings.options[:colors][:nicerank])
|
467
|
+
end
|
466
468
|
end
|
467
469
|
|
468
470
|
if Settings.options[:timeline][:show_date]
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
# Logfile created on 2014-05-26 18:41:42 +0200 by logger.rb/44203
|
@@ -54,37 +54,37 @@ describe Ayadn::BlacklistWorkers do
|
|
54
54
|
k = Ayadn::BlacklistWorkers.new
|
55
55
|
k.add(['client', 'IFTTT'])
|
56
56
|
expect(Ayadn::Databases.blacklist['ifttt']).to eq :client
|
57
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added 'IFTTT' to blacklist of clients."
|
57
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"IFTTT\"]' to blacklist of clients."
|
58
58
|
end
|
59
59
|
it "adds a client to the blacklist" do
|
60
60
|
k = Ayadn::BlacklistWorkers.new
|
61
61
|
k.add(['source', 'Zapier'])
|
62
62
|
expect(Ayadn::Databases.blacklist['zapier']).to eq :client
|
63
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added 'Zapier' to blacklist of clients."
|
63
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"Zapier\"]' to blacklist of clients."
|
64
64
|
end
|
65
65
|
it "adds a hashtag to the blacklist" do
|
66
66
|
k = Ayadn::BlacklistWorkers.new
|
67
67
|
k.add(['hashtag', 'Sports'])
|
68
68
|
expect(Ayadn::Databases.blacklist['sports']).to eq :hashtag
|
69
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added 'Sports' to blacklist of hashtags."
|
69
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"Sports\"]' to blacklist of hashtags."
|
70
70
|
end
|
71
71
|
it "adds a hashtag to the blacklist" do
|
72
72
|
k = Ayadn::BlacklistWorkers.new
|
73
73
|
k.add(['tag', 'tv'])
|
74
74
|
expect(Ayadn::Databases.blacklist['tv']).to eq :hashtag
|
75
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added 'tv' to blacklist of hashtags."
|
75
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"tv\"]' to blacklist of hashtags."
|
76
76
|
end
|
77
77
|
it "adds a mention to the blacklist" do
|
78
78
|
k = Ayadn::BlacklistWorkers.new
|
79
79
|
k.add(['mention', 'mrTest'])
|
80
80
|
expect(Ayadn::Databases.blacklist['@mrtest']).to eq :mention
|
81
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '@mrTest' to blacklist of mentions."
|
81
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"@mrTest\"]' to blacklist of mentions."
|
82
82
|
end
|
83
83
|
it "adds a mention to the blacklist" do
|
84
84
|
k = Ayadn::BlacklistWorkers.new
|
85
85
|
k.add(['mentions', 'yolo'])
|
86
86
|
expect(Ayadn::Databases.blacklist['@yolo']).to eq :mention
|
87
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '@yolo' to blacklist of mentions."
|
87
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"@yolo\"]' to blacklist of mentions."
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -93,11 +93,11 @@ describe Ayadn::BlacklistWorkers do
|
|
93
93
|
k = Ayadn::BlacklistWorkers.new
|
94
94
|
k.add(['client', 'IFTTT'])
|
95
95
|
expect(Ayadn::Databases.blacklist['ifttt']).to eq :client
|
96
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added 'IFTTT' to blacklist of clients."
|
96
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Added '[\"IFTTT\"]' to blacklist of clients."
|
97
97
|
k = Ayadn::BlacklistWorkers.new
|
98
98
|
k.remove(['client', 'IFTTT'])
|
99
99
|
expect(Ayadn::Databases.blacklist['ifttt']).to eq nil
|
100
|
-
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Removed 'client:IFTTT' from blacklist."
|
100
|
+
expect(File.read('spec/mock/ayadn.log')).to include "(wee) INFO -- Removed 'client:[\"IFTTT\"]' from blacklist."
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
data/spec/unit/databases_spec.rb
CHANGED
data/spec/unit/workers_spec.rb
CHANGED
@@ -41,7 +41,7 @@ describe Ayadn::Workers do
|
|
41
41
|
expect(posts[23187443][:has_checkins]).to be false
|
42
42
|
expect(posts[23187443][:mentions]).to eq []
|
43
43
|
expect(posts[23187443][:checkins]).to be_empty
|
44
|
-
expect(posts[23187443].length).to eq
|
44
|
+
expect(posts[23187443].length).to eq 32
|
45
45
|
end
|
46
46
|
it "gets oembed link from checkins post" do
|
47
47
|
posts = Ayadn::Workers.new.build_posts(checkins['data'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ayadn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Dejonckheere
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- lib/ayadn/fileops.rb
|
217
217
|
- lib/ayadn/logs.rb
|
218
218
|
- lib/ayadn/mark.rb
|
219
|
+
- lib/ayadn/nicerank.rb
|
219
220
|
- lib/ayadn/pinboard.rb
|
220
221
|
- lib/ayadn/post.rb
|
221
222
|
- lib/ayadn/scroll.rb
|
@@ -235,6 +236,8 @@ files:
|
|
235
236
|
- spec/mock/checkins.json
|
236
237
|
- spec/mock/fwr_@ayadn.json
|
237
238
|
- spec/mock/index.db
|
239
|
+
- spec/mock/nicerank.db
|
240
|
+
- spec/mock/nicerank.log
|
238
241
|
- spec/mock/pagination.db
|
239
242
|
- spec/mock/posted.json
|
240
243
|
- spec/mock/regex.json
|
@@ -286,6 +289,8 @@ test_files:
|
|
286
289
|
- spec/mock/checkins.json
|
287
290
|
- spec/mock/fwr_@ayadn.json
|
288
291
|
- spec/mock/index.db
|
292
|
+
- spec/mock/nicerank.db
|
293
|
+
- spec/mock/nicerank.log
|
289
294
|
- spec/mock/pagination.db
|
290
295
|
- spec/mock/posted.json
|
291
296
|
- spec/mock/regex.json
|