ayadn 2.0.12 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 838837a525197748fc18b25d93d90228061aa2e3
4
- data.tar.gz: f62380908cbfdca3083ee7b04c581e8aa6e65198
3
+ metadata.gz: 9f91b217c6c170cfcc4cb0bfb47be2b881463054
4
+ data.tar.gz: cdc82c5ddcda7512c6195be5abc219e28935c17b
5
5
  SHA512:
6
- metadata.gz: d35b5e8556aae6c3b0e45d1b0df5661caf6e8fdc70cd38e72809a51b99b15c812b388353469e1fb5438355583581a81a23289fc67ee1b367b8c8388619cc3858
7
- data.tar.gz: 7c9e60bbc4adfe40dc63c57f5876a47229ad2f7c86d140a1d9f045b8f0d180b7f377355e68999e7955e4bd94e33b176ac03ca89a8a645a9bc381a111dd292092
6
+ metadata.gz: 1e59fafb75249a6a9bc64be41c434ef0a4311ab7f0181011c5c4283dcb2abcb27d36bab6d985bb00a7d0d219d1172287186f0e4c5d317eea577c029d58591352
7
+ data.tar.gz: d6919bab279e3b739ac73a6c2259859eb9bc774b8fa4329debaf04eb209119645864c27fb51ff23bae0ca6976b64e7643a802b07de9a99639bbf3a33ef555ff6
@@ -1,3 +1,10 @@
1
+ ## 2.1 - 2015-08-29 - 'Electric Boogaloo'
2
+
3
+ - Fix: crash when scrolling Global with NiceRank
4
+ - Fix: crash when using list sort option posts/day
5
+ - Fix: rare crash if user has no name
6
+ - Deprecated: sort lists using posts/day
7
+
1
8
  ## 2.0.12 - 2015-05-10 - 'Agent Carter'
2
9
 
3
10
  - Fix: Youtube/Vimeo integration if video not found or unauthorized
data/README.md CHANGED
@@ -84,7 +84,7 @@ Feedback and/or contributions are very welcomed!
84
84
 
85
85
  Examples on Mac OS X, with iTerm2 + Solarized theme.
86
86
 
