Skip to content

Commit

Permalink
s/Match/BotMatch/
Browse files Browse the repository at this point in the history
  • Loading branch information
alaz committed Dec 20, 2016
1 parent a287b47 commit 15ccad4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/legitbot.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion lib/legitbot/baidu.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/legitbot/bing.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/legitbot/Match.rb → lib/legitbot/botmatch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/legitbot/duckduckgo.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/legitbot/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/legitbot/yandex.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
8 changes: 4 additions & 4 deletions test/match_test.rb → test/botmatch_test.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 15ccad4

Please sign in to comment.