isbot 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/isbot.gemspec +4 -4
- data/lib/isbot.rb +5 -0
- data/lib/parser.rb +1 -1
- data/tests/isbot_test.rb +9 -2
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d9d1d1bd8a2da54f66ee96a4e016eda9ea71c8d5
|
|
4
|
+
data.tar.gz: 7a8578933be095b5180d7db76b70011dad614788
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54eef6e02d138091ea81eade42ee6502402377a93514f7662d90cc7fdc9d9a935cc4196252c6cd593b0adc147e7b02b97db7302b0f5d72bb700ec4baea3c3758
|
|
7
|
+
data.tar.gz: 36d32f718d1b09384f955bc4aa55877044ecdf76092c5891a77d601ca361289ea3a4e51fb71d7d94d87debb211f4829b9de1cd21734a315f72b859a4e0d08236
|
data/README.md
CHANGED
|
@@ -14,16 +14,25 @@ user_agent = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot
|
|
|
14
14
|
# Three forms of use:
|
|
15
15
|
|
|
16
16
|
# 1. Use the is_bot function
|
|
17
|
-
|
|
17
|
+
is_bot user_agent # true
|
|
18
18
|
|
|
19
19
|
# 2. Use the monkey patch method of the String object
|
|
20
|
-
|
|
20
|
+
user_agent.is_bot? # true
|
|
21
21
|
|
|
22
22
|
# 3. Use the is_bot function with code_blocks
|
|
23
23
|
is_bot user_agent do |match_bot|
|
|
24
24
|
puts match_bot # Googlebot/
|
|
25
25
|
end
|
|
26
26
|
````
|
|
27
|
+
|
|
28
|
+
Add a Spider User-Agent field:
|
|
29
|
+
|
|
30
|
+
```` ruby
|
|
31
|
+
user_agent = 'Mozilla/5.0 (compatible; MyBot/1.0; +http://my.me/bot.html'
|
|
32
|
+
IsBot::add_ua_field 'MyBot'
|
|
33
|
+
|
|
34
|
+
user_agent.is_bot? # true
|
|
35
|
+
````
|
|
27
36
|
#### Attached:
|
|
28
37
|
|
|
29
38
|
The crawler user-agent data from https://github.com/monperrus/crawler-user-agents, thanks! 😀
|
data/isbot.gemspec
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'isbot'
|
|
3
|
-
s.version = '0.1.
|
|
3
|
+
s.version = '0.1.2'
|
|
4
4
|
s.executables << 'isbot'
|
|
5
|
-
s.date = '2017-05-
|
|
5
|
+
s.date = '2017-05-21'
|
|
6
6
|
s.summary = 'detects bots/crawlers/spiders via the user agent.'
|
|
7
7
|
s.description = 'A simple library for detecting bots/crawlers/spiders through User-Agent strings.'
|
|
8
8
|
s.authors = ['Hentioe']
|
|
9
|
-
s.email = 'meow.i5.br@
|
|
9
|
+
s.email = 'meow.i5.br@gmail.com'
|
|
10
10
|
s.files = Dir['**/*']
|
|
11
11
|
s.homepage =
|
|
12
12
|
'https://github.com/Hentioe/isbot'
|
|
13
13
|
s.license = 'MIT'
|
|
14
|
-
end
|
|
14
|
+
end
|
data/lib/isbot.rb
CHANGED
data/lib/parser.rb
CHANGED
data/tests/isbot_test.rb
CHANGED
|
@@ -5,7 +5,7 @@ class IsBotTest < Test::Unit::TestCase
|
|
|
5
5
|
$list = [
|
|
6
6
|
'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
|
7
7
|
'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)',
|
|
8
|
-
'Mozilla/5.0 (compatible;
|
|
8
|
+
'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'
|
|
9
9
|
]
|
|
10
10
|
|
|
11
11
|
def test_is_bot
|
|
@@ -15,8 +15,15 @@ class IsBotTest < Test::Unit::TestCase
|
|
|
15
15
|
def test_is_bot_with_block
|
|
16
16
|
$list.each do |ua|
|
|
17
17
|
is_bot ua do |match_bot|
|
|
18
|
-
|
|
18
|
+
assert_not_nil match_bot
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
def test_add_ua_field
|
|
24
|
+
user_agent = 'Mozilla/5.0 (compatible; MyBot/1.0; +http://my.me/bot.html'
|
|
25
|
+
IsBot::add_ua_field 'MyBot'
|
|
26
|
+
|
|
27
|
+
assert_true user_agent.is_bot?
|
|
28
|
+
end
|
|
22
29
|
end
|
metadata
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: isbot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hentioe
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-05-
|
|
11
|
+
date: 2017-05-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A simple library for detecting bots/crawlers/spiders through User-Agent
|
|
14
14
|
strings.
|
|
15
|
-
email: meow.i5.br@
|
|
15
|
+
email: meow.i5.br@gmail.com
|
|
16
16
|
executables:
|
|
17
17
|
- isbot
|
|
18
18
|
extensions: []
|