ayadn 1.8.2 → 2.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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/CHANGELOG.md +73 -52
  4. data/README.md +17 -3
  5. data/ayadn.gemspec +3 -4
  6. data/doc/01-index.md +6 -5
  7. data/doc/02-install.md +23 -1
  8. data/doc/03-first-steps.md +22 -28
  9. data/doc/04-options.md +1 -1
  10. data/doc/05-streams.md +29 -9
  11. data/doc/06-post.md +13 -5
  12. data/doc/07-actions.md +63 -1
  13. data/doc/08-listings.md +112 -4
  14. data/doc/09-accounts.md +17 -3
  15. data/doc/10-nicerank.md +5 -5
  16. data/doc/11-blacklist.md +8 -14
  17. data/doc/12-alias.md +1 -13
  18. data/doc/14-set.md +8 -110
  19. data/doc/15-nowplaying.md +16 -4
  20. data/doc/18-contact.md +14 -13
  21. data/doc/19-examples.md +2 -0
  22. data/lib/ayadn/action.rb +322 -183
  23. data/lib/ayadn/alias.rb +17 -45
  24. data/lib/ayadn/annotations.rb +1 -1
  25. data/lib/ayadn/api.rb +7 -8
  26. data/lib/ayadn/app.rb +99 -12
  27. data/lib/ayadn/authorize.rb +92 -57
  28. data/lib/ayadn/blacklist.rb +52 -62
  29. data/lib/ayadn/check.rb +81 -74
  30. data/lib/ayadn/cnx.rb +77 -26
  31. data/lib/ayadn/databases.rb +890 -105
  32. data/lib/ayadn/debug.rb +30 -89
  33. data/lib/ayadn/descriptions.rb +876 -329
  34. data/lib/ayadn/endpoints.rb +2 -2
  35. data/lib/ayadn/errors.rb +9 -9
  36. data/lib/ayadn/extend.rb +8 -1
  37. data/lib/ayadn/fileops.rb +10 -8
  38. data/lib/ayadn/mark.rb +79 -56
  39. data/lib/ayadn/migration.rb +427 -0
  40. data/lib/ayadn/nicerank.rb +74 -72
  41. data/lib/ayadn/nowplaying.rb +123 -60
  42. data/lib/ayadn/nowwatching.rb +26 -10
  43. data/lib/ayadn/pinboard.rb +12 -7
  44. data/lib/ayadn/post.rb +40 -37
  45. data/lib/ayadn/profile.rb +5 -2
  46. data/lib/ayadn/scroll.rb +20 -5
  47. data/lib/ayadn/search.rb +30 -22
  48. data/lib/ayadn/set.rb +146 -50
  49. data/lib/ayadn/settings.rb +66 -67
  50. data/lib/ayadn/status.rb +459 -234
  51. data/lib/ayadn/stream.rb +80 -46
  52. data/lib/ayadn/switch.rb +51 -47
  53. data/lib/ayadn/tvshow.rb +47 -15
  54. data/lib/ayadn/version.rb +1 -1
  55. data/lib/ayadn/view.rb +119 -60
  56. data/lib/ayadn/workers.rb +144 -92
  57. data/lib/ayadn.rb +7 -8
  58. data/spec/mock/ayadn/accounts.sqlite +0 -0
  59. data/spec/mock/ayadn.sqlite +0 -0
  60. data/spec/unit/annotations_spec.rb +12 -13
  61. data/spec/unit/api_spec.rb +3 -4
  62. data/spec/unit/blacklistworkers_spec.rb +18 -23
  63. data/spec/unit/databases_spec.rb +51 -36
  64. data/spec/unit/endpoints_spec.rb +5 -2
  65. data/spec/unit/extend_spec.rb +24 -0
  66. data/spec/unit/nicerank_spec.rb +13 -13
  67. data/spec/unit/post_spec.rb +47 -36
  68. data/spec/unit/set_spec.rb +67 -96
  69. data/spec/unit/view_spec.rb +12 -6
  70. data/spec/unit/workers_spec.rb +38 -12
  71. data/tags +1285 -0
  72. metadata +29 -39
  73. data/spec/mock/aliases.db +0 -0
  74. data/spec/mock/blacklist.db +0 -0
  75. data/spec/mock/bookmarks.db +0 -0
  76. data/spec/mock/channels.db +0 -0
  77. data/spec/mock/index.db +0 -0
  78. data/spec/mock/nicerank.db +0 -0
  79. data/spec/mock/pagination.db +0 -0
  80. data/spec/mock/users.db +0 -0
  81. data/spec/unit/status_spec.rb +0 -9
