ayadn 1.2.10 → 1.3.0

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: 59e66569c512036ff97974dabb24cbef415d082b
4
- data.tar.gz: 5bc80e482e6118f1c743733eff0e4e25418c54be
3
+ metadata.gz: 68be7f0b81c33d2647ee698be5d787d3ab302b23
4
+ data.tar.gz: dee94c175ef19fead20537823adb02e293817cfe
5
5
  SHA512:
6
- metadata.gz: 1c50fd4120b74b199008bf6a701aa22ad0c30725235e7248184e1f9ba375cbd696a3b665fbbcfc39f0fad017095ba388735ca926699b7ab3f280c70ae3734d8a
7
- data.tar.gz: 7a91a9a7c28056bbe80706cda043dbc2be0c85bf7379196e3c7bbf01d27201b174492017c3197bb9e7701bd3bf2f3234a90b4a4393660efaf96df5920c2474ae
6
+ metadata.gz: 1b41aee21510a8dc7baec12d9cd874c304fc39bd2be299e4df82c58a19e44100f11caa7fe71a2f3bad5f385c64aa5cbfb72c72dc7d9ab3f869ff80a535b6dd08
7
+ data.tar.gz: b116e88c21e37e31d29532f679a444301535cf5cd4902d5bbae7077a52bde198ed003da610cc6f5078c9b44639c297d961a46c937db0aca9ae5eff23dcab19f3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 1.3.0 - 'K'
2
+
3
+ - Updated the NiceRank API url
4
+ - NiceRank filter is more efficient (checks is_human + real_person)
5
+ - A few gridless grids for readability
6
+ - Added several command synonyms
7
+ Features:
8
+ - New color: black. Depends on your terminal. (ex: ayadn set color date black)
9
+ - Silence a user (ayadn -K add user @username)
10
+ - Clear the contents of the aliases database (ayadn -A clear)
11
+ - Clear the contents of the blacklist database (ayadn -K clear)
12
+ - Clear the contents of the bookmarks database (ayadn mark clear)
13
+
1
14
  # 1.2.10 - 'Anders'
2
15
 
3
16
  - Fixed the non-installing unicode_utils Gem
data/lib/ayadn/alias.rb CHANGED
@@ -3,6 +3,7 @@ module Ayadn
3
3
  class Alias < Thor
4
4
 
5
5
  desc "create CHANNEL ALIAS", "Creates an alias for a channel"
6
+ map "add" => :create
6
7
  long_desc Descriptions.alias_create
7
8
  def create(*args)
8
9
  begin
@@ -27,6 +28,7 @@ module Ayadn
27
28
  end
28
29
 
29
30
  desc "delete ALIAS", "Deletes a previously created alias"
31
+ map "remove" => :delete
30
32
  long_desc Descriptions.alias_delete
31
33
  def delete(*args)
32
34
  begin
@@ -94,6 +96,26 @@ module Ayadn
94
96
  end
95
97
  end
96
98
 
99
+ desc "clear", "Clear your aliases database"
100
+ def clear
101
+ begin
102
+ init
103
+ puts "\n\nAre you sure you want to erase all the content of your aliases database?\n\n[y/N]\n".color(:red)
104
+ input = STDIN.getch
105
+ if input == 'y' || input == 'Y'
106
+ Databases.clear_aliases
107
+ Logs.rec.info "Cleared the aliases database."
108
+ puts Status.done
109
+ else
110
+ abort Status.canceled
111
+ end
112
+ rescue => e
113
+ Errors.global_error("alias/clear", args, e)
114
+ ensure
115
+ Databases.close_all
116
+ end
117
+ end
118
+
97
119
  private
98
120
 
99
121
  def init
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
3
  class Blacklist < Thor
4
- desc "add TYPE TARGET", "Adds a mention, hashtag or client to your blacklist"
4
+ desc "add TYPE TARGET", "Adds a mention, hashtag, client or username to your blacklist"
5
+ map "create" => :add
5
6
  long_desc Descriptions.blacklist_add
6
7
  def add(*args)
7
8
  Action.quit(Status.type_and_target_missing) if args.length < 2
@@ -9,7 +10,8 @@ module Ayadn
9
10
  puts Status.done
10
11
  end
11
12
 
