class Ayadn::Status

Attributes

thor[R]

Public Class Methods

new(thor = Thor::Shell::Color.new) click to toggle source
# File lib/ayadn/status.rb, line 7
def initialize thor = Thor::Shell::Color.new
  @thor = thor
end

Public Instance Methods

already_reposted() click to toggle source
# File lib/ayadn/status.rb, line 174
def already_reposted
  info("ok", "already reposted", "green")
end
already_starred() click to toggle source
# File lib/ayadn/status.rb, line 170
def already_starred
  info("ok", "already starred", "green")
end
ask_clear_blacklist() click to toggle source
# File lib/ayadn/status.rb, line 511
def ask_clear_blacklist
  info("question", "are you sure you want to erase all the content of your blacklist database? [y/N]", "red")
end
ask_clear_bookmarks() click to toggle source
# File lib/ayadn/status.rb, line 515
def ask_clear_bookmarks
  info("question", "are you sure you want to erase all the content of your bookmarks database? [y/N]", "red")
end
ask_clear_databases() click to toggle source
# File lib/ayadn/status.rb, line 507
def ask_clear_databases
  info("question", "are you sure you want to erase all the content of your aliases database? [y/N]", "red")
end
auto() click to toggle source
# File lib/ayadn/status.rb, line 357
def auto
  say do
    say_info "entering the auto posting mode"
    say_info "each line you type (each time you hit ENTER) is automatically posted to ADN"
    say_info "at any moment, starting now, hit CTRL+C to exit"
    say_yellow :info, "AUTO POSTING MODE ACTIVATED"
  end
end
ayadn() click to toggle source
# File lib/ayadn/status.rb, line 488
    def ayadn
      <<-AYADN

\t\t     _____ __ __ _____ ____  _____
\t\t    |  _  |  |  |  _  |    \\|   | |
\t\t    |     |_   _|     |  |  | | | |
\t\t    |__|__| |_| |__|__|____/|_|___|


      AYADN
    end
bad_path() click to toggle source
# File lib/ayadn/status.rb, line 414
def bad_path
  info("error", "couldn't upload this file (path seems wrong)", "red")
end
blocked(username) click to toggle source
# File lib/ayadn/status.rb, line 198
def blocked(username)
  info("blocked", username, "green")
end
blocking(username) click to toggle source
# File lib/ayadn/status.rb, line 66
def blocking(username)
  say_yellow :blocking, username
end
canceled() click to toggle source
# File lib/ayadn/status.rb, line 15
def canceled
  say do
    puts "\n"
    say_red :canceled, ""
  end
end
deleted(post_id) click to toggle source
# File lib/ayadn/status.rb, line 146
def deleted(post_id)
  info("deleted", "post #{post_id}", "green")
end
deleted_m(message_id) click to toggle source
# File lib/ayadn/status.rb, line 150
def deleted_m(message_id)
  info("deleted", "message #{message_id}", "green")
end
deleting_message(message_id) click to toggle source
# File lib/ayadn/status.rb, line 42
def deleting_message(message_id)
  say_yellow :deleting, "message #{message_id}"
end
deleting_post(post_id) click to toggle source
# File lib/ayadn/status.rb, line 38
def deleting_post(post_id)
  say_yellow :deleting, "post #{post_id}"
end
deprecated_ayadn() click to toggle source
# File lib/ayadn/status.rb, line 455
def deprecated_ayadn
  say do
    say_red :deprecated, "Ayadn 1.x user data detected"
    say_yellow :warning,  "please delete your old ayadn folder then try again"
  end
end
done() click to toggle source
# File lib/ayadn/status.rb, line 11
def done
  info("done", "", "green")
end
downloaded(name) click to toggle source
# File lib/ayadn/status.rb, line 22
def downloaded(name)
  info("downloaded", "#{Settings.config.paths.downloads}/#{name}", "green")