data/lib/ayadn/status.rb CHANGED
@@ -1,325 +1,550 @@
1
1
  # encoding: utf-8
2
2
  module Ayadn
3
3
  class Status
4
- def self.done
5
- "\nDone.\n".color(:green)
6
- end
7
- def self.downloaded(name)
8
- "\nFile downloaded in #{Settings.config[:paths][:downloads]}/#{name}\n".color(:green)
9
- end
10
- def self.links_saved(name)
11
- "\nLinks exported to file #{Settings.config[:paths][:lists]}/#{name}\n".color(:green)
12
- end
13
- def self.downloading
14
- "Downloading from ADN...\n\n".inverse
15
- end
16
- def self.uploading files
17
- files.length > 1 ? pl = "s" : pl = ""
18
- "\nUploading file#{pl} to ADN...".color(:cyan)
19
- end
20
- def self.posting
21
- "Posting to ADN...\n\n".inverse
4
+
5
+ def initialize
6
+ @thor = Thor::Shell::Color.new
7
+ end
8
+
9
+ def done
10
+ info("done", "", "green")
11
+ end
12
+
13
+ def canceled
14
+ say do
15
+ puts "\n"
16
+ @thor.say_status :canceled, "", :red
17
+ end
22
18
  end
23
- def self.deleting_post(post_id)
24
- "\nDeleting post #{post_id}\n".inverse
19
+
20
+ def downloaded(name)
21
+ info("downloaded", "#{Settings.config[:paths][:downloads]}/#{name}", "green")
25
22
  end
26
- def self.deleting_message(message_id)
27
- "\nDeleting message #{message_id}\n".inverse
23
+
24
+ def links_saved(name)
25
+ info("done", "links exported to file #{Settings.config[:paths][:lists]}/#{name}", "green")
28
26
  end
29
- def self.unfollowing(username)
30
- "\nUnfollowing #{username}".inverse
27
+
28
+ def downloading
29
+ info("connected", "downloading from ADN", "yellow")
31
30
  end
32
- def self.following(username)
33
- "\nFollowing #{username}".inverse
31
+
32
+ def posting
33
+ info("connected", "posting to ADN", "yellow")
34
34
  end
35
- def self.unmuting(username)
36
- "\nUnmuting #{username}".inverse
35
+
36
+ def deleting_post(post_id)
37
+ @thor.say_status :deleting, "post #{post_id}", :yellow
37
38
  end
38
- def self.muting(username)
39
- "\nMuting #{username}".inverse
39
+
40
+ def deleting_message(message_id)
41
+ @thor.say_status :deleting, "message #{message_id}", :yellow
40
42
  end
41
- def self.unblocking(username)
42
- "\nUnblocking #{username}".inverse
43
+
44
+ def unfollowing(username)
45
+ @thor.say_status :unfollowing, username, :yellow
43
46
  end
44
- def self.blocking(username)
45
- "\nBlocking #{username}".inverse
47
+
48
+ def following(username)
49
+ @thor.say_status :following, username, :yellow
46
50
  end
47
- def self.unreposting(post_id)
48
- "\nUnreposting #{post_id}".inverse
51
+
52
+ def unmuting(username)
53
+ @thor.say_status :unmuting, username, :yellow
49
54
  end
50
- def self.reposting(post_id)
51
- "\nReposting #{post_id}".inverse
55
+
56
+ def muting(username)
57
+ @thor.say_status :muting, username, :yellow
52
58
  end
53
- def self.unstarring(post_id)
54
- "\nUnstarring #{post_id}".inverse
59
+
60
+ def unblocking(username)
61
+ @thor.say_status :unblocking, username, :yellow
55
62
  end
56
- def self.starring(post_id)
57
- "\nStarring #{post_id}".inverse
63
+
64
+ def blocking(username)
65
+ @thor.say_status :blocking, username, :yellow
58
66
  end
59
- def self.not_deleted(post_id)
60
- "\nCould not delete post #{post_id} (post isn't yours, or is already deleted)\n".color(:red)
67
+
68
+ def unreposting(post_id)
69
+ @thor.say_status :unreposting, "post #{post_id}", :yellow
61
70
  end
62
- def self.not_starred(post_id)
63
- "\nCould not star post #{post_id} (post doesn't exist, or is already starred)\n".color(:red)
71
+
72
+ def reposting(post_id)
73
+ @thor.say_status :reposting, "post #{post_id}", :yellow
64
74
  end