12
- desc "remove TYPE TARGET", "Removes a mention, hashtag or client from your blacklist"
13
+ desc "remove TYPE TARGET", "Removes a mention, hashtag, client or username from your blacklist"
14
+ map "delete" => :remove
13
15
  long_desc Descriptions.blacklist_remove
14
16
  def remove(*args)
15
17
  Action.quit(Status.type_and_target_missing) if args.length < 2
@@ -37,6 +39,12 @@ module Ayadn
37
39
  puts Status.done
38
40
  end
39
41
 
42
+ desc "clear", "Clear your blacklist database"
43
+ def clear
44
+ BlacklistWorkers.new.clear
45
+ puts Status.done
46
+ end
47
+
40
48
  end
41
49
 
42
50
  class BlacklistWorkers
@@ -68,10 +76,28 @@ module Ayadn
68
76
  Databases.close_all
69
77
  end
70
78
  end
79
+ def clear
80
+ begin
81
+ puts "\n\nAre you sure you want to erase all the content of your blacklist database?\n\n[y/N]\n".color(:red)
82
+ input = STDIN.getch
83
+ if input == 'y' || input == 'Y'
84
+ Databases.clear_blacklist
85
+ Logs.rec.info "Cleared the blacklist database."
86
+ else
87
+ abort Status.canceled
88
+ end
89
+ ensure
90
+ Databases.close_all
91
+ end
92
+ end
71
93
  def add(args)
72
94
  begin
73
95
  type = args.shift
74
96
  case type
97
+ when 'user', 'username', 'account'
98
+ target = Workers.add_arobases_to_usernames args
99
+ Databases.add_user_to_blacklist(target)
100
+ Logs.rec.info "Added '#{target}' to blacklist of users."
75
101
  when 'mention', 'mentions'
76
102
  target = Workers.add_arobases_to_usernames args
77
103
  Databases.add_mention_to_blacklist(target)
@@ -93,6 +119,11 @@ module Ayadn
93
119
  begin
94
120
  type = args.shift
95
121
  case type
122
+ when 'user', 'username', 'account'
123
+ temp = Workers.add_arobases_to_usernames args
124
+ target = temp.map {|u| "-#{u}"}
125
+ Databases.remove_from_blacklist(target)
126
+ Logs.rec.info "Removed '#{target}' from blacklist of users."
96
127
  when 'mention', 'mentions'
97
128
  target = Workers.add_arobases_to_usernames args
98
129
  Databases.remove_from_blacklist(target)
@@ -61,6 +61,9 @@ module Ayadn
61
61
  ids
62
62
  end
63
63
 
64
+ def self.add_user_to_blacklist(target)
65
+ target.each {|username| @blacklist["-#{username.downcase}"] = :user}
66
+ end
64
67
  def self.add_mention_to_blacklist(target)
65
68
  target.each {|username| @blacklist[username.downcase] = :mention}
66
69
  end
@@ -96,6 +99,18 @@ module Ayadn
96
99
  @aliases.delete(channel_alias)
97
100
  end
98
101
 
102
+ def self.clear_aliases
103
+ @aliases.clear
104
+ end
105
+
106
+ def self.clear_blacklist
107
+ @blacklist.clear
108
+ end
109
+
110
+ def self.clear_bookmarks
111
+ @bookmarks.clear
112
+ end
113
+
99
114
  def self.get_channel_id(channel_alias)
100
115
  @aliases[channel_alias]
101
116
  end
data/lib/ayadn/mark.rb CHANGED
@@ -76,6 +76,26 @@ module Ayadn
76
76
  end
77
77
  end
78
78
 
79
+ desc "clear", "Clear your bookmarks database"
80
+ def clear
81
+ begin
82
+ init
83
+ puts "\n\nAre you sure you want to erase all the content of your bookmarks database?\n\n[y/N]\n".color(:red)
84
+ input = STDIN.getch
85
+ if input == 'y' || input == 'Y'
86
+ Databases.clear_bookmarks
87
+ Logs.rec.info "Cleared the bookmarks database."
88
+ puts Status.done
89
+ else
90
+ abort Status.canceled
91
+ end
92
+ rescue => e
93
+ Errors.global_error("mark/clear", nil, e)
94
+ ensure
95
+ Databases.close_all
96
+ end
97
+ end
98
+
79
99
  desc "delete POST_ID", "Delete entry POST_ID from your bookmarked conversations"
80
100
  long_desc Descriptions.mark_delete
81
101
  def delete *args
