diff --git a/lib/legitbot.rb b/lib/legitbot.rb index 9624d52..9ba713c 100644 --- a/lib/legitbot.rb +++ b/lib/legitbot.rb @@ -1,7 +1,7 @@ require 'resolv' require_relative 'legitbot/legitbot' -require_relative 'legitbot/match' +require_relative 'legitbot/botmatch' require_relative 'legitbot/google' require_relative 'legitbot/yandex' require_relative 'legitbot/bing' diff --git a/lib/legitbot/baidu.rb b/lib/legitbot/baidu.rb index 3c00a7a..2c599cc 100644 --- a/lib/legitbot/baidu.rb +++ b/lib/legitbot/baidu.rb @@ -1,6 +1,6 @@ module Legitbot # http://help.baidu.com/question?prod_en=master&class=498&id=1000973 - class Baidu < Match + class Baidu < BotMatch ValidDomains = ["baidu.com.", "baidu.jp."] def initialize(ip, resolver_config = nil) diff --git a/lib/legitbot/bing.rb b/lib/legitbot/bing.rb index 0fc4662..5c2b592 100644 --- a/lib/legitbot/bing.rb +++ b/lib/legitbot/bing.rb @@ -1,6 +1,6 @@ module Legitbot # https://blogs.bing.com/webmaster/2012/08/31/how-to-verify-that-bingbot-is-bingbot/ - class Bing < Match + class Bing < BotMatch ValidDomains = ["search.msn.com."] def initialize(ip, resolver_config = nil) diff --git a/lib/legitbot/Match.rb b/lib/legitbot/botmatch.rb similarity index 98% rename from lib/legitbot/Match.rb rename to lib/legitbot/botmatch.rb index ec23f12..395c0e4 100644 --- a/lib/legitbot/Match.rb +++ b/lib/legitbot/botmatch.rb @@ -3,7 +3,7 @@ module Legitbot # Represents a bot instance match. Typical methods are # +valid?+, +fake?+ and +detected_as+ # - class Match + class BotMatch def initialize(ip, resolver_config = nil) @dns = Resolv::DNS.new(resolver_config) @ip = ip diff --git a/lib/legitbot/duckduckgo.rb b/lib/legitbot/duckduckgo.rb index c57caab..a8ec7c9 100644 --- a/lib/legitbot/duckduckgo.rb +++ b/lib/legitbot/duckduckgo.rb @@ -1,6 +1,6 @@ module Legitbot # https://duckduckgo.com/duckduckbot - class DuckDuckGo < Match + class DuckDuckGo < BotMatch ValidIPs = %w(72.94.249.34 72.94.249.35 72.94.249.36 72.94.249.37 72.94.249.38) def initialize(ip, resolver_config = nil) diff --git a/lib/legitbot/google.rb b/lib/legitbot/google.rb index ef42c63..b54a3dc 100644 --- a/lib/legitbot/google.rb +++ b/lib/legitbot/google.rb @@ -4,7 +4,7 @@ module Legitbot # https://support.google.com/webmasters/answer/1061943 # https://support.google.com/webmasters/answer/80553 - class Google < Match + class Google < BotMatch ValidDomains = ["google.com.", "googlebot.com."] def initialize(ip, resolver_config = nil) diff --git a/lib/legitbot/yandex.rb b/lib/legitbot/yandex.rb index db1b0ec..8eec880 100644 --- a/lib/legitbot/yandex.rb +++ b/lib/legitbot/yandex.rb @@ -1,7 +1,7 @@ module Legitbot # https://yandex.com/support/webmaster/robot-workings/check-yandex-robots.xml - class Yandex < Match + class Yandex < BotMatch ValidDomains = ["yandex.ru.", "yandex.net.", "yandex.com."] def initialize(ip, resolver_config = nil) diff --git a/test/match_test.rb b/test/botmatch_test.rb similarity index 73% rename from test/match_test.rb rename to test/botmatch_test.rb index d6c42be..cba13af 100644 --- a/test/match_test.rb +++ b/test/botmatch_test.rb @@ -1,19 +1,19 @@ require 'minitest/autorun' require 'legitbot' -class MatchTest < Minitest::Test +class BotMatchTest < Minitest::Test def test_reverse_name - match = Legitbot::Match.new "66.249.78.6" + match = Legitbot::BotMatch.new "66.249.78.6" assert_equal "crawl-66-249-78-6.googlebot.com", match.reverse_name end def test_reverse_ip - match = Legitbot::Match.new "66.249.78.6" + match = Legitbot::BotMatch.new "66.249.78.6" assert_equal "66.249.78.6", match.reversed_ip end def test_reverse_resolves - match = Legitbot::Match.new "66.249.78.6" + match = Legitbot::BotMatch.new "66.249.78.6" assert_equal true, match.reverse_resolves? end