lib/ayadn/action.rb in ayadn-1.2.8 vs lib/ayadn/action.rb in ayadn-1.2.9

- old
+ new

@@ -458,11 +458,11 @@ end no_data('search') if stream['data'].empty? if options[:users] stream['data'].sort_by! {|obj| obj['counts']['followers']} stream['data'].each do |obj| - puts "----------\n\n\n" + puts @view.big_separator @view.show_userinfos(obj, nil) end elsif options[:channels] @view.show_channels stream, options else @@ -872,25 +872,22 @@ def nowplaying begin Databases.close_all abort(Status.error_only_osx) unless Settings.config[:platform] =~ /darwin/ itunes = get_track_infos - itunes.each do |el| - abort(Status.empty_fields) if el.length == 0 - end + itunes.each {|el| abort(Status.empty_fields) if el.length == 0} @view.clear_screen text_to_post = "#nowplaying\nTitle: ‘#{itunes.track}’\nArtist: #{itunes.artist}\nfrom ‘#{itunes.album}’" puts Status.writing show_nowplaying(text_to_post) unless STDIN.getch == ("y" || "Y") puts "\nCanceled.\n\n".color(:red) exit end puts "\n" - resp = Post.new.post([text_to_post]) puts Status.yourpost - @view.show_posted(resp) + @view.show_posted(Post.new.post([text_to_post])) rescue => e puts Status.wtf Errors.global_error("action/nowplaying", itunes, e) end end @@ -1080,17 +1077,17 @@ def meta_404(stream) stream['meta']['code'] == 404 end def user_404(username) - puts "\nUser #{username} doesn't exist. It could be a deleted account.\n".color(:red) + puts Status.user_404 username Errors.info("User #{username} doesn't exist") exit end def post_404(post_id) - puts "\nImpossible to find #{post_id}. This post may have been deleted.\n".color(:red) + puts Status.post_404 post_id Errors.info("Impossible to find #{post_id}") exit end def length_of_index @@ -1170,11 +1167,11 @@ unless channel_id.is_integer? orig = channel_id channel_id = Databases.get_channel_id(orig) if channel_id.nil? Errors.warn("Alias '#{orig}' doesn't exist.") - puts "\nThis alias doesn't exist.\n\n".color(:red) + puts Status.no_alias exit end end channel_id end @@ -1219,11 +1216,11 @@ end def get_track_infos track = `osascript -e 'tell application "iTunes"' -e 'set trackName to name of current track' -e 'return trackName' -e 'end tell'` if track.empty? - puts "\nCanceled: unable to get info from iTunes.\n".color(:red) + puts Status.no_itunes Errors.warn "Nowplaying canceled: unable to get info from iTunes." exit end album = `osascript -e 'tell application "iTunes"' -e 'set trackAlbum to album of current track' -e 'return trackAlbum' -e 'end tell'` artist = `osascript -e 'tell application "iTunes"' -e 'set trackArtist to artist of current track' -e 'return trackArtist' -e 'end tell'` @@ -1258,27 +1255,29 @@ def show_links(links) links.each {|l| puts "#{l}\n".color(Settings.options[:colors][:link])} end def view_all_hashtag_links(stream, hashtag) - links = links_from_posts(stream) @view.clear_screen puts "Links from posts containing hashtag '##{hashtag}': \n".color(:cyan) - show_links(links) + show_links(links_from_posts(stream)) end def view_all_search_links(stream, words) - links = links_from_posts(stream) @view.clear_screen puts "Links from posts containing word(s) '#{words}': \n".color(:cyan) - show_links(links) + show_links(links_from_posts(stream)) end def view_all_stars_links(stream) - links = links_from_posts(stream) @view.clear_screen puts "Links from your starred posts: \n".color(:cyan) - show_links(links) + show_links(links_from_posts(stream)) + end + + def self.quit msg + puts msg + exit end end end