@@ -3,7 +3,7 @@ module Ayadn
3
3
  class NiceRank
4
4
 
5
5
  def initialize
6
- @url = 'http://api.search-adn.net/user/nicerank?ids='
6
+ @url = 'http://api.nice.social/user/nicerank?ids='
7
7
  end
8
8
 
9
9
  def get_ranks stream
@@ -35,6 +35,7 @@ module Ayadn
35
35
  username: ranks[:username],
36
36
  rank: ranks[:rank],
37
37
  is_human: ranks[:is_human],
38
+ real_person: ranks[:real_person],
38
39
  cached: ranks[:cached]
39
40
  }
40
41
  end
@@ -43,7 +44,7 @@ module Ayadn
43
44
  Debug.how_many_ranks niceranks, get_these
44
45
 
45
46
  unless get_these.empty?
46
- resp = JSON.parse(CNX.get "#{@url}#{get_these.join(',')}")
47
+ resp = JSON.parse(CNX.get "#{@url}#{get_these.join(',')}&show_details=Y")
47
48
 
48
49
  if resp['meta']['code'] != 200
49
50
  Debug.niceranks_error resp
@@ -62,6 +63,7 @@ module Ayadn
62
63
  username: table[obj['user_id']],
63
64
  rank: obj['rank'],
64
65
  is_human: obj['is_human'],
66
+ real_person: obj['account']['real_person'],
65
67
  cached: Time.now
66
68
  }
67
69
  end
data/lib/ayadn/set.rb CHANGED
@@ -243,7 +243,7 @@ module Ayadn
243
243
  end
244
244
  end
245
245
  def self.cache_range value
246
- if value >= 3 && value <= 720
246
+ if value >= 1 && value <= 168
247
247
  value.round
248
248
  else
249
249
  abort(Status.cache_range)
@@ -254,7 +254,7 @@ module Ayadn
254
254
  t >= 1 ? t : 3
255
255
  end
256
256
  def self.color(color)
257
- colors_list = %w{red green magenta cyan yellow blue white}
257
+ colors_list = %w{red green magenta cyan yellow blue white black}
258
258
  unless colors_list.include?(color)
259
259
  puts Status.error_missing_parameters
260
260
  abort(Status.valid_colors(colors_list))
@@ -452,18 +452,34 @@ module Ayadn
452
452
  Settings.options[:colors][:hashtags] = color.to_sym
453
453
  end
454
454
 
455
+ def hashtag color
456
+ hashtags color
457
+ end
458
+
455
459
  def mentions(color)
456
460
  Settings.options[:colors][:mentions] = color.to_sym
457
461
  end
458
462
 
463
+ def mention color
464
+ mentions color
465
+ end
466
+
459
467
  def source(color)
460
468
  Settings.options[:colors][:source] = color.to_sym
461
469
  end
462
470
 
471
+ def client color
472
+ source color
473
+ end
474
+
463
475
  def symbols(color)
464
476
  Settings.options[:colors][:symbols] = color.to_sym
465
477
  end
466
478
 
479
+ def symbol(color)
480
+ symbols color
481
+ end
482
+
467
483
  def debug(color)
468
484
  Settings.options[:colors][:debug] = color.to_sym
469
485
  end
data/lib/ayadn/status.rb CHANGED
@@ -245,7 +245,7 @@ module Ayadn
245
245
  "\nPlease wait while Ayadn is pruning and compacting the #{db} database...\n".color(:cyan)
246
246
  end
247
247
  def self.cache_range
248
- "\nPlease enter a number of hours between 3 and 168.\n\n".color(:red)
248
+ "\nPlease enter a number of hours between 1 and 168.\n\n".color(:red)
249
249
  end
250
250
  def self.must_be_in_index
251
251
  "\nNumber must be in the range of the indexed posts.\n".color(:red)
data/lib/ayadn/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
- VERSION = "1.2.10"
3
+ VERSION = "1.3.0"
4
4
  end
data/lib/ayadn/view.rb CHANGED
@@ -77,7 +77,7 @@ module Ayadn
77
77
 
78
78
  def show_settings
79
79
  table = Terminal::Table.new do |t|
80
- t.style = { :width => Settings.options[:formats][:table][:width] }
80
+ t.style = { :width => Settings.options[:formats][:table][:width], border_x: ' ', border_i: ' ', border_y: ' ' }
81
81
  t.title = "Current Ayadn settings".color(:cyan)
