is_crawler 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +6 -2
- data/lib/is_crawler/version.rb +1 -1
- data/lib/is_crawler.rb +6 -0
- data/spec/is_crawler_spec.rb +10 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
You can use the `is_crawler?` method with just a user agent string to determine if
|
21
|
+
You can use the `is_crawler?` method with just a user agent string to determine if it matches *any* crawler, like so:
|
22
22
|
|
23
23
|
class MyController < ActionController::Base
|
24
24
|
include IsCrawler
|
@@ -35,7 +35,11 @@ You can use the `is_crawler?` method with just a user agent string to determine
|
|
35
35
|
|
36
36
|
is_crawler?("Some User Agent/1.0", :facebook, :google)
|
37
37
|
|
38
|
-
|
38
|
+
...or you can use the method sugar:
|
39
|
+
|
40
|
+
is_facebook_crawler? request.env["HTTP_USER_AGENT"]
|
41
|
+
|
42
|
+
...and you can add to the list of detectables:
|
39
43
|
|
40
44
|
Crawler::CUSTOM << Crawler.new(:custom_crawler_name, "string that is always present in the crawler's user agent")
|
41
45
|
|
data/lib/is_crawler/version.rb
CHANGED
data/lib/is_crawler.rb
CHANGED
@@ -9,4 +9,10 @@ module IsCrawler
|
|
9
9
|
Crawler.matches_any?(requesting_user_agent)
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
Crawler.all.each do |crawler|
|
14
|
+
define_method "is_#{crawler.name.to_s}_crawler?" do |requesting_user_agent|
|
15
|
+
is_crawler? requesting_user_agent, crawler.name
|
16
|
+
end
|
17
|
+
end
|
12
18
|
end
|
data/spec/is_crawler_spec.rb
CHANGED
@@ -36,6 +36,16 @@ describe IsCrawler do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
Crawler.all.each do |crawler|
|
41
|
+
describe '#is_{some}_crawler' do
|
42
|
+
let(:crawler) { Crawler.all.first }
|
43
|
+
subject { Test.new.send("is_#{crawler.name}_crawler?", user_agent) }
|
44
|
+
it "provides method sugar for each crawler" do
|
45
|
+
subject.should == false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
51
|
class Test; include IsCrawler; end
|
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -77,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
segments:
|
79
79
|
- 0
|
80
|
-
hash:
|
80
|
+
hash: 1790514343912662541
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
83
83
|
requirements:
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
segments:
|
88
88
|
- 0
|
89
|
-
hash:
|
89
|
+
hash: 1790514343912662541
|
90
90
|
requirements: []
|
91
91
|
rubyforge_project:
|
92
92
|
rubygems_version: 1.8.24
|