rack-turing-test 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25ecf72d2de79e1601c619baf39ecd9ffd87d6bd
4
+ data.tar.gz: d87195ff7397a5cedd3c4546a0b153f8fb48e9d1
5
+ SHA512:
6
+ metadata.gz: 20806eb6ecadcea091a6fe2576d5fda89139f0e63001e01b5085427a7b46a550977d9e65ad09a3818a80bb1d4aa74fae81775004bdce30b91e066591d2938886
7
+ data.tar.gz: fb09ccdb7bd3495e51fc57d9d8ff89e4f4058af1a4e3a9edef8d0a4eebb3f8e79d9de53b3595994ccfa583a514e5152986233c3182b8c349225913a72461ec5e
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module TuringTest
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- require "rack-turing-test/version"
1
+ require 'rack-turing-test/version'
2
2
 
3
3
  module Rack
4
4
  module TuringTest
@@ -21,7 +21,7 @@ module Rack
21
21
  # Sometimes, there's a case that the HTTP_USERAGENT is nil.
22
22
  # It's very rare for ordinary browsers. So, simply we observe it as a bot.
23
23
  def bot?
24
- user_agent.nil? || !!user_agent.match(PATTERN)
24
+ @__bot ||= (user_agent.nil? || !!user_agent.match(PATTERN))
25
25
  end
26
26
  end
27
27
 
@@ -9,9 +9,32 @@ describe Rack::TuringTest do
9
9
  def user_agent; @ua end
10
10
  end
11
11
 
12
+ it "should not detect human as a bot" do
13
+ ua = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)"
14
+ req = TestRequest.new ua
15
+ req.should_not be_bot
16
+ end
17
+
12
18
  it "should detect New-Sogou-Spider as a bot" do
13
19
  ua = "New-Sogou-Spider/1.0 (compatible; MSIE 5.5; Windows 98)"
14
20
  req = TestRequest.new ua
15
21
  req.should be_bot
16
22
  end
23
+
24
+ it "can handle requests that the ua is nil" do
25
+ req = TestRequest.new nil
26
+ req.should be_bot
27
+ end
28
+
29
+ it "can detect googlebot (no ajax)" do
30
+ ua = "Mediapartners-Google"
31
+ req = TestRequest.new ua
32
+ req.should be_bot
33
+ end
34
+
35
+ it "can detect googlebot (ajax)" do
36
+ req = TestRequest.new \
37
+ "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
38
+ req.should be_bot
39
+ end
17
40
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-turing-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Genki Takiuchi
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-02 00:00:00.000000000 Z
11
+ date: 2013-05-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: You can test if sender of request has intelligence.
@@ -44,27 +41,26 @@ files:
44
41
  - spec/rack_turing_test_spec.rb
45
42
  homepage: ''
46
43
  licenses: []
44
+ metadata: {}
47
45
  post_install_message:
48
46
  rdoc_options: []
49
47
  require_paths:
50
48
  - lib
51
49
  required_ruby_version: !ruby/object:Gem::Requirement
52
- none: false
53
50
  requirements:
54
- - - ! '>='
51
+ - - '>='
55
52
  - !ruby/object:Gem::Version
56
53
  version: '0'
57
54
  required_rubygems_version: !ruby/object:Gem::Requirement
58
- none: false
59
55
  requirements:
60
- - - ! '>='
56
+ - - '>='
61
57
  - !ruby/object:Gem::Version
62
58
  version: '0'
63
59
  requirements: []
64
60
  rubyforge_project: rack-turing-test
65
- rubygems_version: 1.8.24
61
+ rubygems_version: 2.0.3
66
62
  signing_key:
67
- specification_version: 3
63
+ specification_version: 4
68
64
  summary: Bot detector for Rack::Request
69
65
  test_files:
70
66
  - spec/rack_turing_test_spec.rb