voight_kampff 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: 701e8fc73d384ed166e012cc83923c629a8909f5
4
- data.tar.gz: a011cc157b5b2e5d63e42a44c81b079c7d2a387c
3
+ metadata.gz: d84469d1aed5ee0786d045d4a064d96a9c96c6a1
4
+ data.tar.gz: 14e7e52f8fd161842dfd36eefc003dc4acf68c06
5
5
  SHA512:
6
- metadata.gz: cb26f0d79e494074a45844e3e158a170918e416586f7a12c4478cc0f49c8383b466521076a2b7a25964acba0dae6ad40f590cd0ec4088a7733bfcf66021d858e
7
- data.tar.gz: 94e716c8c99b02c5fdc9c71f765868ee34bfe7ed7a53e45ef4650d609b92220a64afe5ce9658fe39c33a7e45b8bc7b207b242cbf5f299f252fc4a12bed24fd00
6
+ metadata.gz: b20c3443891cc19f27c0fe8f278330f2e7077a023a237f728b2ef8803a423d730378b6b312eced348c61cbf0d5e8f95b18006502c39c9171812984f02baffd43
7
+ data.tar.gz: 7fa0cfba7a668b9cdd760aeb04f2073b997908e429236aaf6e2c8bab2563448b14972b413eb5878abb7da132ee7e4cc419fc5dc574947067ed52fe94ddaf5816
@@ -3,5 +3,11 @@ module VoightKampff
3
3
  rake_tasks do
4
4
  load 'tasks/voight_kampff.rake'
5
5
  end
6
+
7
+ initializer :add_voight_kampff_methods do |app|
8
+ ActionDispatch::Request.class_eval do
9
+ include VoightKampff::Methods
10
+ end
11
+ end
6
12
  end
7
13
  end
@@ -0,0 +1,10 @@
1
+ module VoightKampff::Methods
2
+ def human?
3
+ VoightKampff::Test.new(user_agent).human?
4
+ end
5
+
6
+ def bot?
7
+ VoightKampff::Test.new(user_agent).bot?
8
+ end
9
+ alias :replicant? :bot?
10
+ end
@@ -1,11 +1,4 @@
1
1
  # Reopen the Rack::Request class to add bot detection methods
2
- class Rack::Request
3
- def human?
4
- VoightKampff::Test.new(user_agent).human?
5
- end
6
-
7
- def bot?
8
- VoightKampff::Test.new(user_agent).bot?
9
- end
10
- alias :replicant? :bot?
2
+ Rack::Request.class_eval do
3
+ include VoightKampff::Methods
11
4
  end
@@ -1,3 +1,3 @@
1
1
  module VoightKampff
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
data/lib/voight_kampff.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'json'
2
2
 
3
3
  require 'voight_kampff/test'
4
- require 'voight_kampff/rack_request' if defined?(Rack)
4
+ require 'voight_kampff/methods'
5
+ require 'voight_kampff/rack_request' if defined?(Rack::Request)
5
6
  require 'voight_kampff/engine' if defined?(Rails)
6
7
 
7
8
  module VoightKampff
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe ReplicantsController, type: :controller do
4
4
  let(:user_agent_string) { '' }
5
5
  before do
6
- expect(request).to receive(:user_agent).and_return user_agent_string
6
+ expect_any_instance_of(ActionController::TestRequest).to receive(:user_agent).and_return user_agent_string
7
7
  get :index
8
8
  end
9
9
 
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.add_dependency 'rack', ['>= 1.4', '< 3.0']
25
25
 
26
- s.add_development_dependency 'rails', '~> 4.2'
26
+ s.add_development_dependency 'rails', '~> 5.0'
27
27
  s.add_development_dependency 'rspec-rails', '~> 3.3'
28
28
  s.add_development_dependency 'combustion', '~> 0.5'
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voight_kampff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '4.2'
39
+ version: '5.0'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '4.2'
46
+ version: '5.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,7 @@ files:
88
88
  - lib/tasks/voight_kampff.rake
89
89
  - lib/voight_kampff.rb
90
90
  - lib/voight_kampff/engine.rb
91
+ - lib/voight_kampff/methods.rb
91
92
  - lib/voight_kampff/rack_request.rb
92
93
  - lib/voight_kampff/test.rb
93
94
  - lib/voight_kampff/version.rb