end
downloading() click to toggle source
# File lib/ayadn/status.rb, line 30
def downloading
  info("connected", "downloading from ADN", "yellow")
end
empty_fields() click to toggle source
# File lib/ayadn/status.rb, line 319
def empty_fields
  info("canceled", "couldn't get enough information (empty field)", "red")
end
empty_list() click to toggle source
# File lib/ayadn/status.rb, line 225
def empty_list
  info("info", "the list is empty", "yellow")
end
error_missing_channel_id() click to toggle source
# File lib/ayadn/status.rb, line 214
def error_missing_channel_id
  info("error", "please specify a channel id", "red")
end
error_missing_message_id() click to toggle source
# File lib/ayadn/status.rb, line 210
def error_missing_message_id
  info("error", "please specify a message id", "red")
end
error_missing_parameters() click to toggle source
# File lib/ayadn/status.rb, line 218
def error_missing_parameters
  say do
    say_error "please submit valid items"
    say_info "see `ayadn -sg` for a list of valid parameters and values"
  end
end
error_missing_post_id() click to toggle source
# File lib/ayadn/status.rb, line 206
def error_missing_post_id
  info("error", "please specify a post id", "red")
end
error_missing_username() click to toggle source
# File lib/ayadn/status.rb, line 202
def error_missing_username
  info("error", "please specify a username", "red")
end
error_only_osx() click to toggle source
# File lib/ayadn/status.rb, line 312
def error_only_osx
  say do
    say_error "this feature only works with iTunes by default"
    say_info "if you've got a Last.fm account, use `ayadn -NP --lastfm` (short: `-l`)"
  end
end
fetching_from(source) click to toggle source
# File lib/ayadn/status.rb, line 429
def fetching_from(source)
  info("connexion", "fetching informations from #{source}", "green")
end
followed(username) click to toggle source
# File lib/ayadn/status.rb, line 182
def followed(username)
  info("followed", username, "green")
end
following(username) click to toggle source
# File lib/ayadn/status.rb, line 50
def following(username)
  say_yellow :following, username
end
info(status, message, color = nil) click to toggle source

# File lib/ayadn/status.rb, line 544
def info(status, message, color = nil)
  if color.nil?
    lamb = lambda { say_nocolor(status.to_sym, message.to_s) }
  else
    lamb = lambda { @thor.say_status(status.to_sym, message.to_s, color.to_sym) }
  end
  puts "\n"
  lamb.call
  puts "\n"
end
itunes_store() click to toggle source
# File lib/ayadn/status.rb, line 425
def itunes_store
  info("connexion", "fetching informations from the iTunes Store", "green")
end
itunes_store_track(store) click to toggle source
# File lib/ayadn/status.rb, line 523
def itunes_store_track(store)
  puts "\n"
  say_cyan :next, "Ayadn will use these elements to insert album artwork and a link"
end
message() click to toggle source
# File lib/ayadn/status.rb, line 271
def message
  say_cyan :max, "#{Settings.config.message_max_length} characters"
end
message_from(username) click to toggle source
# File lib/ayadn/status.rb, line 244
def message_from(username)
  puts "\n"
  say_yellow :from, "#{Settings.config.identity.handle}"
  say_yellow :to, "#{username[0]}"
end
must_be_in_index() click to toggle source
# File lib/ayadn/status.rb, line 373
def must_be_in_index
  info("error", "number must be in the range of the indexed posts", "red")
end
must_be_integer() click to toggle source
# File lib/ayadn/status.rb, line 280
def must_be_integer
  info("error", "this paramater must be an integer between 1 and 200", "red")
end
muted(username) click to toggle source
# File lib/ayadn/status.rb, line 190
def muted(username)
  info("muted", username, "green")
end
muting(username) click to toggle source
# File lib/ayadn/status.rb, line 58
def muting(username)
  say_yellow :muting, username
end
no_alias() click to toggle source
# File lib/ayadn/status.rb, line 385
def no_alias
  info("error", "this alias doesn't exist", "red")