82
82
  t.headings = [ "Category".color(:red), "Parameter".color(:red), "Value(s)".color(:red) ]
83
83
  @iter = 0
@@ -296,14 +296,13 @@ module Ayadn
296
296
  unless content[:nicerank] == false
297
297
  next if content[:nicerank] < Settings.options[:nicerank][:threshold]
298
298
  next if content[:is_human] == false
299
+ next if content[:real_person] == false
299
300
  end
300
301
  filtered[id] = content
301
302
  end
302
303
  return filtered
303
304
  end
304
- return posts
305
305
  end
306
- return posts
307
306
  end
308
307
  return posts
309
308
  end
data/lib/ayadn/workers.rb CHANGED
@@ -5,6 +5,7 @@ module Ayadn
5
5
  def build_aliases_list(list)
6
6
  table = init_table
7
7
  table.title = "List of your channel aliases".color(:cyan) + "".color(:white)
8
+ table.style = {border_x: '~', border_i: '+', border_y: ':'}
8
9
  list.each {|k,v| table << ["#{k}".color(:green), "#{v}".color(:red)]}
9
10
  table
10
11
  end
@@ -12,6 +13,8 @@ module Ayadn
12
13
  def build_blacklist_list(list)
13
14
  table = init_table
14
15
  table.title = "Your blacklist".color(:cyan) + "".color(:white)
16
+ table.style = {border_x: '~', border_i: '+', border_y: ':'}
17
+ list = list.sort_by {|k,v| v} # no sort_by! for Daybreak dbs
15
18
  list.each {|k,v| table << ["#{v.capitalize}".color(:green), "#{k}".color(:red)]}
16
19
  table
17
20
  end
@@ -24,6 +27,7 @@ module Ayadn
24
27
  obj['name'].nil? ? name = "" : name = obj['name']
25
28
  users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you']}
26
29
  end
30
+ table.style = {border_x: ' ', border_i: ' ', border_y: ' '}
27
31
  return users_list, table
28
32
  end
29
33
 
@@ -35,6 +39,7 @@ module Ayadn
35
39
  obj['name'].nil? ? name = "" : name = obj['name']
36
40
  users_list << {:username => obj['username'], :name => name, :you_follow => obj['you_follow'], :follows_you => obj['follows_you']}
37
41
  end
42
+ table.style = {border_x: ' ', border_i: ' ', border_y: ' '}
38
43
  return users_list, table
39
44
  end
40
45
 
@@ -45,6 +50,7 @@ module Ayadn
45
50
  else
46
51
  "List of users ".color(:cyan) + "#{target}".color(:red) + " is following ".color(:cyan) + "".color(:white)
47
52
  end
53
+ table.style = {border_x: ' ', border_i: ' ', border_y: ' '}
48
54
  users_list = build_users_array(list)
49
55
  build_users_list(users_list, table)
50
56
  end
@@ -56,27 +62,32 @@ module Ayadn
56
62
  else
57
63
  "List of users following ".color(:cyan) + "#{target}".color(:red) + "".color(:white)
58
64
  end
65
+ table.style = {border_x: ' ', border_i: ' ', border_y: ' '}
59
66
  build_users_list(build_users_array(list), table)
60
67
  end
61
68
 
62
69
  def build_muted_list(list)
63
70
  table = init_table
64
71
  table.title = "List of users you muted".color(:cyan) + "".color(:white)
72
+ table.style = {border_x: ' ', border_i: ' ', border_y: ' '}
65
73
  build_users_list(build_users_array(list), table)
66
74
  end
67
75
 
68
76
  def build_blocked_list(list)
69
77
  table = init_table
70
78
  table.title = "List of users you blocked".color(:cyan) + "".color(:white)
79
+ table.style = {border_x: ' ', border_i: ' ', border_y: ' '}
71
80
  build_users_list(build_users_array(list), table)
72
81
  end
73
82
 
74
83
  def build_users_list(list, table)
75
84
  list.each_with_index do |obj, index|
85
+ obj[:username].length > 35 ? username = "#{obj[:username][0...32]}..." : username = obj[:username]
76
86
  unless obj[:name].nil?
77
- table << [ "@#{obj[:username]} ".color(Settings.options[:colors][:username]), "#{obj[:name]}" ]
87
+ obj[:name].length > 35 ? name = "#{obj[:name][0...32]}..." : name = obj[:name]
88
+ table << [ "@#{username} ".color(Settings.options[:colors][:username]), "#{name}" ]
78
89
  else