65
- def self.not_unreposted(post_id)
66
- "\nCould not unrepost post #{post_id} (post isn't yours, isn't a repost, or has been deleted)\n".color(:red)
75
+
76
+ def unstarring(post_id)
77
+ @thor.say_status :unstarring, "post #{post_id}", :yellow
67
78
  end
68
- def self.not_reposted(post_id)
69
- "\nCould not repost post #{post_id} (post has been deleted?)\n".color(:red)
79
+
80
+ def starring(post_id)
81
+ @thor.say_status :starring, "post #{post_id}", :yellow
70
82
  end
71
- def self.not_unstarred(post_id)
72
- "\nCould not unstar post #{post_id} (post isn't yours, isn't starred, or has been deleted)\n".color(:red)
83
+
84
+ def not_deleted(post_id)
85
+ info("error", "could not delete post #{post_id} (post isn't yours, or is already deleted)", "red")
73
86
  end
74
- def self.not_unfollowed(post_id)
75
- "\nCould not unfollow user #{username} (doesn't exist, or wasn't already followed)\n".color(:red)
87
+
88
+ def not_deleted_m(post_id)
89
+ info("error", "could not delete post #{post_id} (post isn't yours, or is already deleted)", "red")
76
90
  end
77
- def self.not_followed(post_id)
78
- "\nCould not follow user #{username} (doesn't exist, or you already follow)\n".color(:red)
91
+
92
+ def not_starred(post_id)
93
+ info("error", "could not star post #{post_id} (post doesn't exist, or is already starred)", "red")
79
94
  end
80
- def self.not_unmuted(post_id)
81
- "\nCould not unmute user #{username} (doesn't exist, or wasn't already muted)\n".color(:red)
95
+
96
+ def not_unreposted(post_id)
97
+ info("error", "could not unrepost post #{post_id} (post isn't yours, isn't a repost, or has been deleted)", "red")
82
98
  end
83
- def self.not_muted(post_id)
84
- "\nCould not mute user #{username} (doesn't exist, or is already muted)\n".color(:red)
99
+
100
+ def not_reposted(post_id)
101
+ info("error", "could not repost post #{post_id} (post has been deleted?)", "red")
85
102
  end
86
- def self.not_unblocked(post_id)
87
- "\nCould not unblock user #{username} (doesn't exist, or wasn't already blocked)\n".color(:red)
103
+
104
+ def not_unstarred(post_id)
105
+ info("error", "could not unstar post #{post_id} (post isn't yours, isn't starred, or has been deleted)", "red")
88
106
  end
89
- def self.not_blocked(post_id)
90
- "\nCould not block user #{username} (doesn't exist, or is already blocked)\n".color(:red)
107
+
108
+ def not_unfollowed(username)
109
+ info("error", "could not unfollow user #{username} (doesn't exist, or wasn't already followed)", "red")
91
110
  end
92
- def self.deleted(post_id)
93
- "\nPost #{post_id} has been deleted.\n".color(:green)
111
+
112
+ def not_followed(username)
113
+ info("error", "could not follow user #{username} (doesn't exist, or you already follow)", "red")
94
114
  end
95
- def self.deleted_m(message_id)
96
- "\nMessage #{message_id} has been deleted.\n".color(:green)
115
+
116
+ def not_unmuted(username)
117
+ info("error", "could not unmute user #{username} (doesn't exist, or wasn't already muted)", "red")
97
118
  end
98
- def self.starred(post_id)
99
- "\nPost #{post_id} has been starred.\n".color(:green)
119
+
120
+ def not_muted(username)
121
+ info("error", "could not mute user #{username} (doesn't exist, or is already muted)", "red")
100
122
  end
101
- def self.unreposted(post_id)
102
- "\nPost #{post_id} has been unreposted.\n".color(:green)
123
+
124
+ def not_unblocked(username)
125
+ info("error", "could not unblock user #{username} (doesn't exist, or wasn't already blocked)", "red")
103
126
  end
104
- def self.reposted(post_id)
105
- "\nPost #{post_id} has been reposted.\n".color(:green)
127
+
128
+ def not_blocked(username)
129
+ info("error", "could not block user #{username} (doesn't exist, or is already blocked)", "red")
106
130
  end
107
- def self.unstarred(post_id)
108
- "\nPost #{post_id} has been unstarred.\n".color(:green)
131
+
132
+ def deleted(post_id)
133
+ info("deleted", "post #{post_id}", "green")
109
134
  end
110
- def self.unfollowed(username)
111
- "\nUser #{username} has been unfollowed.\n".color(:green)
135
+
136
+ def deleted_m(message_id)
137
+ info("deleted", "message #{message_id}", "green")
112
138
  end
113
- def self.followed(username)
114
- "\nUser #{username} has been followed.\n".color(:green)
139
+
140
+ def starred(post_id)
141
+ info("starred", "post #{post_id}", "green")
115
142
  end
116
- def self.unmuted(username)
117
- "\nUser #{username} has been unmuted.\n".color(:green)
143
+
144
+ def unreposted(post_id)
145
+ info("unreposted", "post #{post_id}", "green")
118
146
  end
119
- def self.muted(username)
120
- "\nUser #{username} has been muted.\n".color(:green)
147
+
148
+ def reposted(post_id)
149
+ info("reposted", "post #{post_id}", "green")
121
150
  end
122
- def self.unblocked(username)
123
- "\nUser #{username} has been unblocked.\n".color(:green)
151
+
152
+ def unstarred(post_id)
153
+ info("unstarred", "post #{post_id}", "green")
124
154
  end
125
- def self.blocked(username)
126
- "\nUser #{username} has been blocked.\n".color(:green)
155
+
156
+ def already_starred
157
+ info("ok", "already starred", "green")
127
158
  end
128
- def self.error_missing_title
129
- "\nYou have to specify (part of) a movie title.\n".color(:red)
159
+
160
+ def already_reposted
161
+ info("ok", "already reposted", "green")
130
162
  end
131
- def self.error_missing_username
132
- "\nYou have to specify a username.\n".color(:red)
163
+
164
+ def unfollowed(username)
165
+ info("unfollowed", username, "green")
133
166
  end
134
- def self.error_missing_post_id
135
- "\nYou have to specify a post id.\n".color(:red)
167
+
168
+ def followed(username)
169
+ info("followed", username, "green")
136
170
  end
137
- def self.error_missing_message_id
138
- "\nYou have to specify a message id.\n".color(:red)
171
+
172
+ def unmuted(username)
173
+ info("unmuted", username, "green")
139
174
  end
140
- def self.error_missing_channel_id
141
- "\nYou have to specify a channel id.\n".color(:red)
175
+
176
+ def muted(username)
177
+ info("muted", username, "green")
142
178
  end
143
- def self.error_missing_hashtag
144
- "\nYou have to specify one or more hashtag(s).\n".color(:red)
179
+
180
+ def unblocked(username)
181
+ info("unblocked", username, "green")
145
182
  end
146
- def self.error_missing_parameters
147
- "\nYou have to submit valid items. See 'ayadn -sg' for a list of valid parameters and values.\n".color(:red)
183
+
184
+ def blocked(username)
185
+ info("blocked", username, "green")
148
186
  end
149
- def self.empty_list
150
- "\n\nThe list is empty.\n\n".color(:red)
187
+
188
+ def error_missing_title
189
+ info("error", "please specify (part of) a movie title", "red")
151
190
  end
152
- def self.not_found
153
- "\n\n404 NOT FOUND - Object does not exist or has been deleted\n\n"
191
+
192
+ def error_missing_username
193
+ info("error", "please specify a username", "red")
154
194
  end
155
- def self.stopped
156
- "\n\nStopped.".color(:red)
195
+
196
+ def error_missing_post_id
197
+ info("error", "please specify a post id", "red")
157
198
  end
158
- def self.writing
159
- "\nPosting as ".color(:cyan) + "#{Settings.config[:identity][:handle]}".color(:green) + ".".color(:cyan)
199
+
200
+ def error_missing_message_id
201
+ info("error", "please specify a message id", "red")
160
202
  end
161
- def self.yourpost
162
- "Your post:\n".color(:cyan)
203
+
204
+ def error_missing_channel_id
205
+ info("error", "please specify a channel id", "red")
163
206
  end
164
- def self.yourmessage username = nil
165
- if username.nil?
166
- "Your message:\n\n".color(:cyan)
167
- else
168
- "Your message to ".color(:cyan) + username.color(:green) + ":\n\n".color(:cyan)
207
+
208
+ def error_missing_parameters
209
+ say do
210
+ @thor.say_status :error, "please submit valid items", :red
211
+ @thor.say_status :info, "see `ayadn -sg` for a list of valid parameters and values", :cyan
169
212
  end
170
213
  end