end
no_curl() click to toggle source
# File lib/ayadn/status.rb, line 418
def no_curl
  say do
    say_error "Ayadn needs 'curl' to upload files"
    say_yellow :next, "please install 'curl' (or check that it's properly declared in your $PATH)"
  end
end
no_force(target) click to toggle source
# File lib/ayadn/status.rb, line 433
def no_force(target)
  say do
    say_error "'#{target}' can't be displayed (could be muted, blocked, in the Blacklist, etc)"
    say_info "please use option '--force' ('-f') to try and display this content anyway"
  end
end
no_itunes() click to toggle source
# File lib/ayadn/status.rb, line 389
def no_itunes
  info("canceled", "unable to get info from iTunes", "red")
end
no_new_messages() click to toggle source
# File lib/ayadn/status.rb, line 288
def no_new_messages
  info("info", "no new messages", "cyan")
end
no_new_posts() click to toggle source
# File lib/ayadn/status.rb, line 284
def no_new_posts
  info("info", "no new posts since your last visit with Ayadn", "cyan")
end
no_pin_creds() click to toggle source
# File lib/ayadn/status.rb, line 300
def no_pin_creds
  info("error", "Ayadn couldn't find your Pinboard credentials", "red")
end
no_text() click to toggle source
# File lib/ayadn/status.rb, line 410
def no_text
  info("error", "no text", "red")
end
no_username() click to toggle source
# File lib/ayadn/status.rb, line 448
def no_username
  say do
    say_error "Ayadn couldn't get your username"
    say_yellow :next, "please try again"
  end
end
nobody_reposted() click to toggle source
# File lib/ayadn/status.rb, line 341
def nobody_reposted
  info("error", "nobody reposted this post", "red")
end
nobody_starred() click to toggle source
# File lib/ayadn/status.rb, line 345
def nobody_starred
  info("error", "nobody starred this post", "red")
end
not_authorized() click to toggle source
# File lib/ayadn/status.rb, line 323
def not_authorized
  say do
    say_error "no user authorized"
    say_info "please run `ayadn -auth` to authorize an account"
  end
end
not_blocked(username) click to toggle source
# File lib/ayadn/status.rb, line 142
def not_blocked(username)
  info("error", "could not block user #{username} (doesn't exist, or is already blocked)", "red")
end
not_deleted(post_id) click to toggle source
# File lib/ayadn/status.rb, line 98
def not_deleted(post_id)
  info("error", "could not delete post #{post_id} (post isn't yours, or is already deleted)", "red")
end
not_deleted_m(post_id) click to toggle source
# File lib/ayadn/status.rb, line 102
def not_deleted_m(post_id)
  info("error", "could not delete post #{post_id} (post isn't yours, or is already deleted)", "red")
end
not_followed(username) click to toggle source
# File lib/ayadn/status.rb, line 126
def not_followed(username)
  info("error", "could not follow user #{username} (doesn't exist, or you already follow)", "red")
end
not_muted(username) click to toggle source
# File lib/ayadn/status.rb, line 134
def not_muted(username)
  info("error", "could not mute user #{username} (doesn't exist, or is already muted)", "red")
end
not_reposted(post_id) click to toggle source
# File lib/ayadn/status.rb, line 114
def not_reposted(post_id)
  info("error", "could not repost post #{post_id} (post has been deleted?)", "red")
end
not_starred(post_id) click to toggle source
# File lib/ayadn/status.rb, line 106
def not_starred(post_id)
  info("error", "could not star post #{post_id} (post doesn't exist, or is already starred)", "red")
end
not_unblocked(username) click to toggle source
# File lib/ayadn/status.rb, line 138
def not_unblocked(username)
  info("error", "could not unblock user #{username} (doesn't exist, or wasn't already blocked)", "red")
end
not_unfollowed(username) click to toggle source
# File lib/ayadn/status.rb, line 122
def not_unfollowed(username)
  info("error", "could not unfollow user #{username} (doesn't exist, or wasn't already followed)", "red")
end
not_unmuted(username) click to toggle source
# File lib/ayadn/status.rb, line 130
def not_unmuted(username)
  info("error", "could not unmute user #{username} (doesn't exist, or wasn't already muted)", "red")
end
not_unreposted(post_id) click to toggle source
# File lib/ayadn/status.rb, line 110
def not_unreposted(post_id)
  info("error", "could not unrepost post #{post_id} (post isn't yours, isn't a repost, or has been deleted)", "red")
end
not_unstarred(post_id) click to toggle source
# File lib/ayadn/status.rb, line 118
def not_unstarred(post_id)
  info("error", "could not unstar post #{post_id} (post isn't yours, isn't starred, or has been deleted)", "red")
end
not_your_repost() click to toggle source
# File lib/ayadn/status.rb, line 349
def not_your_repost
  info("error", "this post isn't one of your reposts", "red")
end
not_your_starred() click to toggle source
# File lib/ayadn/status.rb, line 353
def not_your_starred
  info("error", "this isn't one of your starred posts", "red")
end
ok?() click to toggle source
# File lib/ayadn/status.rb, line 519
def ok?
  info("confirm", "is it ok? [y/N]", "yellow")
end
one_username() click to toggle source
# File lib/ayadn/status.rb, line 444
def one_username
  info("error", "please specify only one username", "red")
end
pin_creds_saved() click to toggle source
# File lib/ayadn/status.rb, line 304
def pin_creds_saved
  info("done", "credentials successfully encoded and saved", "green")
end
pin_password() click to toggle source
# File lib/ayadn/status.rb, line 397
def pin_password
  info("please", "enter your Pinboard password (invisible, CTRL+C to cancel)", "green")
end
pin_username() click to toggle source
# File lib/ayadn/status.rb, line 393
def pin_username
  info("please", "enter your Pinboard username (CTRL+C to cancel)", "green")
end
post() click to toggle source
# File lib/ayadn/status.rb, line 267
def post
  say_cyan :max, "#{Settings.config.post_max_length} characters"
end
post_404(post_id) click to toggle source
# File lib/ayadn/status.rb, line 381
def post_404(post_id)
  info("error", "impossible to find #{post_id} (it may have been deleted)", "red")
end
post_info() click to toggle source
# File lib/ayadn/status.rb, line 475
def post_info
  info("info", "post", "cyan")
end
posting() click to toggle source
# File lib/ayadn/status.rb, line 34
def posting
  info("connected", "posting to ADN", "yellow")
end
profile_options() click to toggle source
# File lib/ayadn/status.rb, line 440
def profile_options
  info("error", "please specify what to update or delete: --bio, --name, --blog, --twitter or --web", "red")
end
readline() click to toggle source
# File lib/ayadn/status.rb, line 255
def readline
  say do
    say_cyan :next, "type your text"
    say_cyan :ok, "[CTRL+D] to validate"
    say_cyan :cancel, "[CTRL+C] to cancel"
  end
end
redirecting() click to toggle source
# File lib/ayadn/status.rb, line 334
def redirecting
  say do
    say_info "post is a repost"
    say_yellow :action, "redirecting"
  end
end
reply() click to toggle source
# File lib/ayadn/status.rb, line 263
def reply
  say_cyan :max, "#{Settings.config.post_max_length} characters"
end
replying_to(post_id) click to toggle source
# File lib/ayadn/status.rb, line 250
def replying_to(post_id)
  puts "\n"
  say_yellow :replying, "to post #{post_id}"
end
repost_info() click to toggle source
# File lib/ayadn/status.rb, line 479
def repost_info
  info("info", "repost of", "cyan")
end
reposted(post_id) click to toggle source
# File lib/ayadn/status.rb, line 162
def reposted(post_id)
  info("reposted", "post #{post_id}", "green")
end
reposting(post_id) click to toggle source
# File lib/ayadn/status.rb, line 74
def reposting(post_id)
  say_yellow :reposting, "post #{post_id}"
end
saving_pin() click to toggle source
# File lib/ayadn/status.rb, line 308
def saving_pin
  info("saving", "post text and links to Pinboard", "yellow")
end
say() { || ... } click to toggle source
# File lib/ayadn/status.rb, line 555
def say() # expects a block
  puts "\n"
  yield
  puts "\n"
end
say_blue(tag, message) click to toggle source
# File lib/ayadn/status.rb, line 581
def say_blue(tag, message)
  @thor.say_status tag, message, :blue
end
say_center(message) click to toggle source
# File lib/ayadn/status.rb, line 561
def say_center(message)
  @thor.say_status nil, message
end
say_cyan(tag, message) click to toggle source
# File lib/ayadn/status.rb, line 585
def say_cyan(tag, message)
  @thor.say_status tag, message, :cyan
end
say_end() click to toggle source
# File lib/ayadn/status.rb, line 597
def say_end
  say { say_green :done, "end of diagnostics" }
end
say_error(message) click to toggle source
# File lib/ayadn/status.rb, line 569
def say_error(message)
  @thor.say_status :error, message, :red
end
say_green(tag, message) click to toggle source
# File lib/ayadn/status.rb, line 577
def say_green(tag, message)
  @thor.say_status tag, message, :green
end
say_header(message) click to toggle source
# File lib/ayadn/status.rb, line 601
def say_header(message)
  say { say_info message }
end
say_info(message) click to toggle source
# File lib/ayadn/status.rb, line 573
def say_info(message)
  @thor.say_status :info, message, :cyan
end
say_nocolor(tag, message) click to toggle source
# File lib/ayadn/status.rb, line 565
def say_nocolor(tag, message)
  @thor.say_status tag, message
end
say_red(tag, message) click to toggle source
# File lib/ayadn/status.rb, line 589
def say_red(tag, message)
  @thor.say_status tag, message, :red
end
say_text(text) click to toggle source
# File lib/ayadn/status.rb, line 605
def say_text(text)
  say { puts text }
end
say_trace(message) click to toggle source
# File lib/ayadn/status.rb, line 609
def say_trace(message)
  @thor.say_status :message, message, :yell
end
say_yellow(tag, message) click to toggle source
# File lib/ayadn/status.rb, line 593
def say_yellow(tag, message)
  @thor.say_status tag, message, :yellow
end
server_error(bool) click to toggle source
# File lib/ayadn/status.rb, line 528
def server_error(bool)
  if bool
    say do
      say_error "Ayadn couldn't get the JSON reponse"
      say_yellow :next, "trying again in 10 seconds"
    end
  else
    say do
      say_error "Ayadn couldn't get the JSON reponse"
      say_yellow :status, "Current command canceled after one retry"
    end
  end
end
starred(post_id) click to toggle source
# File lib/ayadn/status.rb, line 154
def starred(post_id)
  info("starred", "post #{post_id}", "green")
end
starring(post_id) click to toggle source
# File lib/ayadn/status.rb, line 82
def starring(post_id)
  say_yellow :starring, "post #{post_id}"
end
threshold() click to toggle source
# File lib/ayadn/status.rb, line 366
def threshold
  say do
    say_error "please enter a value between 0.1 and 3.5"
    say_green :info, "example: 2.1"
  end
end
to_be_posted() click to toggle source
# File lib/ayadn/status.rb, line 466
def to_be_posted
  info("", "Your post:")
end
too_long(size, max_size) click to toggle source
# File lib/ayadn/status.rb, line 401
def too_long(size, max_size)
  diff = size - max_size
  diff > 1 ? pl = "s" : pl = ""
  say do
    say_error "text too long"
    say_green :info, "#{max_size} max: #{diff} character#{pl} to remove"
  end
