voight_kampff 1.1.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aaad7c130bf25186c8a6f0d83b788b37dfd359f5
4
- data.tar.gz: 65eaafd893c9e7b1043199bdb56b8df525509a6f
2
+ SHA256:
3
+ metadata.gz: c69b1d4e546df4f4ab198fbec224b3cb55ac3bc5dfa8f89b02e98ce438335479
4
+ data.tar.gz: 18cf54d7053b41d3f9619b1cfdf851c0cc610fdba4a1996c54b9d3ede1b483e1
5
5
  SHA512:
6
- metadata.gz: 90e012989497795cacb3357e6b3654ab5a0fa0e965e79b51868f7b23d0e9ca0788eb21e22cb8da8943622a654b74a6c1831ef01073c201d4991ca63c7137ae40
7
- data.tar.gz: cf79235228114f2e1ff3125277823556591c7426058af965f4aff8e0ed85a583ac4cab8b2e7cd58a92fa4cecd9f1cc90ddf1af72d5c973e3b373a4cccd0e906f
6
+ metadata.gz: a23c1eb73c61bb1db3dd5c1f0a43f4a27cbbc39cf898d78b143dd15c924961454ff7da7041e79efe8aba3ac614eba973da46c6dfff9170d791ee8e6141474d1e
7
+ data.tar.gz: 020c12b9fdf01106b7997d3c1052304352da0930baadd2bee8382e59624bea3066f0637a9cf0fee0ef0b9fc4504461927b0e97ceb62d45f15804adc0801691d1
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: CI
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - '**'
8
+ pull_request:
9
+ branches:
10
+ - '**'
11
+ schedule:
12
+ - cron: '0 4 1 * *'
13
+
14
+ jobs:
15
+ rspec:
16
+ runs-on: ubuntu-20.04
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ ruby:
21
+ - '3.2'
22
+ - '3.1'
23
+ - '3.0'
24
+ - '2.7'
25
+
26
+ steps:
27
+ - name: Checkout
28
+ uses: actions/checkout@v2
29
+
30
+ - name: Setup Ruby
31
+ uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ bundler-cache: true
35
+
36
+ - name: RSpec
37
+ run: bundle exec rspec
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 3.2.0
data/README.md CHANGED
@@ -8,8 +8,21 @@ Voight-Kampff relies on a [user agent](http://en.wikipedia.org/wiki/User_agent)
8
8
 
9
9
  Installation
10
10
  ------------
11
+
11
12
  `gem install voight_kampff`
12
13
 
14
+ If you're using Rails and want to add `ActionDispatch::Request#bot?` and `ActionDispatch::Request#human?` methods, require `voight_kampff/rails`:
15
+
16
+ ```Gemfile
17
+ gem 'voight_kampff', require: 'voight_kampff/rails'
18
+ ```
19
+
20
+ if you're using pure Rack, require it the following way:
21
+
22
+ ```Gemfile
23
+ gem 'voight_kampff', require: 'voight_kampff/rack'
24
+ ```
25
+
13
26
  Configuration
14
27
  -------------
15
28
 
@@ -49,10 +62,27 @@ In general the `#bot?` command tends to include all of these and I'm sure it's u
49
62
 
50
63
  Also, the gem no longer extends `ActionDispatch::Request` instead it extends `Rack::Request` which `ActionDispatch::Request` inherits from. This allows the same functionality for Rails while opening the gem up to other rack-based projects.
51
64
 
65
+ Upgrading to version 2.0
66
+ ------------------------
67
+
68
+ If you use Rails and `ActionDispatch::Request#bot?` and `ActionDispatch::Request#human?` methods, change your gemfile:
69
+
70
+ ```diff
71
+ -gem 'voight_kampff'
72
+ +gem 'voight_kampff', require: 'voight_kampff/rails'
73
+ ```
74
+
75
+ If you use Rack, change your gemfile:
76
+
77
+ ```diff
78
+ -gem 'voight_kampff'
79
+ +gem 'voight_kampff', require: 'voight_kampff/rack'
80
+ ```
81
+
52
82
  FAQ
53
83
  ---
54
84
  __Q:__ __What's with the name?__
55
- __A:__ It's the [machine in Blade Runner](http://en.wikipedia.org/wiki/Blade_Runner#Voigt-Kampff_machine) that is used to test whether someone is a human or a replicant.
85
+ __A:__ It's the [machine in Blade Runner](https://en.wikipedia.org/wiki/Blade_Runner#Voight-Kampff_machine) that is used to test whether someone is a human or a replicant.
56
86
 
57
87
  __Q:__ __I've found a bot that isn't being matched__
58
88
  __A:__ The list is being pulled from [github.com/monperrus/crawler-user-agents](https://github.com/monperrus/crawler-user-agents).
@@ -0,0 +1,2 @@
1
+ require 'voight_kampff'
2
+ require 'voight_kampff/rack_request'
@@ -0,0 +1,3 @@
1
+ require 'voight_kampff'
2
+ require 'voight_kampff/rack'
3
+ require 'voight_kampff/engine'
@@ -33,7 +33,7 @@ module VoightKampff
33
33
  end
34
34
 
35
35
  def preferred_path
36
- lookup_paths.find { |path| File.exists? path }
36
+ lookup_paths.find { |path| File.exist? path }
37
37
  end
38
38
 
39
39
  def matching_crawler
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module VoightKampff
2
- VERSION = '1.1.3'
4
+ VERSION = '2.0.0'
3
5
  end
data/lib/voight_kampff.rb CHANGED
@@ -2,8 +2,6 @@ require 'json'
2
2
 
3
3
  require 'voight_kampff/test'
4
4
  require 'voight_kampff/methods'
5
- require 'voight_kampff/rack_request' if defined?(Rack::Request)
6
- require 'voight_kampff/engine' if defined?(Rails)
7
5
 
8
6
  module VoightKampff
9
7
  class << self
@@ -30,7 +30,11 @@ describe VoightKampff::Test do
30
30
  before { VoightKampff::Test.new('anything').bot? }
31
31
 
32
32
  it 'is fast' do
33
- expect(Benchmark.realtime { 20.times { VoightKampff::Test.new('anything').bot? } }).to be < 0.002
33
+ expect(
34
+ Benchmark.realtime do
35
+ 20.times { VoightKampff::Test.new('anything').bot? }
36
+ end
37
+ ).to be < 0.005
34
38
  end
35
39
  end
36
40
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bundler/setup'
2
2
  require 'combustion'
3
3
  require 'voight_kampff'
4
+ require 'voight_kampff/rails'
4
5
 
5
6
  Combustion.initialize! :action_controller
6
7
 
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.test_files = `git ls-files -- {tests}/**/*`.split("\n")
22
22
  s.require_path = 'lib'
23
23
 
24
- s.add_dependency 'rack', ['>= 1.4', '< 3.0']
24
+ s.add_dependency 'rack', ['>= 1.4']
25
25
 
26
- s.add_development_dependency 'rails', '~> 5.0'
27
- s.add_development_dependency 'rspec-rails', '~> 3.3'
28
- s.add_development_dependency 'combustion', '~> 0.5'
26
+ s.add_development_dependency 'combustion', '~> 1.1'
27
+ s.add_development_dependency 'rails', '>= 5.2'
28
+ s.add_development_dependency 'rspec-rails', '~> 3.8'
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voight_kampff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-30 00:00:00.000000000 Z
11
+ date: 2023-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '3.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,57 +24,55 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.4'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '3.0'
33
27
  - !ruby/object:Gem::Dependency
34
- name: rails
28
+ name: combustion
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - "~>"
38
32
  - !ruby/object:Gem::Version
39
- version: '5.0'
33
+ version: '1.1'
40
34
  type: :development
41
35
  prerelease: false
42
36
  version_requirements: !ruby/object:Gem::Requirement
43
37
  requirements:
44
38
  - - "~>"
45
39
  - !ruby/object:Gem::Version
46
- version: '5.0'
40
+ version: '1.1'
47
41
  - !ruby/object:Gem::Dependency
48
- name: rspec-rails
42
+ name: rails
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - "~>"
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '3.3'
47
+ version: '5.2'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - "~>"
52
+ - - ">="
59
53
  - !ruby/object:Gem::Version
60
- version: '3.3'
54
+ version: '5.2'
61
55
  - !ruby/object:Gem::Dependency
62
- name: combustion
56
+ name: rspec-rails
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '0.5'
61
+ version: '3.8'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '0.5'
68
+ version: '3.8'
75
69
  description: Voight-Kampff detects bots, spiders, crawlers and replicants
76
70
  email: adam@codenoble.com
77
71
  executables: []
78
72
  extensions: []
79
73
  extra_rdoc_files: []
80
74
  files:
75
+ - ".github/workflows/ci.yml"
81
76
  - ".gitignore"
82
77
  - ".ruby-version"
83
78
  - Gemfile
@@ -89,7 +84,9 @@ files:
89
84
  - lib/voight_kampff.rb
90
85
  - lib/voight_kampff/engine.rb
91
86
  - lib/voight_kampff/methods.rb
87
+ - lib/voight_kampff/rack.rb
92
88
  - lib/voight_kampff/rack_request.rb
89
+ - lib/voight_kampff/rails.rb
93
90
  - lib/voight_kampff/test.rb
94
91
  - lib/voight_kampff/version.rb
95
92
  - spec/controllers/replicants_controller_spec.rb
@@ -123,8 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
120
  - !ruby/object:Gem::Version
124
121
  version: '0'
125
122
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.5.1
123
+ rubygems_version: 3.0.3.1
128
124
  signing_key:
129
125
  specification_version: 4
130
126
  summary: Voight-Kampff bot detection