From e058b204f45f274936babd10206a64850baaa12d Mon Sep 17 00:00:00 2001 From: erwanlr Date: Fri, 22 Mar 2013 18:37:28 +0100 Subject: [PATCH] Typhoeus::Response hack moved to hacks.rb, ignoring hacks.rb in coverage --- .simplecov | 1 + lib/common/hacks.rb | 16 ++++++++++++++++ lib/common/models/wp_item/existable.rb | 16 ---------------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.simplecov b/.simplecov index 332d946b..ff565dd6 100644 --- a/.simplecov +++ b/.simplecov @@ -3,4 +3,5 @@ SimpleCov.start do add_filter "_helper.rb" add_filter "environment.rb" add_filter "_plugin.rb" + add_filter "hacks.rb" end diff --git a/lib/common/hacks.rb b/lib/common/hacks.rb index f4e069bc..7ec15ed1 100644 --- a/lib/common/hacks.rb +++ b/lib/common/hacks.rb @@ -26,6 +26,22 @@ if RUBY_VERSION < '1.9' end end +# This is used in WpItem::Existable +module Typhoeus + class Response + + # Compare the body hash to error_404_hash and homepage_hash + # returns true if they are different, false otherwise + # + # @return [ Boolean ] + def has_valid_hash?(error_404_hash, homepage_hash) + body_hash = Digest::MD5.hexdigest(self.body) + + body_hash != error_404_hash && body_hash != homepage_hash + end + end +end + # Override for puts to enable logging def puts(o = '') # remove color for logging diff --git a/lib/common/models/wp_item/existable.rb b/lib/common/models/wp_item/existable.rb index 5384b63d..14cd7117 100755 --- a/lib/common/models/wp_item/existable.rb +++ b/lib/common/models/wp_item/existable.rb @@ -1,21 +1,5 @@ # encoding: UTF-8 -# HACK -module Typhoeus - class Response - - # Compare the body hash to error_404_hash and homepage_hash - # returns true if they are different, false otherwise - # - # @return [ Boolean ] - def has_valid_hash?(error_404_hash, homepage_hash) - body_hash = Digest::MD5.hexdigest(self.body) - - body_hash != error_404_hash && body_hash != homepage_hash - end - end -end - class WpItem module Existable