171
- def self.message_from(username)
172
- "\nMessage from ".color(:cyan) + "#{Settings.config[:identity][:handle]} ".color(:green) + "to ".color(:cyan) + "#{username[0]}".color(:yellow) + ".".color(:cyan)
173
- end
174
- def self.replying_to(post_id)
175
- "\nReplying to post #{post_id}...\n".color(:green)
176
- end
177
- def self.readline
178
- "\nType your text. ".color(:cyan) + "[CTRL+D] ".color(:green) + "to validate, ".color(:cyan) + "[CTRL+C] ".color(:red) + "to cancel.\n".color(:cyan)
179
- end
180
- # def self.classic
181
- # "\nType your text. ".color(:cyan) + "[ENTER] ".color(:green) + "to validate, ".color(:cyan) + "[CTRL+C] ".color(:red) + "to cancel.\n\n".color(:cyan)
182
- # end
183
- def self.reply
184
- "\n#{Settings.config[:post_max_length]} ".color(:yellow) + "characters maximum.\n"
185
- end
186
- def self.post
187
- "\n#{Settings.config[:post_max_length]} ".color(:yellow) + "characters maximum.\n"
188
- end
189
- def self.message
190
- "\n#{Settings.config[:message_max_length]} ".color(:yellow) + "characters maximum.\n"
191
- end
192
- # def self.method_missing(meth, args)
193
- # "\nThe command '#{meth} #{args}' doesn't exist.\n".color(:red)
194
- # end
195
- def self.valid_colors(colors_list)
196
- "\nThe valid colors are: #{colors_list}\n".color(:cyan)
197
- end
198
- def self.not_mutable
199
- "\nThis parameter is not modifiable for the time being, sorry.\n".color(:red)
200
- end
201
- def self.must_be_integer
202
- "\nThis paramater must be an integer between 1 and 200.\n".color(:red)
203
- end
204
- def self.no_new_posts
205
- "\nNo new posts since your last visit.\n\n".color(:cyan)
206
- end
207
- def self.no_new_messages
208
- "\n No new messages since your last visit.\n".color(:cyan)
209
- end
210
- def self.type_and_target_missing
211
- "\nYou have to submit a TYPE (mention, hashtag, client name) and a TARGET (a @username, a hashtag, a client name)\n\n".color(:red)
212
- end
213
- def self.wrong_arguments
214
- "\nYou have to submit valid arguments.\n\n".color(:red)
214
+
215
+ def empty_list
216
+ info("info", "the list is empty", "yellow")
217
+ end
218
+
219
+ def writing
220
+ puts "\n"
221
+ @thor.say_status "author", "#{Settings.config[:identity][:handle]}", "cyan"
222
+ puts "\n"
223
+ end
224
+
225
+ def yourmessage username = nil
226
+ if username.nil?
227
+ @thor.say_status "", "Your message:"
228
+ else
229
+ @thor.say_status "", "Your message to #{username}:"
230
+ end
231
+ puts "\n\n"
232
+ end
233
+
234
+ def message_from(username)
235
+ puts "\n"
236
+ @thor.say_status "from", "#{Settings.config[:identity][:handle]}", "yellow"
237
+ @thor.say_status "to", "#{username[0]}", "yellow"
238
+ end
239
+
240
+ def replying_to(post_id)
241
+ puts "\n"
242
+ @thor.say_status "replying", "to post #{post_id}", "yellow"
243
+ end
244
+
245
+ def readline
246
+ say do
247
+ @thor.say_status :next, "type your text", :cyan
248
+ @thor.say_status :ok, "[CTRL+D] to validate", :cyan
249
+ @thor.say_status :cancel, "[CTRL+C] to cancel", :cyan
250
+ end
215
251
  end
216
- def self.no_pin_creds
217
- "\nAyadn couldn't find your Pinboard credentials.\n".color(:red)
252
+
253
+ def reply
254
+ @thor.say_status "max", "#{Settings.config[:post_max_length]} characters", "cyan"
218
255
  end
219
- def self.pin_creds_saved
220
- "\n\nCredentials successfully encoded and saved in database.\n\n".color(:green)
256
+
257
+ def post
258
+ @thor.say_status "max", "#{Settings.config[:post_max_length]} characters", "cyan"
221
259
  end
222
- def self.saving_pin
223
- "\nSaving post text and links to Pinboard...\n\n".color(:yellow)
260
+
261
+ def message
262
+ @thor.say_status "max", "#{Settings.config[:message_max_length]} characters", "cyan"
224
263
  end
225
- def self.error_only_osx
226
- "\nThis feature only works with iTunes by default. If you've got a Last.fm account, add the option:\n\n`ayadn -np --lastfm` (short: `-l`).\n\n".color(:red)
264
+
265
+ def valid_colors(colors_list)
266
+ @thor.say_status "info", "valid colors:", "cyan"
267
+ say { puts colors_list }
227
268
  end
