lib/ayadn/check.rb in ayadn-3.0 vs lib/ayadn/check.rb in ayadn-4.0

- old
+ new

@@ -1,62 +1,70 @@ # encoding: utf-8 module Ayadn class Check - def initialize - @status = Status.new + def initialize status = Status.new + @status = status end - def same_username(stream) - stream['data']['username'] == Settings.config[:identity][:username] + def same_username(user_object) + user_object.username == Settings.config.identity.username end def auto_save_muted(list) - FileOps.save_muted_list(list) if Settings.options[:backup][:lists] + FileOps.save_muted_list(list) if Settings.options.backup.lists end def auto_save_followers(list) - FileOps.save_followers_list(list) if Settings.options[:backup][:lists] + FileOps.save_followers_list(list) if Settings.options.backup.lists end def auto_save_followings(list) - FileOps.save_followings_list(list) if Settings.options[:backup][:lists] + FileOps.save_followings_list(list) if Settings.options.backup.lists end def no_username username if username.empty? @status.error_missing_username exit end end def no_data stream, target - if stream['data'].empty? + if stream.posts.empty? Errors.warn "In action/#{target}: no data" @status.empty_list exit end end def no_new_posts stream, options, title - if options[:new] == true + if options[:new] unless Databases.has_new?(stream, title) @status.no_new_posts exit end end end def no_post stream, post_id - if stream['meta']['code'] == 404 + if stream.meta.code == 404 @status.post_404(post_id) Errors.info("Impossible to find #{post_id}") exit end end + def no_details stream, post_id + if stream["meta"]["code"] == 404 + @status.post_404(post_id) + Errors.info("Impossible to find #{post_id}") + exit + end + end + def bad_post_id post_id unless post_id.is_integer? @status.error_missing_post_id exit end @@ -70,10 +78,10 @@ end end end def no_user stream, username - if stream['meta']['code'] == 404 + if stream.meta.code == 404 @status.user_404(username) Errors.info("User #{username} doesn't exist") exit end end