79
- table << [ "@#{obj[:username]} ".color(Settings.options[:colors][:username]), "" ]
90
+ table << [ "@#{username} ".color(Settings.options[:colors][:username]), "" ]
80
91
  end
81
92
  table << :separator unless index + 1 == list.length
82
93
  end
@@ -89,6 +100,7 @@ module Ayadn
89
100
 
90
101
  data.each.with_index(1) do |post, index|
91
102
  next if Databases.blacklist[post['source']['name'].downcase]
103
+ next if Databases.blacklist["-@#{post['user']['username'].downcase}"]
92
104
  hashtags = extract_hashtags(post)
93
105
  @skip = false
94
106
  hashtags.each do |h|
@@ -101,7 +113,7 @@ module Ayadn
101
113
  mentions= []
102
114
  post['entities']['mentions'].each { |m| mentions << m['name'] }
103
115
  mentions.each do |m|
104
- if Databases.blacklist["@" + m.downcase]
116
+ if Databases.blacklist["@#{m.downcase}"]
105
117
  @skip = true
106
118
  break
107
119
  end
@@ -111,9 +123,11 @@ module Ayadn
111
123
  if niceranks[post['user']['id'].to_i]
112
124
  rank = niceranks[post['user']['id'].to_i][:rank]
113
125
  is_human = niceranks[post['user']['id'].to_i][:is_human]
126
+ real_person = niceranks[post['user']['id'].to_i][:real_person]
114
127
  else
115
128
  rank = false
116
129
  is_human = 'unknown'
130
+ real_person = nil
117
131
  end
118
132
 
119
133
  if post['user'].has_key?('name')
@@ -133,6 +147,7 @@ module Ayadn
133
147
  user_id: post['user']['id'].to_i,
134
148
  nicerank: rank,
135
149
  is_human: is_human,
150
+ real_person: real_person,
136
151
  handle: "@#{post['user']['username']}",
137
152
  type: post['user']['type'],
138
153
  date: parsed_time(post['created_at']),
@@ -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 32
44
+ expect(posts[23187443].length).to eq 33
45
45
  end
46
46
  it "gets oembed link from checkins post" do
47
47
  posts = Ayadn::Workers.new.build_posts(checkins['data'])
@@ -88,7 +88,7 @@ describe Ayadn::Workers do
88
88
  printed = capture_stdout do
89
89
  puts Ayadn::Workers.new.build_followers_list(list, "@test")
90
90
  end
91
- expect(printed).to include "+----"
91
+ #expect(printed).to include "+----"
92
92
  expect(printed).to include "@test"
93
93
  expect(printed).to include "@bond"
94
94
  expect(printed).to include "Mr Test"
@@ -100,7 +100,7 @@ describe Ayadn::Workers do
100
100
  printed = capture_stdout do
101
101
  puts Ayadn::Workers.new.build_followings_list(list, "@test")
102
102
  end
103
- expect(printed).to include "+----"
103
+ #expect(printed).to include "+~~~~"
104
104
  expect(printed).to include "@test"
105
105
  expect(printed).to include "@bond"
106
106
  expect(printed).to include "Mr Test"
@@ -112,7 +112,7 @@ describe Ayadn::Workers do
112
112
  printed = capture_stdout do
113
113
  puts Ayadn::Workers.new.build_muted_list(list)
114
114
  end
115
- expect(printed).to include "+----"
115
+ #expect(printed).to include "+----"
116
116
  expect(printed).to include "@bond"
117
117
  expect(printed).to include "Mr Test"
118
118
  end
@@ -123,7 +123,7 @@ describe Ayadn::Workers do
123
123
  printed = capture_stdout do
124
124
  puts Ayadn::Workers.new.build_blocked_list(list)
125
125
  end
126
- expect(printed).to include "+----"
126
+ #expect(printed).to include "+----"
127
127
  expect(printed).to include "@bond"
128
128
  expect(printed).to include "Mr Test"
129
129
  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: 1.2.10
4
+ version: 1.3.0
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-30 00:00:00.000000000 Z
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -322,4 +322,3 @@ test_files:
322
322
  - spec/unit/status_spec.rb
323
323
  - spec/unit/view_spec.rb
324
324
  - spec/unit/workers_spec.rb
325
- has_rdoc: