voight_kampff 1.1.4 → 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
2
  SHA256:
3
- metadata.gz: 19ad3aa404672dc068c184cd9541f8f077a80e7ca6413d35d1985784ca341af9
4
- data.tar.gz: 0060d30f9b84a024887e30006d7d1803d19e389289c6f783004586264694e5d9
3
+ metadata.gz: c69b1d4e546df4f4ab198fbec224b3cb55ac3bc5dfa8f89b02e98ce438335479
4
+ data.tar.gz: 18cf54d7053b41d3f9619b1cfdf851c0cc610fdba4a1996c54b9d3ede1b483e1
5
5
  SHA512:
6
- metadata.gz: 3b87e14633463da571b04f75fe620d7230dc987b213ff9d8f157ccc169c27cecc5d5d9ada43ac1345f51d8a95c955f13f1f155776543437598e4ee8ef7a4adbb
7
- data.tar.gz: b94935484b1d50cd93af4086a64884f02e701b790267b6187cae76acc5db80a47030ed0714228ac35b0cb2f7446142c10b85b5e3cf345a6eb26bf7e4230a0570
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.6.5
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,6 +62,23 @@ 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?__
@@ -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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VoightKampff
4
- VERSION = '1.1.4'
4
+ VERSION = '2.0.0'
5
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::Engine)
7
5
 
8
6
  module VoightKampff
9
7
  class << self
@@ -34,7 +34,7 @@ describe VoightKampff::Test do
34
34
  Benchmark.realtime do
35
35
  20.times { VoightKampff::Test.new('anything').bot? }
36
36
  end
37
- ).to be < 0.003
37
+ ).to be < 0.005
38
38
  end
39
39
  end
40
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
26
  s.add_development_dependency 'combustion', '~> 1.1'
27
- s.add_development_dependency 'rails', '~> 5.2'
27
+ s.add_development_dependency 'rails', '>= 5.2'
28
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.4
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: 2020-03-03 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,9 +24,6 @@ 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
28
  name: combustion
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -48,14 +42,14 @@ dependencies:
48
42
  name: rails
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
- - - "~>"
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
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
54
  version: '5.2'
61
55
  - !ruby/object:Gem::Dependency
@@ -78,6 +72,7 @@ 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,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
120
  - !ruby/object:Gem::Version
124
121
  version: '0'
125
122
  requirements: []
126
- rubygems_version: 3.0.3
123
+ rubygems_version: 3.0.3.1
127
124
  signing_key:
128
125
  specification_version: 4
129
126
  summary: Voight-Kampff bot detection