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 +25 -10
- data/lib/is_crawler.rb +1 -1
- data/lib/is_crawler/version.rb +1 -1
- data/spec/lib/crawler_spec.rb +2 -2
- metadata +3 -3
data/lib/crawler.rb
CHANGED
@@ -1,15 +1,30 @@
|
|
1
1
|
class Crawler < Struct.new(:name, :ua_string)
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
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
data/lib/is_crawler/version.rb
CHANGED
data/spec/lib/crawler_spec.rb
CHANGED
@@ -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
|
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
|
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.
|
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:
|
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:
|
88
|
+
hash: -2598137808850490808
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.24
|