is_crawler 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/crawler.rb CHANGED
@@ -1,15 +1,30 @@
1
1
  class Crawler < Struct.new(:name, :ua_string)
2
- BING = Crawler.new(:bing, "bingbot/2.0")
3
- FACEBOOK = Crawler.new(:facebook, "facebookexternalhit/1.1")
4
- GOOGLE = Crawler.new(:google, "Googlebot/2.1")
5
- MSN = Crawler.new(:msn, "MSNBot")
6
- TWITTER = Crawler.new(:twitter, "Twitterbot")
7
- YAHOO = Crawler.new(:yahoo, "Yahoo! Slurp")
2
+ class << self
3
+ def all
4
+ [
5
+ Crawler.new(:addthis, "AddThis.com"),
6
+ Crawler.new(:alexa, "ia_archiver"),
7
+ Crawler.new(:archive_org, "archive.org_bot"),
8
+ Crawler.new(:bing, "bingbot"),
9
+ Crawler.new(:bitly, "bitlybot"),
10
+ Crawler.new(:exabot, "Exabot"),
11
+ Crawler.new(:facebook, "facebookexternalhit"),
12
+ Crawler.new(:flipboard, "FlipboardProxy"),
13
+ Crawler.new(:google, "Googlebot"),
14
+ Crawler.new(:google_web_preview, "Google Web Preview"),
15
+ Crawler.new(:msn, "MSNBot"),
16
+ Crawler.new(:openwebspider, "OpenWebSpider"),
17
+ Crawler.new(:technorati, "Technoratibot"),
18
+ Crawler.new(:twitter, "Twitterbot"),
19
+ Crawler.new(:yahoo, "Yahoo! Slurp"),
20
+ Crawler.new(:yahoo_jp, "Y!J"),
21
+ Crawler.new(:yandex, "Yandex")
22
+ ]
23
+ end
8
24
 
9
- ALL = [BING, FACEBOOK, GOOGLE, MSN, TWITTER, YAHOO]
10
-
11
- def self.matches_any? user_agent
12
- ALL.detect { |crawler| crawler.matches? user_agent } != nil
25
+ def matches_any? user_agent
26
+ all.detect { |crawler| crawler.matches? user_agent } != nil
27
+ end
13
28
  end
14
29
 
15
30
  def matches? user_agent
data/lib/is_crawler.rb CHANGED
@@ -12,6 +12,6 @@ module IsCrawler
12
12
  end
13
13
 
14
14
  def which_crawler requesting_user_agent
15
- Crawler::ALL.detect {|crawler| crawler.matches? requesting_user_agent }
15
+ Crawler.all.detect {|crawler| crawler.matches? requesting_user_agent }
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module IsCrawler
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -8,7 +8,7 @@ describe Crawler do
8
8
  end
9
9
 
10
10
  context 'When a known user agent is encountered' do
11
- Crawler::ALL.each do |crawler|
11
+ Crawler.all.each do |crawler|
12
12
  context "such as the #{crawler.name.to_s} bot" do
13
13
  let(:user_agent) { "#{crawler.ua_string}" }
14
14
  it { should be_true }
@@ -18,7 +18,7 @@ describe Crawler do
18
18
  end
19
19
 
20
20
  describe '#matches?' do
21
- Crawler::ALL.each do |crawler|
21
+ Crawler.all.each do |crawler|
22
22
  describe "Comparing #{crawler.name.to_s}'s known UA string" do
23
23
  it 'with a matching string' do
24
24
  crawler.matches?(crawler.ua_string).should == true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_crawler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
76
  version: '0'
77
77
  segments:
78
78
  - 0
79
- hash: 839210596183111383
79
+ hash: -2598137808850490808
80
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  version: '0'
86
86
  segments:
87
87
  - 0
88
- hash: 839210596183111383
88
+ hash: -2598137808850490808
89
89
  requirements: []
90
90
  rubyforge_project:
91
91
  rubygems_version: 1.8.24