lib/ayadn/scroll.rb in ayadn-1.2.5 vs lib/ayadn/scroll.rb in ayadn-1.2.6

- old
+ new

@@ -4,60 +4,41 @@ def initialize(api, view) @api = api @view = view @chars = %w{ | / - \\ } + @show_debug = Settings.options[:timeline][:show_debug] end - def method_missing(meth, options, niceranks = {}) + def method_missing(meth, options) case meth.to_s when 'trending', 'photos', 'checkins', 'replies', 'global', 'unified' - scroll_it(meth.to_s, options, niceranks) + scroll_it(meth.to_s, options) else super end end - def scroll_it(target, options, niceranks) + def scroll_it(target, options) options = check_raw(options) orig_target = target - - ###DEBUG - @iter = 0 - @adn = 1 - + @nr = NiceRank.new loop do begin stream = get(target, options) - ###DEBUG - @adn += 1 - - if options[:filter] == true + # if options[:filter] == true unless stream['data'].empty? - ###DEBUG - #niceranks = @api.get_niceranks stream - niceranks, @iter = @api.get_niceranks stream, @iter - ###DEBUG - if Settings.options[:timeline][:show_debug] == true - puts "@@@@@\nADN calls:\t#{@adn}\n".color(Settings.options[:colors][:debug]) - puts "NiceRank calls:\t#{@iter}".color(Settings.options[:colors][:debug]) - puts "@@@@@\n".color(Settings.options[:colors][:debug]) - end + niceranks = @nr.get_ranks stream else niceranks = {} end - else - niceranks = {} - end + # else + # niceranks = {} + # end - if Settings.options[:timeline][:show_debug] == true - puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug]) - puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug]) - puts "Target:\t\t#{target.inspect}\n".color(Settings.options[:colors][:debug]) - puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug]) - end + debug_stream(stream, options, target) if @show_debug == true target = "explore:#{target}" if explore?(target) show_if_new(stream, options, target, niceranks) target = orig_target if target =~ /explore/ options = save_then_return(stream, options) @@ -74,16 +55,11 @@ id = user['data']['id'] loop do begin stream = @api.get_mentions(username, options) - if Settings.options[:timeline][:show_debug] == true - puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug]) - puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug]) - puts "Target:\t\t#{username}\n".color(Settings.options[:colors][:debug]) - puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug]) - end + debug_stream(stream, options, username) if @show_debug == true show_if_new(stream, options, "mentions:#{id}") options = save_then_return(stream, options) countdown rescue Interrupt @@ -98,16 +74,11 @@ id = user['data']['id'] loop do begin stream = @api.get_posts(username, options) - if Settings.options[:timeline][:show_debug] == true - puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug]) - puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug]) - puts "Target:\t\t#{username}\n".color(Settings.options[:colors][:debug]) - puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug]) - end + debug_stream(stream, options, username) if @show_debug == true show_if_new(stream, options, "posts:#{id}") options = save_then_return(stream, options) countdown rescue Interrupt @@ -120,16 +91,11 @@ options = check_raw(options) loop do begin stream = @api.get_convo(post_id, options) - if Settings.options[:timeline][:show_debug] == true - puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug]) - puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug]) - puts "Target:\t\t#{post_id}\n".color(Settings.options[:colors][:debug]) - puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug]) - end + debug_stream(stream, options, post_id) if @show_debug == true show_if_new(stream, options, "replies:#{post_id}") options = save_then_return(stream, options) countdown rescue Interrupt @@ -142,16 +108,11 @@ options = check_raw(options) loop do begin stream = @api.get_messages(channel_id, options) - if Settings.options[:timeline][:show_debug] == true - puts "+++++\nStream meta:\t#{stream['meta']}\n".color(Settings.options[:colors][:debug]) - puts "Options:\t#{options.inspect}\n".color(Settings.options[:colors][:debug]) - puts "Target:\t\t#{channel_id}\n".color(Settings.options[:colors][:debug]) - puts "Posts:\t\t#{stream['data'].length}\n+++++\n".color(Settings.options[:colors][:debug]) - end + debug_stream(stream, options, channel_id) if @show_debug == true show_if_new(stream, options, "channel:#{channel_id}") options = save_then_return(stream, options) countdown rescue Interrupt @@ -159,9 +120,17 @@ end end end private + + def debug_stream stream, options, target + deb = "+++++\nStream meta:\t#{stream['meta']}\n\n" + deb << "Options:\t#{options.inspect}\n\n" + deb << "Target:\t\t#{target.inspect}\n\n" + deb << "Posts:\t\t#{stream['data'].length}\n+++++\n" + puts deb.color(Settings.options[:colors][:debug]) + end def countdown if Settings.options[:timeline][:show_spinner] == true waiting else