crawler_detect 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/crawler_detect/version.rb +1 -1
- data/lib/rack/crawler_detect.rb +9 -9
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97314f6307705c0123a25333340c7509138cd8991eb1946a52d66c99df08ddac
|
4
|
+
data.tar.gz: 135a67b8502348dde1c86dd0e17e894dceafeb61b8acb74487f3d6e1832954e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f6dc6ef31c358ce0a5e94469971021ba5a1e1c8ba9133836e839053e4717c32d94a0c3dbb2d828ada989192f70e85d899ad87b9b56f0e26ef33f08d45209112
|
7
|
+
data.tar.gz: ed8cf6c609fe3b7e3102d9a6d60358d9e80e19f69b1a8c4b218bc929642991389e40fecf48c5de69975d76373b1406b7a89e1c9ec5ccdf2dd727710eb3363524
|
data/lib/rack/crawler_detect.rb
CHANGED
@@ -16,25 +16,25 @@ module Rack
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def call(env)
|
19
|
-
|
20
|
-
|
21
|
-
@app.call(@env)
|
19
|
+
set_env_variables!(env)
|
20
|
+
@app.call(env)
|
22
21
|
end
|
23
22
|
|
24
23
|
private
|
25
24
|
|
26
|
-
def set_env_variables!
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
def set_env_variables!(env)
|
26
|
+
ua = user_agent(env)
|
27
|
+
return unless ua
|
28
|
+
detector = ::CrawlerDetect::Detector.new(ua)
|
29
|
+
env["rack.crawler_detect"] = {
|
30
30
|
is_crawler: detector.is_crawler?,
|
31
31
|
crawler_name: detector.crawler_name,
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
35
|
-
def user_agent
|
35
|
+
def user_agent(env)
|
36
36
|
user_agent_headers.map do |header|
|
37
|
-
|
37
|
+
env[header]
|
38
38
|
end.compact.join(" ")
|
39
39
|
end
|
40
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crawler_detect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kozlov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -165,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
|
-
|
169
|
-
rubygems_version: 2.7.6
|
168
|
+
rubygems_version: 3.0.6
|
170
169
|
signing_key:
|
171
170
|
specification_version: 4
|
172
171
|
summary: 'CrawlerDetect: detect bots/crawlers'
|