228
- def self.empty_fields
229
- "\nCanceled: couldn't get enough information (empty field).\n\n".color(:red)
269
+
270
+ def must_be_integer
271
+ info("error", "this paramater must be an integer between 1 and 200", "red")
230
272
  end
231
- def self.canceled
232
- "\n\nCanceled.\n\n".color(:cyan)
273
+
274
+ def no_new_posts
275
+ info("info", "no new posts since your last visit with Ayadn", "cyan")
233
276
  end
234
- def self.not_authorized
235
- "\nYou need to authorize Ayadn before using it.\n\nPlease run 'ayadn -auth' :)\n\n".color(:red)
277
+
278
+ def no_new_messages
279
+ info("info", "no new messages", "cyan")
236
280
  end
237
- def self.wtf
238
- "\nSomething wrong happened. :(\n\n".color(:red)
281
+
282
+ def type_and_target_missing
283
+ info("error", "please submit a TYPE ('mention', 'hashtag', 'client') and a TARGET (a @username, a hashtag, a client name)", "red")
239
284
  end
240
- def self.redirecting
241
- "\nPost is a repost. Redirecting...\n".color(:cyan)
285
+
286
+ def wrong_arguments
287
+ info("error", "invalid arguments", "red")
242
288
  end
243
- def self.nobody_reposted
244
- "\nNobody reposted this post.\n\n".color(:red)
289
+
290
+ def no_pin_creds
291
+ info("error", "Ayadn couldn't find your Pinboard credentials", "red")
245
292
  end
246
- def self.nobody_starred
247
- "\nNobody starred this post.\n\n".color(:red)
293
+
294
+ def pin_creds_saved
295
+ info("done", "credentials successfully encoded and saved", "green")
248
296
  end
249
- def self.not_your_repost
250
- "\nThis post isn't one of your reposts.\n\n".color(:red)
297
+
298
+ def saving_pin
299
+ info("saving", "post text and links to Pinboard", "yellow")
251
300
  end
252
- def self.not_your_starred
253
- "\nThis isn't one of your starred posts.\n\n".color(:red)
301
+
302
+ def error_only_osx
303
+ say do
304
+ @thor.say_status :error, "this feature only works with iTunes by default", :red
305
+ @thor.say_status :info, "if you've got a Last.fm account, use `ayadn -NP --lastfm` (short: `-l`)", :cyan
306
+ end
254
307
  end
255
- def self.auto
256
- view = "\nEntering the auto posting mode.\n\n".color(:cyan)
257
- view << "In this mode, each line you type (each time you hit ENTER!) is automatically posted to ADN.\n\n".color(:cyan)
258
- view << "At any moment, starting now, hit CTRL+C to exit.\n\n".color(:yellow)
259
- view << "\n\t--AUTO POSTING MODE ACTIVATED--\n\n".color(:red)
308
+
309
+ def empty_fields
310
+ info("canceled", "couldn't get enough information (empty field)", "red")
260
311
  end
261
- def self.reducing db
262
- "\nPlease wait while Ayadn is pruning and compacting the #{db} database...\n".color(:cyan)
312
+
313
+ def not_authorized
314
+ say do
315
+ @thor.say_status :error, "no user authorized", :red
316
+ @thor.say_status :auth, "please run `ayadn -auth` to authorize an account", :yellow
317
+ end
263
318
  end
264
- def self.cache_range
265
- "\nPlease enter a number of hours between 1 and 168.\n\n".color(:red)
319
+
320
+ def wtf
321
+ info("error", "an unkown error happened", "red")
266
322
  end
267
- def self.threshold
268
- "\nPlease enter a value between 0.1 and 3.5, example: 2.1\n\n".color(:red)
323
+
324
+ def redirecting
325
+ say do
326
+ @thor.say_status :info, "post is a repost", :cyan
327
+ @thor.say_status :action, "redirecting", :yellow
328
+ end
269
329
  end
270
- def self.must_be_in_index
271
- "\nNumber must be in the range of the indexed posts.\n".color(:red)
330
+
331
+ def nobody_reposted
332
+ info("error", "nobody reposted this post", "red")
333
+ end
334
+
335
+ def nobody_starred
336
+ info("error", "nobody starred this post", "red")
337
+ end
338
+
339
+ def not_your_repost
340
+ info("error", "this post isn't one of your reposts", "red")
341
+ end
342
+
343
+ def not_your_starred
344
+ info("error", "this isn't one of your starred posts", "red")
345
+ end
346
+
347
+ def auto
348
+ say do
349
+ @thor.say_status :info, "entering the auto posting mode", :cyan
350
+ @thor.say_status :info, "each line you type (each time you hit ENTER) is automatically posted to ADN", :cyan
351
+ @thor.say_status :info, "at any moment, starting now, hit CTRL+C to exit", :cyan
352
+ @thor.say_status :info, "AUTO POSTING MODE ACTIVATED", :yellow
353
+ end
272
354
  end
273
- def self.user_404 username
274
- "\nUser #{username} doesn't exist. It could be a deleted account.\n".color(:red)
355
+
356
+ def threshold
357
+ say do
358
+ @thor.say_status :error, "please enter a value between 0.1 and 3.5", :red
359
+ @thor.say_status :info, "example: 2.1", :green
360
+ end
275
361
  end
276
- def self.post_404(post_id)
277
- "\nImpossible to find #{post_id}. This post may have been deleted.\n".color(:red)
362
+
363
+ def must_be_in_index
364
+ info("error", "number must be in the range of the indexed posts", "red")
365
+ end
366
+
367
+ def user_404(username)
368
+ info("error", "user #{username} doesn't exist (it could be a deleted account)", "red")
369
+ end
370
+
371
+ def post_404(post_id)
372
+ info("error", "impossible to find #{post_id} (it may have been deleted)", "red")
373
+ end
374
+
375
+ def no_alias
376
+ info("error", "this alias doesn't exist", "red")
377
+ end
378
+
379
+ def no_itunes
380
+ info("canceled", "unable to get info from iTunes", "red")
381
+ end
382
+
383
+ def pin_username
384
+ info("please", "enter your Pinboard username (CTRL+C to cancel)", "green")
385
+ end
386
+
387
+ def pin_password
388
+ info("please", "enter your Pinboard password (invisible, CTRL+C to cancel)", "green")
389
+ end
390
+
391
+ def too_long(size, max_size)
392
+ diff = size - max_size
393
+ diff > 1 ? pl = "s" : pl = ""
394
+ say do
395
+ @thor.say_status :error, "text too long", :red
396
+ @thor.say_status :info, "#{max_size} max: #{diff} character#{pl} to remove", :green
397
+ end
278
398
  end
279
- def self.no_alias
280
- "\nThis alias doesn't exist.\n\n".color(:red)
399
+
400
+ def no_text
401
+ info("error", "no text", "red")
281
402
  end
282
- def self.no_itunes
283
- "\nCanceled: unable to get info from iTunes.\n".color(:red)
403
+
404
+ def bad_path
405
+ info("error", "couldn't upload this file (path seems wrong)", "red")
284
406
  end
285
- def self.pin_username
286
- "Please enter your Pinboard username (CTRL+C to cancel): ".color(:green)
407
+
408
+ def no_curl
409
+ say do
410
+ @thor.say_status :error, "Ayadn needs 'curl' to upload files", :red
411
+ @thor.say_status :next, "please install 'curl' (or check that it's properly declared in your $PATH)", :yellow
412
+ end
287
413
  end
288
- def self.pin_password
289
- "\nPlease enter your Pinboard password (invisible, CTRL+C to cancel): ".color(:green)
414
+
415
+ def itunes_store
416
+ info("connexion", "fetching informations from the iTunes Store", "green")
290
417
  end
291
- def self.too_long size, max_size
292
- "\n\nCanceled: too long. #{max_size} max, #{size - max_size} characters to remove.\n\n\n".color(:red)
418
+
419
+ def fetching_from(source)
420
+ info("connexion", "fetching informations from #{source}", "green")
293
421
  end
294
- def self.no_text
295
- "\n\nYou should provide some text.\n\n".color(:red)
422
+
423
+ def no_movie
424
+ info("error", "sorry, can't find this movie", "red")
296
425
  end
297
- def self.bad_path
298
- "\n\nCouldn't upload this file (path seems wrong).\n\n".color(:red)
426
+
427
+ def no_show
428
+ info("error", "sorry, can't find this show", "red")
299
429
  end
300
- def self.no_curl
301
- "\n\nAyadn needs 'curl' to upload files. Please install 'curl' (or check that it's properly declared in your $PATH).\n\n".color(:red)
430
+
431
+ def no_show_infos
432
+ info("error", "sorry, can't find informations about this show", "red")
302
433
  end
303
- def self.itunes_store
304
- "Fetching informations from the Itunes Store...\n".color(:green)
434
+
435
+ def no_force(target)
436
+ say do
437
+ @thor.say_status :error, "'#{target}' can't be displayed (could be muted, blocked, in the Blacklist, etc)", :red
438
+ @thor.say_status :info, "please use option '--force' ('-f') to try and display this content anyway", :cyan
439
+ end
305
440
  end
306
- def self.fetching_from source
307
- "\nFetching informations from #{source}...\n".color(:green)
441
+
442
+ def profile_options
443
+ info("error", "please specify what to update or delete: --bio, --name, --blog, --twitter or --web", "red")
308
444
  end
309
- def self.no_movie
310
- "\nSorry, can't find this movie.\n".color(:blue)
445
+
446
+ def one_username
447
+ info("error", "please specify only one username", "red")
311
448
  end
312
- def self.no_show
313
- "\nSorry, can't find this show.\n".color(:blue)
449
+
450
+ def no_username
451
+ say do
452
+ @thor.say_status :error, "Ayadn couldn't get your username", :red
453
+ @thor.say_status :next, "please try again", :yellow
454
+ end
314
455
  end
315
- def self.no_show_infos
316
- "\nSorry, can't find informations about this show.\n".color(:blue)
456
+
457
+ def has_to_migrate
458
+ say do
459
+ @thor.say_status :upgrade, "Ayadn 1.x user data detected", :red
460
+ @thor.say_status :migrate, "please run `ayadn migrate` to upgrade your account", :yellow
461
+ end
317
462
  end
318
- def self.no_force target
319
- "\n'#{target}' can't be displayed (could be muted, blocked, in the Blacklist, etc). Use option '--force' ('-f') to try and display this content anyway.\n\n".color(:blue)
463
+
464
+ def updating_profile
465
+ info("updating", "profile", "yellow")
466
+ end
467
+
468
+ def to_be_posted
469
+ info("", "Your post:")
470
+ end
471
+
472
+ def yourpost
473
+ # info("", "Your post:")
474
+ @thor.say_status nil, "Your post:"
475
+ end
476
+
477
+ def post_info
478
+ info("info", "post", "cyan")
479
+ end
480
+
481
+ def repost_info
482
+ info("info", "repost of", "cyan")
483
+ end
484
+
485
+ def unread_from_channel(channel_id)
486
+ @thor.say_status :info, "unread message(s) from channel #{channel_id}", :cyan
487
+ puts "\n\n"
488
+ end
489
+
490
+ def ayadn
491
+ <<-AYADN
492
+
493
+ \t\t _____ __ __ _____ ____ _____
494
+ \t\t | _ | | | _ | \\| | |
495
+ \t\t | |_ _| | | | | | |
496
+ \t\t |__|__| |_| |__|__|____/|_|___|
497
+
498
+
499
+ AYADN
500
+ end
501
+ def version
502
+ puts ayadn()
503
+ @thor.say_status :version, "#{VERSION}", :green
504
+ @thor.say_status :changelog, "https://github.com/ericdke/na/blob/master/CHANGELOG.md", :yellow
505
+ @thor.say_status :docs, "https://github.com/ericdke/na/tree/master/doc", :yellow
506
+ puts "\n\n"
507
+ end
508
+
509
+ def ask_clear_databases
510
+ info("question", "are you sure you want to erase all the content of your aliases database? [y/N]", "red")
511
+ end
512
+
513
+ def ask_clear_blacklist
514
+ info("question", "are you sure you want to erase all the content of your blacklist database? [y/N]", "red")
515
+ end
516
+
517
+ def ask_clear_bookmarks
518
+ info("question", "are you sure you want to erase all the content of your bookmarks database? [y/N]", "red")
519
+ end
520
+
521
+ def ok?
522
+ info("confirm", "is it ok? [y/N]", "yellow")
523
+ end
524
+
525
+ def itunes_store_track(store)
526
+ puts "\n"
527
+ @thor.say_status "next", "Ayadn will use these elements to insert album artwork and a link", :cyan
528
+ end
529
+
530
+ ##---
531
+
532
+ def info(status, message, color = nil)
533
+ if color.nil?
534
+ lamb = lambda { @thor.say_status(status.to_sym, message.to_s) }
535
+ else
536
+ lamb = lambda { @thor.say_status(status.to_sym, message.to_s, color.to_sym) }
537
+ end
538
+ puts "\n"
539
+ lamb.call
540
+ puts "\n"
320
541
  end
321
- def self.profile_options
322
- "\n\nYou have to specify what to update or delete: --bio, --name, --blog, --twitter or --web.\n\n".color(:red)
542
+
543
+ def say() # expects a block
544
+ puts "\n"
545
+ yield
546
+ puts "\n"
323
547
  end
548
+
324
549
  end
325
550
  end