87
- ![followers list](https://www.dropbox.com/s/es0o4sq7w05y2ps/ayadn200followerslistsmall.png?dl=1)
87
+ ![followers list](https://www.evernote.com/shard/s89/sh/fddc2f8e-78f0-4dde-974b-bf724f643d7f/419854929e27b5b3/res/522b6cd4-2e0f-4528-bc94-ea4a61de54a7/skitch.png)
88
88
 
89
89
  ![mentions stream in classic view](http://dl.dropboxusercontent.com/s/16d7u5wjsd3un1j/ayadn200mentions.png)
90
90
 
@@ -20,30 +20,30 @@ Install Ayadn, authorize your account: done.
20
20
 
21
21
  If you need to install Ruby it's better to use something like RVM or RBENV. You can of course use the Ruby shipped with your system but it will require root privileges and is not recommended.
22
22
 
23
- ## MIGRATE
23
+ ## WINDOWS
24
24
 
25
- The database format has changed between 1.x and 2.x: if you already have one or several authorized accounts, Ayadn will ask you to run the `migrate` command once per account. You only have to do this once.
25
+ Ayadn also works on Windows because it's pure Ruby, but some Gems it depends upon require some effort to be installed with some Windows versions ("amalgalite", notably). And you will need an ANSI compatible console (ConEmu, Console2, etc) and Ruby 2.0.0+ 32bits via RubyInstaller and its DevKit (or a cygwin equivalent).
26
26
 
27
- You can also start with a fresh configuration: just delete your `~/ayadn` folder before authorizing a new user with Ayadn 2.x.
27
+ ## MIGRATE
28
28
 
29
- ## WINDOWS
29
+ If you have an old Ayadn 1.x install that you want to keep using with Ayadn 2.x, Ayadn 2.x will ask you to run the `migrate` command (once) for this account.
30
30
 
31
- Ayadn also works on Windows because it's pure Ruby, but some Gems it depends upon require some effort to be installed with some Windows versions ("amalgalite", notably). And you will need an ANSI compatible console (ConEmu, Console2, etc) + Ruby 2.0.0 32bits via RubyInstaller and its DevKit (or a cygwin equivalent).
31
+ Otherwise it's better to start with a fresh configuration: just delete your old 1.0 `~/ayadn` folder before authorizing the user again with Ayadn 2.x.
32
32
 
33
33
  ## DEPENDENCIES
34
34
 
35
35
  Ayadn depends upon these Gems:
36
36
 
37
- amalgalite
38
- fast_cache
39
- pinboard
40
- rainbow
41
- rest-client
42
- spotlite
43
- terminal-table
44
- thor
45
- tvdb_party
46
- unicode_utils
47
- daybreak
48
-
49
- The "daybreak" dependency is only needed for 1.x to 2.x migrations. As this migration is optional and Ayadn 1.x is deprecated, this dependency will be removed in future versions.
37
+ amalgalite (SQLite)
38
+ fast_cache (in-memory caching)
39
+ pinboard (export to Pinboard)
40
+ rainbow (text UI utilities)
41
+ rest-client (networking)
42
+ spotlite (IMDb access)
43
+ terminal-table (text UI utilities)
44
+ thor (commands and options parsing)
45
+ tvdb_party (TVDb access)
46
+ unicode_utils (text utilities)
47
+ daybreak (Ruby data store)
48
+
49
+ *Note: the "daybreak" dependency is only needed for 1.x to 2.x migrations. As this migration is optional and Ayadn 1.x is deprecated, this dependency will be removed in future versions.*
@@ -24,7 +24,7 @@ You can then switch between accounts:
24
24
 
25
25
  `ayadn switch @ericd`
26
26
 
27
- or
27
+ Shortcut:
28
28
 
29
29
  `ayadn -@ ericd`
30
30
 
@@ -32,7 +32,7 @@ You can also unauthorize a user with or without deleting its folders:
32
32
 
33
33
  `ayadn unauthorize @ericd`
34
34
 
35
- or
35
+ Shortcut:
36
36
 
37
37
  `ayadn -UA -D @ericd`
38
38
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Note: options are only described once in this manual (in the first example for 'Streams', 'Timeline').
4
4
 
5
- **However, options are available for mosts of streams!**
5
+ However, **these options are available for most streams!**
6
6
 
7
7
  They're described only once to ensure this documentation keeps being readable.
8
8
 
@@ -144,7 +144,7 @@ Set it permanently with:
144
144
 
145
145
  `ayadn set timeline compact true`
146
146
 
147
- You may want to change colors to create visual marks between posts if you choose the compact view, i.e. putting the all header in the same color (post id, username, name, etc).
147
+ *Tip: you may want to change colors to create visual marks between posts if you choose the compact view by default, i.e. setting the whole header to the same color (post id, username, name, etc).*
148
148
 
149
149
  # GLOBAL
150
150
 
@@ -215,7 +215,7 @@ You can get your own mentions stream by using *me* instead of *@username*:
215
215
 
216
216
  `ayadn -m me`
217
217
 
218
- Don't forget that like most streams, Mentions is *scrollable*: very convenient to know at a glance if we got something new from our friends!
218
+ Like most streams, Mentions is *scrollable*: very convenient to know at a glance if we got something new from our friends!
219
219
 
220
220
  # POSTS
221
221
 
@@ -10,11 +10,11 @@ Simple and fast way to post a short sentence/word to App.net.
10
10
 
11
11
  You have to put your text between single quotes if you're using punctuation:
12
12
 
13
- `ayadn -P 'Hello from Ayadn, guys!'`
13
+ `ayadn -P 'Hello from Ayadn!'`
14
14
 
15
15
  *But remember you can't use any quote character inside the quotes...*
16
16
 
17
- **So you should rather use the _write_ method for posting.**
17
+ **So you should rather use the _WRITE_ method for posting.**
18
18
 
19
19
  # WRITE
20
20
 
@@ -28,25 +28,25 @@ Multi-line post to App.net.
28
28
 
29
29
  It will show you a prompt where you can type anything, including special characters and Markdown links.
30
30
 
31
- Hit ENTER to create line breaks.
31
+ Hit `ENTER` to create line breaks.
32
32
 
33
- Hit ENTER, SPACE, ENTER to create paragraphs compatible with all clients.
34
-
35
- Cancel your post with CTRC-C or send it with CTRL-D.
33
+ Send your post with `CTRL-D`, or cancel with `CTRC-C`.
36
34
 
37
35
  Just type a @username at the beginning of your post if you want to mention a specific user, as you would in any other App.net client.
38
36
 
37
+ *Tip: hit `ENTER`, `SPACE`, `ENTER` to create paragraphs compatible with all App.net clients.*
38
+
39
39
  # AUTO POST
40
40
 
41
41
  Auto post every line of input.
42
42
 
43
43
  `ayadn auto`
44
44
 
45
- In this mode, each line you type (each time you hit ENTER!) is automatically posted to ADN.
45
+ In this mode, each line you type (each time you hit `ENTER`!) is automatically posted to ADN.
46
46
 
47
47
  You can type anything, including special characters and Markdown links, and of course mention anyone: the only thing you can't do from this mode is _replying_ to a post in a thread.
48
48
 
49
- Hit CTRL+C to exit this mode at any moment.
49
+ Hit `CTRL+C` to exit this mode at any moment.
50
50
 
51
51
  # REPLY
52
52
 
@@ -60,7 +60,7 @@ Reply to a specific post.
60
60
 
61
61
  `ayadn -R 23362460`
62
62
 
63
- Ayadn will then show you the *write* prompt.
63
+ Ayadn will then show you the *WRITE* prompt.
64
64
 
65
65
  If you reply to a post containing multiple mentions, your text will be inserted between the leading mention and the other ones.
66
66
 
@@ -91,7 +91,7 @@ Send a private message to a specific user.
91
91
 
92
92
  `ayadn pm @ericd`
93
93
 
94
- Ayadn will then show you the *write* prompt.
94
+ Ayadn will then show you the *WRITE* prompt.
95
95
 
96
96
  By default, Ayadn will mark this private messages channel as read once the message has been sent.
97
97
 
@@ -111,7 +111,7 @@ Send a message to an App.net CHANNEL.
111
111
 
112
112
  `ayadn -C 46217`
113
113
 
114
- Ayadn will then show you the *write* prompt.
114
+ Ayadn will then show you the *WRITE* prompt.
115
115
 
116
116
  By default, Ayadn will mark this channel as read once the message has been sent.
117
117
 
@@ -163,7 +163,7 @@ ayadn -R 23362460 -Y https://www.youtube.com/watch?v=Ei8CFin00PY
163
163
  ayadn pm @ericd -Y https://www.youtube.com/watch?v=Ei8CFin00PY
164
164
  ```
165
165
 
166
- Unfortunately, very few App.net clients treat video embedding properly. So I would advise to include the video URL in the text body anyway, for better compatibility.
166
+ *Note: unfortunately, very few App.net clients treat video embedding properly. So I would advise to include the video URL in the text body anyway, for better compatibility.*
167
167
 
168
168
  # EMBED MOVIE POSTER
169
169
 
@@ -172,7 +172,7 @@ Download a file from your App.net storage (any file posted with any ADN client).
172
172
 
173
173
  Export a post's url, text and link(s) to your Pinboard account and add optional tags.
174
174
 
175
- `ayadn pin 22790201 Ayadn Ruby dev`
175
+ `ayadn pin 22790201`
176
176
 
177
177
  `ayadn pin 26874913 duel swords france history`
178
178
 
@@ -18,10 +18,6 @@ Sort the list by name:
18
18
 
19
19
  `ayadn -fwr -n me`
20
20
 
21
- Sort the list by posts/day:
22
-
23
- `ayadn -fwr -d me`
24
-
25
21
  Sort the list by total posts:
26
22
 
27
23
  `ayadn -fwr -p me`
@@ -64,10 +60,6 @@ Sort the list by name:
64
60
 
65
61
  `ayadn -fwg -n me`
66
62
 
67
- Sort the list by posts/day:
68
-
69
- `ayadn -fwg -d me`
70
-
71
63
  Sort the list by total posts:
72
64
 
73
65
  `ayadn -fwg -p me`
@@ -182,10 +174,6 @@ Sort the list by name:
182
174
 
183
175
  `ayadn -mtd -n`
184
176
 
185
- Sort the list by posts/day:
186
-
187
- `ayadn -mtd -d`
188
-
189
177
  Sort the list by total posts:
190
178
 
191
179
  `ayadn -mtd -p`
@@ -220,10 +208,6 @@ Sort the list by name:
220
208
 
221
209
  `ayadn -bkd -n`
222
210
 
223
- Sort the list by posts/day:
224
-
225
- `ayadn -bkd -d`
226
-
227
211
  Sort the list by total posts:
228
212
 
229
213
  `ayadn -bkd -p`
@@ -278,7 +262,7 @@ You can permanently reverse the ADN default list order with a `set` command:
278
262
 
279
263
  You can change the width of the lists table if the default size doesn't fit well in your terminal:
280
264
 
281
- `ayadn set formats table width 80`
265
+ `ayadn set formats table width 70`
282
266
 
283
267
  (min: 60, max: 90, default: 75)
284
268
 
@@ -14,7 +14,7 @@ After your successful login, you will be redirected to the Ayadn authorization p
14
14
 
15
15
  Copy the code (token) you will find there and paste it into Ayadn: a new user will be created and automatically logged in.
16
16
 
17
- *Note: authorizing an already authorized user updates the old content with the new content: token, name, etc.*
17
+ *Note that authorizing an already authorized user updates the meta informations: token, name, etc.*
18
18
 
19
19
  # SWITCH
20
20
 
@@ -24,7 +24,7 @@ Switch between your authorized accounts.
24
24
 
25
25
  `ayadn switch ericd`
26
26
 
27
- Alternative syntax:
27
+ Shortcut:
28
28
 
29
29
  `ayadn -@ ericd`
30
30
 
@@ -40,8 +40,10 @@ Unauthorize an Ayadn user account.
40
40
 
41
41
  `ayadn unauthorize @ericd`
42
42
 
43
+ Shortcut:
44
+
43
45
  `ayadn -UA ericd`
44
46
 
45
- You can specify the `--delete` (`-D`) option to force delete the account folders:
47
+ You can specify the `--delete` (`-D`) option to force delete the account folders (recommended):
46
48
 
47
49
  `ayadn -UA -D @ericd`
@@ -46,7 +46,7 @@ Any user with a NiceRank smaller than this value will be ignored in the Global s
46
46
 
47
47
  (default: 2.1)
48
48
 
49
- ## Desactivate NiceRank
49
+ ## Deactivate NiceRank
50
50
 
51
51
  NiceRank is enabled by default on new Ayadn installations, but can be disabled if needed:
52
52
 
@@ -6,13 +6,13 @@ Usage:
6
6
 
7
7
  `ayadn mark add 30594331`
8
8
 
9
- `ayadn mark add 30594331 convo title`
9
+ `ayadn mark add 30594331 interesting convo`
10
10
 
11
11
  `ayadn mark list`
12
12
 
13
13
  `ayadn mark delete 30594331`
14
14
 
15
- `ayadn mark rename 30594331 'other name'`
15
+ `ayadn mark rename 30594331 'interesting convo about stuff'`
16
16
 
17
17
  ## ADD
18
18
 
@@ -12,7 +12,9 @@ OS X only.
12
12
 
13
13
  Ayadn will grab information from your running iTunes, format it, insert the *#nowplaying* hashtag then ask for your confirmation before posting it.
14
14
 
15
- It will also grab a link to the album and the album artwork from the iTunes Store (you can prevent this behavior by adding the `--no_url` option (short: `-n`).
15
+ It will also grab a link to the album and the album artwork from the iTunes Store (you can prevent this behavior by adding the `--no_url` option (short: `-n`)).
16
+
17
+ *Note: __nowplaying__ doesn't work with the curated Apple Music playlists such as 'For You', 'New' and 'Radio'.*
16
18
 
17
19
  ## Last.fm
18
20
 
@@ -20,11 +22,11 @@ It will also grab a link to the album and the album artwork from the iTunes Stor
20
22
 
21
23
  `ayadn -NP -l`
22
24
 
23
- Ayadn will grab information from your Last.fm account, format it, insert the *#nowplaying* hashtag then ask for your confirmation before posting it.
25
+ Ayadn will grab information from your Last.fm account (you will be prompted for your Last.fm username), format the information, insert the *#nowplaying* hashtag then ask for your confirmation before posting it.
24
26
 
25
27
  It will also grab a link to the album and the album artwork from the iTunes Store (you can prevent this behavior by adding the `--no_url` option (short: `-n`).
26
28
 
27
- *Note: the Last.fm feed may take some time to be updated. If it doesn't reflect your recent history, please wait a few minutes.*
29
+ *Note: Last.fm does not always update their feed immediately. If __nowplaying__ doesn't reflect your recent history, please wait for a few minutes.*
28
30
 
29
31
  ## Deezer
30
32
 
@@ -32,11 +34,11 @@ It will also grab a link to the album and the album artwork from the iTunes Stor
32
34
 
33
35
  `ayadn -NP -d`
34
36
 
35
- Ayadn will grab information from your Deezer account (you will be prompted to authorize Ayadn for Deezer the first time you launch this command), format it, insert the *#nowplaying* hashtag then ask for your confirmation before posting it.
37
+ Ayadn will grab information from your Deezer account (you will be prompted to authorize Ayadn for Deezer the first time you launch this command), format the information, insert the *#nowplaying* hashtag then ask for your confirmation before posting it.
36
38
 
37
39
  It will also grab a link to the album and the album artwork from the iTunes Store (you can prevent this behavior by adding the `--no_url` option (short: `-n`).
38
40
 
39
- *Note: Deezer will update the recent history list only after a song has been played to its end.*
41
+ *Note: Deezer only updates the recent history list if a song has been played to its end.*
40
42
 
41
43
  ## Options
42
44
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  [@ericd](http://app.net/ericd)
4
4
 
5
- [email](eric@aya.io)
5
+ [email](mailto:eric@aya.io)
6
6
 
7
7
  [@ayadn](http://app.net/ayadn)
8
8
 
@@ -33,4 +33,4 @@ I can't keep up and update the list, of course, there's too many of you awesome
33
33
  [@nguarracino](http://app.net/nguarracino)
34
34
  [@schmidt_fu](http://app.net/schmidt_fu)
35
35
 
36
- See also the Ayadn CHANGELOG file...
36
+ See also the Ayadn CHANGELOG file for specific contributions.
@@ -191,7 +191,6 @@ module Ayadn
191
191
  option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order"
192
192
  option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username"
193
193
  option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name"
194
- option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day"
195
194
  option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts"
196
195
  option :date, aliases: "-t", type: :boolean, desc: "Sort the list by: date (only with 'lastposts' option)"
197
196
  option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already"
@@ -209,7 +208,6 @@ module Ayadn
209
208
  option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order"
210
209
  option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username"
211
210
  option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name"
212
- option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day"
213
211
  option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts"
214
212
  option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already"
215
213
  option :cache, type: :boolean, desc: "Cache the results"
@@ -225,7 +223,6 @@ module Ayadn
225
223
  option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order"
226
224
  option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username"
227
225
  option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name"
228
- option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day"
229
226
  option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts"
230
227
  option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already"
231
228
  option :cache, type: :boolean, desc: "Cache the results"
@@ -241,7 +238,6 @@ module Ayadn
241
238
  option :reverse, aliases: "-r", type: :boolean, desc: "Reverses the list original order"
242
239
  option :username, aliases: "-u", type: :boolean, desc: "Sort the list by: username"
243
240
  option :name, aliases: "-n", type: :boolean, desc: "Sort the list by: name"
244
- option :posts_day, aliases: "-d", type: :boolean, desc: "Sort the list by: posts/day"
245
241
  option :posts, aliases: "-p", type: :boolean, desc: "Sort the list by: total posts"
246
242
  option :compact, aliases: "-k", type: :boolean, desc: "Force the view to be compact if not already"
247
243
  option :cache, type: :boolean, desc: "Cache the results"
@@ -17,84 +17,72 @@ module Ayadn
17
17
  # Get NR response
18
18
  # Fetch IDs from store
19
19
  # if absent, decode + save to dic + cache in store
20
- # if present, save to dic from store (and count hits for debug)
20
+ # if present, save to dic from store (and count hits for debug)
21
21
  def get_ranks stream
22
- user_ids, niceranks = [], {}
23
- stream['data'].each do |post|
24
- id = post['user']['id']
25
- user_ids << id if @store[id].nil?
26
- end
27
- user_ids.uniq!
28
- got = CNX.get "#{@url}#{user_ids.join(',')}&show_details=Y" unless user_ids.empty?
29
- if got.nil? || got == ""
30
- parsed = {'meta' => {'code' => 404}, 'data' => []}
31
- else
32
-
33
- begin
34
- parsed = JSON.parse(got)
35
- rescue JSON::ParserError => e
36
- parsed = {'meta' => {'code' => 404}, 'data' => []}
22
+ begin
23
+ user_ids, niceranks = [], {}
24
+ stream['data'].each do |post|
25
+ id = post['user']['id']
26
+ user_ids << id if @store[id].nil?
37
27
  end
38
-
39
- end
40
- parsed['data'].each do |obj|
41
- res = @store[obj['user_id']]
42
- if res.nil?
43
- obj['account']['is_human'] == true ? is_human = 1 : is_human = 0
44
- obj['account']['real_person'] == true ? real_person = 1 : real_person = 0
45
- content = {
46
- username: obj['user']['username'],
47
- rank: obj['rank'],
48
- is_human: is_human,
49
- real_person: real_person
50
- }
51
- @store[obj['user_id']] = content
52
- niceranks[obj['user_id']] = content
28
+ user_ids.uniq!
29
+ got = CNX.get "#{@url}#{user_ids.join(',')}" unless user_ids.empty?
30
+ if got.nil? || got == ""
31
+ parsed = {'meta' => {'code' => 404}, 'data' => []}
53
32
  else
54
- @hits += 1
55
- niceranks[obj['user_id']] = res
56
- end
57
33
 
58
- end
34
+ begin
35
+ parsed = JSON.parse(got)
36
+ rescue
37
+ parsed = {'meta' => {'code' => 404}, 'data' => []}
38
+ end
59
39
 
60
- @posts += stream['data'].size
61
- @ids += user_ids.size
40
+ unless parsed['data'].is_a?(Array)
41
+ parsed = {'meta' => {'code' => 404}, 'data' => []}
42
+ end
62
43
 
63
- if Settings.options[:timeline][:debug] == true
64
- deb = "\n"
65
- deb << "+ NICERANK\n"
66
- deb << "* t#{Time.now.to_i}\n"
67
- deb << "Posts:\t\t#{stream['data'].size}\n"
68
- deb << "Requested NR:\t#{user_ids.size}\n"
69
- deb << "* TOTALS\n"
70
- deb << "Posts:\t\t#{@posts}\n"
71
- deb << "Fetched ranks:\t#{@ids}\n"
72
- deb << "DB hits:\t#{@hits}\n"
73
- deb << "Uniques:\t#{@store.count}\n"
74
- deb << "\n"
75
- puts deb.color(Settings.options[:colors][:debug])
76
- Logs.rec.debug "NICERANK/POSTS: #{@posts}"
77
- Logs.rec.debug "NICERANK/NR CALLS: #{@ids}"
78
- Logs.rec.debug "NICERANK/CACHE HITS: #{@hits}"
79
- Logs.rec.debug "NICERANK/CACHED IDS: #{@store.count}"
80
- end
44
+ end
45
+ parsed['data'].each do |obj|
46
+ res = @store[obj['user_id']]
47
+ if res.nil?
48
+ obj['is_human'] == true ? is_human = 1 : is_human = 0
49
+ content = {
50
+ rank: obj['rank'],
51
+ is_human: is_human
52
+ }
53
+ @store[obj['user_id']] = content
54
+ niceranks[obj['user_id']] = content
55
+ else
56
+ @hits += 1
57
+ niceranks[obj['user_id']] = res
58
+ end
59
+ end
81
60
 
82
- return niceranks
83
- end
84
61
 
85
- # This is for user info, no scrolling: no need to cache
86
- def get_posts_day ids
87
- resp = JSON.parse(CNX.get("#{@url}#{ids.join(',')}&show_details=Y"))
88
- if resp.nil? || resp['meta']['code'] != 200
89
- []
90
- else
91
- resp['data'].map do |obj|
92
- pday = obj['user']['posts_day'] == -1 ? 0 : obj['user']['posts_day']
93
- {
94
- id: obj['user_id'],
95
- posts_day:pday.round(2)
96
- }
62
+ @posts += stream['data'].size
63
+ @ids += user_ids.size
64
+
65
+ if Settings.options[:timeline][:debug] == true
66
+ deb = "\n"
67
+ deb << "+ NICERANK\n"
68
+ deb << "* t#{Time.now.to_i}\n"
69
+ deb << "Posts:\t\t#{stream['data'].size}\n"
70
+ deb << "Requested NR:\t#{user_ids.size}\n"
71
+ deb << "* TOTALS\n"
72
+ deb << "Posts:\t\t#{@posts}\n"
73
+ deb << "Fetched ranks:\t#{@ids}\n"
74
+ deb << "DB hits:\t#{@hits}\n"
75
+ deb << "Uniques:\t#{@store.count}\n"
76
+ deb << "\n"
77
+ puts deb.color(Settings.options[:colors][:debug])
78
+ Logs.rec.debug "NICERANK/POSTS: #{@posts}"
79
+ Logs.rec.debug "NICERANK/NR CALLS: #{@ids}"
80
+ Logs.rec.debug "NICERANK/CACHE HITS: #{@hits}"
81
+ Logs.rec.debug "NICERANK/CACHED IDS: #{@store.count}"
97
82
  end
83
+ return niceranks
84
+ rescue => e
85
+ Errors.global_error({error: e, caller: caller, data: [user_ids, niceranks, parsed]})
98
86
  end
99
87
  end
100
88
 
@@ -108,7 +96,7 @@ module Ayadn
108
96
  blocs << ids.shift(200)
109
97
  end
110
98
  blocs.each do |bloc|
111
- got = CNX.get("#{@url}#{bloc.join(',')}&show_details=Y")
99
+ got = CNX.get("#{@url}#{bloc.join(',')}")
112
100
  if got.nil? || got.empty?
113
101
  ranks << [{}]
114
102
  else
@@ -88,7 +88,7 @@ module Ayadn
88
88
  @status.fetching_from('iTunes')
89
89
  itunes = get_itunes_track_infos()
90
90
  itunes.each do |el|
91
- if el.length == 0
91
+ if el.nil? || el.length == 0
92
92
  @status.empty_fields
93
93
  exit
94
94
  end
@@ -96,7 +96,7 @@ module Ayadn
96
96
  post_itunes(options, itunes)
97
97
  rescue => e
98
98
  @status.wtf
99
- Errors.global_error({error: e, caller: caller, data: [itunes, store, options]})
99
+ Errors.global_error({error: e, caller: caller, data: [itunes, options]})
100
100
  end
101
101
  end
102
102
 
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
- VERSION = "2.0.12"
3
+ VERSION = "2.1"
4
4
  end
@@ -71,7 +71,7 @@ module Ayadn
71
71
  if options[:username]
72
72
  bucket.sort_by! { |obj| obj[1] }
73
73
  elsif options[:name]
74
- bucket.sort_by! { |obj| obj[2].downcase }
74
+ bucket.sort_by! { |obj| obj[2] }
75
75
  elsif options[:posts]
76
76
  bucket.sort_by! { |obj| [obj[5], obj[1]] }.reverse!
77
77
  elsif options[:date]
@@ -97,7 +97,7 @@ module Ayadn
97
97
  hashtags = @workers.extract_hashtags(obj[6])
98
98
  text = @workers.colorize_text(obj[6]["text"], mentions, hashtags)
99
99
  total = "(#{obj[5]} posts)"
100
- name = obj[2].nil? ? "(no name)" : obj[2]
100
+ name = obj[2] == "" ? "(no name)" : obj[2]
101
101
  colored_total = total.color(Settings.options[:colors][:link])
102
102
  colored_name = name.color(Settings.options[:colors][:name])
103
103
  colored_date = date.color(Settings.options[:colors][:date])
@@ -218,14 +218,14 @@ module Ayadn
218
218
  view << "#{padding}Posts\t\t\t".color(:cyan) + content['counts']['posts'].to_s.color(Settings.options[:colors][:excerpt])
219
219
 
220
220
 
221
- unless show_ranks == false
222
- # this is ok for one user, but do not call this in a loop
223
- # do call them all at once instead if many
224
- ranks = NiceRank.new.get_posts_day([content['id'].to_i])
225
- unless ranks.empty?
226
- view << "#{padding}Posts/day\t\t".color(:cyan) + ranks[0][:posts_day].to_s.color(Settings.options[:colors][:excerpt])
227
- end
228
- end
221
+ # unless show_ranks == false
222
+ # # this is ok for one user, but do not call this in a loop
223
+ # # do call them all at once instead if many
224
+ # ranks = NiceRank.new.get_posts_day([content['id'].to_i])
225
+ # unless ranks.empty?
226
+ # view << "#{padding}Posts/day\t\t".color(:cyan) + ranks[0][:posts_day].to_s.color(Settings.options[:colors][:excerpt])
227
+ # end
228
+ # end
229
229
 
230
230
  view << "#{padding}Following\t\t".color(:cyan) + content['counts']['following'].to_s.color(Settings.options[:colors][:excerpt])
231
231
  view << "\nFollowers\t\t".color(:cyan) + content['counts']['followers'].to_s.color(Settings.options[:colors][:excerpt])
@@ -514,7 +514,6 @@ module Ayadn
514
514
  unless content[:nicerank] == false
515
515
  next if content[:nicerank] < Settings.options[:nicerank][:threshold]
516
516
  next if content[:is_human] == 0
517
- next if content[:real_person] == 0
518
517
  end
519
518
  filtered[id] = content
520
519
  end
@@ -111,43 +111,21 @@ module Ayadn
111
111
  users = at(list.map {|obj| obj[:username]})
112
112
  ids = list.map {|obj| obj[:id].to_i}
113
113
  ranks = NiceRank.new.from_ids(ids)
114
- indexed_ranks = {}
115
- ranks.each do |r|
116
- if r.empty?
117
- indexed_ranks = false
118
- break
119
- else
120
- indexed_ranks[r['user_id']] = r
121
- end
122
- end
123
- table << ['USERNAME'.color(:red), 'NAME'.color(:red), 'POSTS'.color(:red), 'POSTS/DAY'.color(:red)]
114
+ table << ['USERNAME'.color(:red), 'NAME'.color(:red), 'POSTS'.color(:red)]
124
115
  table << :separator
125
116
  arr = []
126
117
  if options[:username]
127
118
  list.sort_by! { |obj| obj[:username] }
128
119
  elsif options[:name]
129
- list.sort_by! { |obj| obj[:name].downcase }
120
+ list.sort_by! { |obj| obj[:name].nil? ? "(no name)" : obj[:name].downcase }
130
121
  elsif options[:posts]
131
122
  list.sort_by! { |obj| [obj[:posts], obj[:username]] }
132
123
  end
133
124
  list.each do |obj|
134
125
  obj[:name] = "" if obj[:name].nil?
135
- unless indexed_ranks == false
136
- details = indexed_ranks[obj[:id].to_i]
137
- if details['user']['posts_day'] == -1
138
- posts_day = 'ignored'
139
- else
140
- posts_day = details['user']['posts_day'].round(2).to_s
141
- end
142
- else
143
- posts_day = 'unknown'
144
- end
145
126
  obj[:username].length > 23 ? username = "#{obj[:username][0..20]}..." : username = obj[:username]
146
127
  obj[:name].length > 23 ? name = "#{obj[:name][0..20]}..." : name = obj[:name]
147
- arr << [ "@#{username} ".color(Settings.options[:colors][:username]), "#{name.to_s.force_encoding('UTF-8')}", obj[:posts], posts_day ]
148
- end
149
- if options[:posts_day]
150
- arr.sort_by! { |obj| obj[3].to_f }
128
+ arr << [ "@#{username} ".color(Settings.options[:colors][:username]), "#{name.to_s.force_encoding('UTF-8')}", obj[:posts] ]
151
129
  end
152
130
  if options[:reverse]
153
131
  arr.reverse!
@@ -172,8 +150,8 @@ module Ayadn
172
150
  unless Settings.global[:force] == true
173
151
  if Settings.options[:blacklist][:active] == true
174
152
  if Databases.is_in_blacklist?('client', post['source']['name'].downcase)
175
- Debug.skipped({source: post['source']['name']})
176
- next
153
+ Debug.skipped({source: post['source']['name']})
154
+ next
177
155
  end
178
156
  end
179
157
  end
@@ -231,11 +209,9 @@ module Ayadn
231
209
  if niceranks[post['user']['id'].to_i]
232
210
  rank = niceranks[post['user']['id'].to_i][:rank]
233
211
  is_human = niceranks[post['user']['id'].to_i][:is_human]
234
- real_person = niceranks[post['user']['id'].to_i][:real_person]
235
212
  else
236
213
  rank = false
237
214
  is_human = 'unknown'
238
- real_person = 'unknown'
239
215
  end
240
216
 
241
217
  if post['user'].has_key?('name')
@@ -255,7 +231,6 @@ module Ayadn
255
231
  user_id: post['user']['id'].to_i,
256
232
  nicerank: rank,
257
233
  is_human: is_human,
258
- real_person: real_person,
259
234
  handle: "@#{post['user']['username']}",
260
235
  type: post['user']['type'],
261
236
  date: parsed_time(post['created_at']),
Binary file
@@ -1 +1 @@
1
- {"meta":{"code":200,"more":false},"data":[{"user_id":69904,"rank":3.816259,"is_human":true,"user":{"username":"ericd","account_age":513,"following":277,"followers":261,"posts":5933,"stars":345,"posts_day":11.5653,"days_idle":0},"account":{"has_avatar":true,"has_bio":true,"has_cover":true,"is_verified":true,"is_human":true,"real_person":true},"stats":{"robo_posts":6,"post_count":294,"conversations":229,"links":36,"mentions":232,"questions":25}}]}
1
+ {"meta":{"code":200,"more":false},"data":[{"user_id":69904,"rank":3.816259,"is_human":true}]}
@@ -97,24 +97,14 @@ describe Ayadn::NiceRank do
97
97
  let(:rest) {Ayadn::CNX}
98
98
  # let(:nicerank) { JSON.parse(File.read("spec/mock/nicerank.json")) }
99
99
 
100
- describe "#get_posts_day" do
101
- before do
102
- rest.stub(:get).and_return(File.read("spec/mock/nicerank.json"))
103
- end
104
- it "get posts/day for a user" do
105
- expect(rest).to receive(:get).with("http://api.nice.social/user/nicerank?ids=69904&show_details=Y")
106
- x = Ayadn::NiceRank.new.get_posts_day(['69904'])
107
- expect(x).to eq [{:id=>69904, :posts_day=>11.57}]
108
- end
109
- end
110
100
  describe "#from_ids" do
111
101
  before do
112
102
  rest.stub(:get).and_return(File.read("spec/mock/nicerank.json"))
113
103
  end
114
104
  it "get niceranks from user ids" do
115
- expect(rest).to receive(:get).with("http://api.nice.social/user/nicerank?ids=69904&show_details=Y")
105
+ expect(rest).to receive(:get).with("http://api.nice.social/user/nicerank?ids=69904")
116
106
  x = Ayadn::NiceRank.new.from_ids(['69904'])
117
- expect(x).to eq [{"user_id"=>69904,"rank"=>3.816259,"is_human"=>true,"user"=> {"username"=>"ericd","account_age"=>513,"following"=>277,"followers"=>261,"posts"=>5933,"stars"=>345,"posts_day"=>11.5653,"days_idle"=>0},"account"=> {"has_avatar"=>true,"has_bio"=>true,"has_cover"=>true,"is_verified"=>true,"is_human"=>true,"real_person"=>true},"stats"=>{"robo_posts"=>6,"post_count"=>294,"conversations"=>229,"links"=>36,"mentions"=>232,"questions"=>25}}]
107
+ expect(x).to eq [{"user_id"=>69904,"rank"=>3.816259,"is_human"=>true}]
118
108
  end
119
109
  end
120
110
  end
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: 2.0.12
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dejonckheere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-10 00:00:00.000000000 Z
11
+ date: 2015-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor