ayadn 2.1 → 3.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/.gitignore +2 -1
- data/.travis.yml +1 -2
- data/CHANGELOG.md +11 -0
- data/README.md +7 -9
- data/ayadn.gemspec +1 -2
- data/doc/02-install.md +11 -1
- data/doc/18-contact.md +0 -2
- data/lib/ayadn.rb +1 -1
- data/lib/ayadn/action.rb +13 -14
- data/lib/ayadn/annotations.rb +1 -1
- data/lib/ayadn/api.rb +8 -3
- data/lib/ayadn/app.rb +23 -11
- data/lib/ayadn/authorize.rb +47 -27
- data/lib/ayadn/cnx.rb +20 -3
- data/lib/ayadn/descriptions.rb +0 -12
- data/lib/ayadn/diagnostics.rb +471 -0
- data/lib/ayadn/endpoints.rb +47 -46
- data/lib/ayadn/extend.rb +20 -0
- data/lib/ayadn/fileops.rb +3 -3
- data/lib/ayadn/ids.rb +17 -0
- data/lib/ayadn/nicerank.rb +2 -0
- data/lib/ayadn/nowplaying.rb +12 -5
- data/lib/ayadn/post.rb +2 -0
- data/lib/ayadn/set.rb +78 -3
- data/lib/ayadn/settings.rb +20 -3
- data/lib/ayadn/status.rb +114 -62
- data/lib/ayadn/stream.rb +2 -0
- data/lib/ayadn/switch.rb +18 -11
- data/lib/ayadn/tvshow.rb +7 -3
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +131 -82
- data/lib/ayadn/workers.rb +10 -11
- data/spec/mock/@ericd.json +4 -4
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/mock/files.json +2 -2
- data/spec/mock/fwr_@ayadn.json +4 -4
- data/spec/mock/int.json +13 -13
- data/spec/mock/mentions.json +4 -4
- data/spec/mock/nicerank.log +1 -1
- data/spec/mock/posted.json +1 -1
- data/spec/mock/regex.json +2 -2
- data/spec/unit/annotations_spec.rb +8 -8
- data/spec/unit/post_spec.rb +3 -3
- metadata +5 -20
- data/Guardfile +0 -26
- data/lib/ayadn/migration.rb +0 -431
data/lib/ayadn/status.rb
CHANGED
@@ -13,7 +13,7 @@ module Ayadn
|
|
13
13
|
def canceled
|
14
14
|
say do
|
15
15
|
puts "\n"
|
16
|
-
|
16
|
+
say_red :canceled, ""
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -34,51 +34,51 @@ module Ayadn
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def deleting_post(post_id)
|
37
|
-
|
37
|
+
say_yellow :deleting, "post #{post_id}"
|
38
38
|
end
|
39
39
|
|
40
40
|
def deleting_message(message_id)
|
41
|
-
|
41
|
+
say_yellow :deleting, "message #{message_id}"
|
42
42
|
end
|
43
43
|
|
44
44
|
def unfollowing(username)
|
45
|
-
|
45
|
+
say_yellow :unfollowing, username
|
46
46
|
end
|
47
47
|
|
48
48
|
def following(username)
|
49
|
-
|
49
|
+
say_yellow :following, username
|
50
50
|
end
|
51
51
|
|
52
52
|
def unmuting(username)
|
53
|
-
|
53
|
+
say_yellow :unmuting, username
|
54
54
|
end
|
55
55
|
|
56
56
|
def muting(username)
|
57
|
-
|
57
|
+
say_yellow :muting, username
|
58
58
|
end
|
59
59
|
|
60
60
|
def unblocking(username)
|
61
|
-
|
61
|
+
say_yellow :unblocking, username
|
62
62
|
end
|
63
63
|
|
64
64
|
def blocking(username)
|
65
|
-
|
65
|
+
say_yellow :blocking, username
|
66
66
|
end
|
67
67
|
|
68
68
|
def unreposting(post_id)
|
69
|
-
|
69
|
+
say_yellow :unreposting, "post #{post_id}"
|
70
70
|
end
|
71
71
|
|
72
72
|
def reposting(post_id)
|
73
|
-
|
73
|
+
say_yellow :reposting, "post #{post_id}"
|
74
74
|
end
|
75
75
|
|
76
76
|
def unstarring(post_id)
|
77
|
-
|
77
|
+
say_yellow :unstarring, "post #{post_id}"
|
78
78
|
end
|
79
79
|
|
80
80
|
def starring(post_id)
|
81
|
-
|
81
|
+
say_yellow :starring, "post #{post_id}"
|
82
82
|
end
|
83
83
|
|
84
84
|
def not_deleted(post_id)
|
@@ -207,8 +207,8 @@ module Ayadn
|
|
207
207
|
|
208
208
|
def error_missing_parameters
|
209
209
|
say do
|
210
|
-
|
211
|
-
|
210
|
+
say_error "please submit valid items"
|
211
|
+
say_info "see `ayadn -sg` for a list of valid parameters and values"
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
@@ -218,52 +218,52 @@ module Ayadn
|
|
218
218
|
|
219
219
|
def writing
|
220
220
|
puts "\n"
|
221
|
-
|
221
|
+
say_cyan :author, "#{Settings.config[:identity][:handle]}"
|
222
222
|
puts "\n"
|
223
223
|
end
|
224
224
|
|
225
225
|
def yourmessage username = nil
|
226
226
|
if username.nil?
|
227
|
-
|
227
|
+
say_center "Your message:"
|
228
228
|
else
|
229
|
-
|
229
|
+
say_center "Your message to #{username}:"
|
230
230
|
end
|
231
231
|
puts "\n\n"
|
232
232
|
end
|
233
233
|
|
234
234
|
def message_from(username)
|
235
235
|
puts "\n"
|
236
|
-
|
237
|
-
|
236
|
+
say_yellow :from, "#{Settings.config[:identity][:handle]}"
|
237
|
+
say_yellow :to, "#{username[0]}"
|
238
238
|
end
|
239
239
|
|
240
240
|
def replying_to(post_id)
|
241
241
|
puts "\n"
|
242
|
-
|
242
|
+
say_yellow :replying, "to post #{post_id}"
|
243
243
|
end
|
244
244
|
|
245
245
|
def readline
|
246
246
|
say do
|
247
|
-
|
248
|
-
|
249
|
-
|
247
|
+
say_cyan :next, "type your text"
|
248
|
+
say_cyan :ok, "[CTRL+D] to validate"
|
249
|
+
say_cyan :cancel, "[CTRL+C] to cancel"
|
250
250
|
end
|
251
251
|
end
|
252
252
|
|
253
253
|
def reply
|
254
|
-
|
254
|
+
say_cyan :max, "#{Settings.config[:post_max_length]} characters"
|
255
255
|
end
|
256
256
|
|
257
257
|
def post
|
258
|
-
|
258
|
+
say_cyan :max, "#{Settings.config[:post_max_length]} characters"
|
259
259
|
end
|
260
260
|
|
261
261
|
def message
|
262
|
-
|
262
|
+
say_cyan :max, "#{Settings.config[:message_max_length]} characters"
|
263
263
|
end
|
264
264
|
|
265
265
|
def valid_colors(colors_list)
|
266
|
-
|
266
|
+
say_cyan :info, "valid colors:"
|
267
267
|
say { puts colors_list }
|
268
268
|
end
|
269
269
|
|
@@ -301,8 +301,8 @@ module Ayadn
|
|
301
301
|
|
302
302
|
def error_only_osx
|
303
303
|
say do
|
304
|
-
|
305
|
-
|
304
|
+
say_error "this feature only works with iTunes by default"
|
305
|
+
say_info "if you've got a Last.fm account, use `ayadn -NP --lastfm` (short: `-l`)"
|
306
306
|
end
|
307
307
|
end
|
308
308
|
|
@@ -312,8 +312,8 @@ module Ayadn
|
|
312
312
|
|
313
313
|
def not_authorized
|
314
314
|
say do
|
315
|
-
|
316
|
-
|
315
|
+
say_error "no user authorized"
|
316
|
+
say_info "please run `ayadn -auth` to authorize an account"
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
@@ -323,8 +323,8 @@ module Ayadn
|
|
323
323
|
|
324
324
|
def redirecting
|
325
325
|
say do
|
326
|
-
|
327
|
-
|
326
|
+
say_info "post is a repost"
|
327
|
+
say_yellow :action, "redirecting"
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
@@ -346,17 +346,17 @@ module Ayadn
|
|
346
346
|
|
347
347
|
def auto
|
348
348
|
say do
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
349
|
+
say_info "entering the auto posting mode"
|
350
|
+
say_info "each line you type (each time you hit ENTER) is automatically posted to ADN"
|
351
|
+
say_info "at any moment, starting now, hit CTRL+C to exit"
|
352
|
+
say_yellow :info, "AUTO POSTING MODE ACTIVATED"
|
353
353
|
end
|
354
354
|
end
|
355
355
|
|
356
356
|
def threshold
|
357
357
|
say do
|
358
|
-
|
359
|
-
|
358
|
+
say_error "please enter a value between 0.1 and 3.5"
|
359
|
+
say_green :info, "example: 2.1"
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
@@ -392,8 +392,8 @@ module Ayadn
|
|
392
392
|
diff = size - max_size
|
393
393
|
diff > 1 ? pl = "s" : pl = ""
|
394
394
|
say do
|
395
|
-
|
396
|
-
|
395
|
+
say_error "text too long"
|
396
|
+
say_green :info, "#{max_size} max: #{diff} character#{pl} to remove"
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -407,8 +407,8 @@ module Ayadn
|
|
407
407
|
|
408
408
|
def no_curl
|
409
409
|
say do
|
410
|
-
|
411
|
-
|
410
|
+
say_error "Ayadn needs 'curl' to upload files"
|
411
|
+
say_yellow :next, "please install 'curl' (or check that it's properly declared in your $PATH)"
|
412
412
|
end
|
413
413
|
end
|
414
414
|
|
@@ -434,8 +434,8 @@ module Ayadn
|
|
434
434
|
|
435
435
|
def no_force(target)
|
436
436
|
say do
|
437
|
-
|
438
|
-
|
437
|
+
say_error "'#{target}' can't be displayed (could be muted, blocked, in the Blacklist, etc)"
|
438
|
+
say_info "please use option '--force' ('-f') to try and display this content anyway"
|
439
439
|
end
|
440
440
|
end
|
441
441
|
|
@@ -449,15 +449,15 @@ module Ayadn
|
|
449
449
|
|
450
450
|
def no_username
|
451
451
|
say do
|
452
|
-
|
453
|
-
|
452
|
+
say_error "Ayadn couldn't get your username"
|
453
|
+
say_yellow :next, "please try again"
|
454
454
|
end
|
455
455
|
end
|
456
456
|
|
457
|
-
def
|
457
|
+
def deprecated_ayadn
|
458
458
|
say do
|
459
|
-
|
460
|
-
|
459
|
+
say_red :deprecated, "Ayadn 1.x user data detected"
|
460
|
+
say_yellow :warning, "please delete your old ayadn folder then try again"
|
461
461
|
end
|
462
462
|
end
|
463
463
|
|
@@ -471,7 +471,7 @@ module Ayadn
|
|
471
471
|
|
472
472
|
def yourpost
|
473
473
|
# info("", "Your post:")
|
474
|
-
|
474
|
+
say_center "Your post:"
|
475
475
|
end
|
476
476
|
|
477
477
|
def post_info
|
@@ -483,7 +483,7 @@ module Ayadn
|
|
483
483
|
end
|
484
484
|
|
485
485
|
def unread_from_channel(channel_id)
|
486
|
-
|
486
|
+
say_info "unread message(s) from channel #{channel_id}"
|
487
487
|
puts "\n\n"
|
488
488
|
end
|
489
489
|
|
@@ -500,9 +500,9 @@ module Ayadn
|
|
500
500
|
end
|
501
501
|
def version
|
502
502
|
puts ayadn()
|
503
|
-
|
504
|
-
|
505
|
-
|
503
|
+
say_green :version, "#{VERSION}"
|
504
|
+
say_yellow :changelog, "https://github.com/ericdke/na/blob/master/CHANGELOG.md"
|
505
|
+
say_yellow :docs, "https://github.com/ericdke/na/tree/master/doc"
|
506
506
|
puts "\n\n"
|
507
507
|
end
|
508
508
|
|
@@ -524,19 +524,19 @@ module Ayadn
|
|
524
524
|
|
525
525
|
def itunes_store_track(store)
|
526
526
|
puts "\n"
|
527
|
-
|
527
|
+
say_cyan :next, "Ayadn will use these elements to insert album artwork and a link"
|
528
528
|
end
|
529
529
|
|
530
530
|
def server_error(bool)
|
531
531
|
if bool == true
|
532
532
|
say do
|
533
|
-
|
534
|
-
|
533
|
+
say_error "Ayadn couldn't get the JSON reponse"
|
534
|
+
say_yellow :next, "trying again in 10 seconds"
|
535
535
|
end
|
536
536
|
else
|
537
537
|
say do
|
538
|
-
|
539
|
-
|
538
|
+
say_error "Ayadn couldn't get the JSON reponse"
|
539
|
+
say_yellow :status, "Current command canceled after one retry"
|
540
540
|
end
|
541
541
|
end
|
542
542
|
end
|
@@ -545,7 +545,7 @@ module Ayadn
|
|
545
545
|
|
546
546
|
def info(status, message, color = nil)
|
547
547
|
if color.nil?
|
548
|
-
lamb = lambda {
|
548
|
+
lamb = lambda { say_nocolor(status.to_sym, message.to_s) }
|
549
549
|
else
|
550
550
|
lamb = lambda { @thor.say_status(status.to_sym, message.to_s, color.to_sym) }
|
551
551
|
end
|
@@ -560,5 +560,57 @@ module Ayadn
|
|
560
560
|
puts "\n"
|
561
561
|
end
|
562
562
|
|
563
|
+
def say_center(message)
|
564
|
+
@thor.say_status nil, message
|
565
|
+
end
|
566
|
+
|
567
|
+
def say_nocolor(tag, message)
|
568
|
+
@thor.say_status tag, message
|
569
|
+
end
|
570
|
+
|
571
|
+
def say_error(message)
|
572
|
+
@thor.say_status :error, message, :red
|
573
|
+
end
|
574
|
+
|
575
|
+
def say_info(message)
|
576
|
+
@thor.say_status :info, message, :cyan
|
577
|
+
end
|
578
|
+
|
579
|
+
def say_green(tag, message)
|
580
|
+
@thor.say_status tag, message, :green
|
581
|
+
end
|
582
|
+
|
583
|
+
def say_blue(tag, message)
|
584
|
+
@thor.say_status tag, message, :blue
|
585
|
+
end
|
586
|
+
|
587
|
+
def say_cyan(tag, message)
|
588
|
+
@thor.say_status tag, message, :cyan
|
589
|
+
end
|
590
|
+
|
591
|
+
def say_red(tag, message)
|
592
|
+
@thor.say_status tag, message, :red
|
593
|
+
end
|
594
|
+
|
595
|
+
def say_yellow(tag, message)
|
596
|
+
@thor.say_status tag, message, :yellow
|
597
|
+
end
|
598
|
+
|
599
|
+
def say_end
|
600
|
+
say { say_green :done, "end of diagnostics" }
|
601
|
+
end
|
602
|
+
|
603
|
+
def say_header(message)
|
604
|
+
say { say_info message }
|
605
|
+
end
|
606
|
+
|
607
|
+
def say_text(text)
|
608
|
+
say { puts text }
|
609
|
+
end
|
610
|
+
|
611
|
+
def say_trace(message)
|
612
|
+
@thor.say_status :message, message, :yell
|
613
|
+
end
|
614
|
+
|
563
615
|
end
|
564
616
|
end
|
data/lib/ayadn/stream.rb
CHANGED
data/lib/ayadn/switch.rb
CHANGED
@@ -3,13 +3,20 @@ module Ayadn
|
|
3
3
|
class Switch
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@
|
7
|
-
|
8
|
-
|
6
|
+
@status = Status.new
|
7
|
+
begin
|
8
|
+
@acc_db = Amalgalite::Database.new(Dir.home + "/ayadn/accounts.sqlite")
|
9
|
+
rescue Amalgalite::SQLite3::Error => e
|
10
|
+
@status.not_authorized
|
11
|
+
exit
|
12
|
+
rescue => e
|
13
|
+
raise e
|
14
|
+
end
|
9
15
|
end
|
10
16
|
|
11
17
|
def list
|
12
18
|
puts "\n"
|
19
|
+
please if @acc_db.blank?
|
13
20
|
accounts = Databases.all_accounts(@acc_db)
|
14
21
|
please if accounts.empty?
|
15
22
|
accounts.sort_by! { |acc| acc[0] }
|
@@ -39,28 +46,29 @@ module Ayadn
|
|
39
46
|
exit
|
40
47
|
end
|
41
48
|
username = Workers.new.remove_arobase_if_present([user.first])[0]
|
49
|
+
please if @acc_db.blank?
|
42
50
|
accounts = Databases.all_accounts(@acc_db)
|
43
51
|
please if accounts.empty?
|
44
52
|
active = accounts.select { |acc| acc[4] == 1 }[0]
|
45
53
|
active_user = active[0]
|
46
54
|
if username == active_user
|
47
55
|
@status.say do
|
48
|
-
@
|
56
|
+
@status.say_green :done, "already authorized with username @#{username}"
|
49
57
|
end
|
50
58
|
exit
|
51
59
|
end
|
52
60
|
flag = accounts.select { |acc| acc[0] == username }.flatten
|
53
61
|
if flag.empty?
|
54
62
|
@status.say do
|
55
|
-
@
|
56
|
-
@
|
63
|
+
@status.say_error "@#{username} isn't in the database"
|
64
|
+
@status.say_yellow :next, "please run `ayadn -auth` to authorize this account"
|
57
65
|
end
|
58
66
|
exit
|
59
67
|
else
|
60
68
|
@status.say do
|
61
|
-
@
|
69
|
+
@status.say_cyan :switching, "from @#{active_user} to @#{username}"
|
62
70
|
Databases.set_active_account(@acc_db, username)
|
63
|
-
@
|
71
|
+
@status.say_green :done, "@#{username} is now the active account"
|
64
72
|
end
|
65
73
|
exit
|
66
74
|
end
|
@@ -69,9 +77,8 @@ module Ayadn
|
|
69
77
|
private
|
70
78
|
|
71
79
|
def please
|
72
|
-
@status.
|
73
|
-
|
74
|
-
end
|
80
|
+
@status.say_info "please run `ayadn -auth` to authorize an account"
|
81
|
+
puts
|
75
82
|
exit
|
76
83
|
end
|
77
84
|
end
|