end
type_and_target_missing() click to toggle source
# File lib/ayadn/status.rb, line 292
def type_and_target_missing
  info("error", "please submit a TYPE ('mention', 'hashtag', 'client') and a TARGET (a @username, a hashtag, a client name)", "red")
end
unblocked(username) click to toggle source
# File lib/ayadn/status.rb, line 194
def unblocked(username)
  info("unblocked", username, "green")
end
unblocking(username) click to toggle source
# File lib/ayadn/status.rb, line 62
def unblocking(username)
  say_yellow :unblocking, username
end
unfollowed(username) click to toggle source
# File lib/ayadn/status.rb, line 178
def unfollowed(username)
  info("unfollowed", username, "green")
end
unfollowing(username) click to toggle source
# File lib/ayadn/status.rb, line 46
def unfollowing(username)
  say_yellow :unfollowing, username
end
unmuted(username) click to toggle source
# File lib/ayadn/status.rb, line 186
def unmuted(username)
  info("unmuted", username, "green")
end
unmuting(username) click to toggle source
# File lib/ayadn/status.rb, line 54
def unmuting(username)
  say_yellow :unmuting, username
end
unread_from_channel(channel_id) click to toggle source
# File lib/ayadn/status.rb, line 483
def unread_from_channel(channel_id)
  say_info "unread message(s) from channel #{channel_id}"
  puts "\n\n"
end
unreposted(post_id) click to toggle source
# File lib/ayadn/status.rb, line 158
def unreposted(post_id)
  info("unreposted", "post #{post_id}", "green")
end
unreposting(post_id) click to toggle source
# File lib/ayadn/status.rb, line 70
def unreposting(post_id)
  say_yellow :unreposting, "post #{post_id}"
end
unstarred(post_id) click to toggle source
# File lib/ayadn/status.rb, line 166
def unstarred(post_id)
  info("unstarred", "post #{post_id}", "green")
end
unstarring(post_id) click to toggle source
# File lib/ayadn/status.rb, line 78
def unstarring(post_id)
  say_yellow :unstarring, "post #{post_id}"
end
updating_profile() click to toggle source
# File lib/ayadn/status.rb, line 462
def updating_profile
  info("updating", "profile", "yellow")
end
user_404(username) click to toggle source
# File lib/ayadn/status.rb, line 377
def user_404(username)
  info("error", "user #{username} doesn't exist (it could be a deleted account)", "red")
end
valid_colors(colors_list) click to toggle source
# File lib/ayadn/status.rb, line 275
def valid_colors(colors_list)
  say_cyan :info, "valid colors:"
  say { puts colors_list }
end
version() click to toggle source
# File lib/ayadn/status.rb, line 499
def version
  puts ayadn()
  say_green :version, "#{VERSION}"
  say_yellow :changelog, "https://github.com/ericdke/na/blob/master/CHANGELOG.md"
  say_yellow :docs, "https://github.com/ericdke/na/tree/master/doc"
  puts "\n\n"
end
writing() click to toggle source
# File lib/ayadn/status.rb, line 229
def writing
  puts "\n"
  say_cyan :author, "#{Settings.config.identity.handle}"
  puts "\n"
end
wrong_arguments() click to toggle source
# File lib/ayadn/status.rb, line 296
def wrong_arguments
  info("error", "invalid arguments", "red")
end
wtf() click to toggle source
# File lib/ayadn/status.rb, line 330
def wtf
  info("error", "an unkown error happened", "red")
end
yourmessage(username = nil) click to toggle source
# File lib/ayadn/status.rb, line 235
def yourmessage username = nil
    if username.nil?
      say_center "Your message:"
    else
      say_center "Your message to #{username}:"
    end
    puts "\n\n"
end
yourpost() click to toggle source
# File lib/ayadn/status.rb, line 470
def yourpost
  # info("", "Your post:")
  say_center "Your post:"
end