rack-simple_user_agent 0.1.2 → 0.2.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
  SHA1:
3
- metadata.gz: 26be151d208e1fa3bc6cb600f274def1c876cfc9
4
- data.tar.gz: cdeb511a0a0d66071fa9c2b0e3ae3ec9b9c3ac2d
3
+ metadata.gz: db974678b1ec2d9e5b19324de2ea7f377644f025
4
+ data.tar.gz: da7c0416b7f4e30ad61cf208c5c52ade86eb9950
5
5
  SHA512:
6
- metadata.gz: c314d2f3cd9207a35ce535d3fe19883e8fe3ddce5b4452ac067e0aca664cf24abafb841e79c1ed02979afca2d4cf3ad947b8dca1d24348edd6ed4a9c1fdcdc53
7
- data.tar.gz: 1b6ebcbc3501af757c4af60a65bcba0a3f2a04911d7254905f456b338a1918a0e5c6a71bad2665927763df0c42105be890bc9267cf3371c58209685834cfb2f6
6
+ metadata.gz: 4f2613e1ebac34cd9f01c8ae88c8b20649f23ff23f376966f386a27c372c3957404c2514882fcc2198176a1968cbec4206f3422d60d95c667036cbee45066850
7
+ data.tar.gz: 2ba58c96929b7a7ef6787901f93011b154d4c79887a4f486fd550473255a5ffeaa0fd40bee2688e6263bcda86b5bf7044eb0e334ee3324f50eccf045cf15b7f3
data/README.md CHANGED
@@ -46,14 +46,19 @@ end
46
46
 
47
47
  ```
48
48
  request ── from_smartphone?
49
- ├── from_android?
50
- │   ├── from_android_mobile?
51
- │   └── from_android_tablet?
52
- ├── from_iphone?
53
- │   ├── from_ipad?
54
- │   ├── from_iphone?
55
- │   └── from_ipod?
56
- └── from_windows_phone?
49
+ ├── from_android?
50
+    ├── from_android_mobile?
51
+    └── from_android_tablet?
52
+ ├── from_iphone?
53
+    ├── from_ipad?
54
+    ├── from_iphone?
55
+    └── from_ipod?
56
+ └── from_windows_phone?
57
+
58
+ └ from_googlebot?
59
+ ├── from_googlebot_news?
60
+ ├── from_googlebot_images?
61
+ └── from_googlebot_video?
57
62
  ```
58
63
 
59
64
  ## Development
@@ -0,0 +1,23 @@
1
+ module Rack
2
+ class SimpleUserAgent
3
+ module Detectors
4
+ module Bot
5
+ def from_googlebot?
6
+ user_agent_string.include?("Googlebot")
7
+ end
8
+
9
+ def from_googlebot_news?
10
+ user_agent_string.include?("Googlebot-News")
11
+ end
12
+
13
+ def from_googlebot_images?
14
+ user_agent_string.include?("Googlebot-Image")
15
+ end
16
+
17
+ def from_googlebot_video?
18
+ user_agent_string.include?("Googlebot-Video")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ module Rack
2
+ class SimpleUserAgent
3
+ module Detectors
4
+ module Helper
5
+
6
+ private
7
+
8
+ def user_agent_string
9
+ user_agent.to_s
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,49 @@
1
+ module Rack
2
+ class SimpleUserAgent
3
+ module Detectors
4
+ module Smartphone
5
+ def from_smartphone?
6
+ from_ios? || from_android? || from_windows_phone?
7
+ end
8
+
9
+ def from_ios?
10
+ from_iphone? || from_ipad? || from_ipod?
11
+ end
12
+
13
+ def from_iphone?
14
+ user_agent_string.include?("iPhone")
15
+ end
16
+
17
+ def from_ipad?
18
+ user_agent_string.include?("iPad")
19
+ end
20
+
21
+ def from_ipod?
22
+ user_agent_string.include?("iPod")
23
+ end
24
+
25
+ def from_android?
26
+ user_agent_string.include?("Android")
27
+ end
28
+
29
+ def from_android_tablet?
30
+ from_android? && !android_mobile?
31
+ end
32
+
33
+ def from_android_mobile?
34
+ from_android? && android_mobile?
35
+ end
36
+
37
+ def from_windows_phone?
38
+ user_agent_string.include?("Windows Phone")
39
+ end
40
+
41
+ private
42
+
43
+ def android_mobile?
44
+ !(user_agent =~ /Android.+Mobi(le)?/).nil?
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,13 @@
1
+ require "rack/simple_user_agent/detectors/helper"
2
+ require "rack/simple_user_agent/detectors/bot"
3
+ require "rack/simple_user_agent/detectors/smartphone"
4
+
5
+ module Rack
6
+ class SimpleUserAgent
7
+ module Detectors
8
+ include Helper
9
+ include Smartphone
10
+ include Bot
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class SimpleUserAgent
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0".freeze
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  require "rack/simple_user_agent/version"
2
- require "rack/simple_user_agent/detector"
2
+ require "rack/simple_user_agent/detectors"
3
3
  require 'rack/simple_user_agent/railtie' if defined?(Rails)
4
4
 
5
5
  module Rack
@@ -14,6 +14,6 @@ module Rack
14
14
  end
15
15
 
16
16
  class Request
17
- include Rack::SimpleUserAgent::Detector
17
+ include Rack::SimpleUserAgent::Detectors
18
18
  end
19
19
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.11"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "minitest", "~> 5.0"
24
+ spec.add_development_dependency "minitest-reporters"
24
25
  spec.add_development_dependency "pry"
25
26
  spec.add_development_dependency "rack-test"
26
27
  spec.add_development_dependency "coveralls"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-simple_user_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - toshimaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-25 00:00:00.000000000 Z
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-reporters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -113,7 +127,10 @@ files:
113
127
  - bin/console
114
128
  - bin/setup
115
129
  - lib/rack/simple_user_agent.rb
116
- - lib/rack/simple_user_agent/detector.rb
130
+ - lib/rack/simple_user_agent/detectors.rb
131
+ - lib/rack/simple_user_agent/detectors/bot.rb
132
+ - lib/rack/simple_user_agent/detectors/helper.rb
133
+ - lib/rack/simple_user_agent/detectors/smartphone.rb
117
134
  - lib/rack/simple_user_agent/railtie.rb
118
135
  - lib/rack/simple_user_agent/version.rb
119
136
  - rack-simple_user_agent.gemspec
@@ -1,48 +0,0 @@
1
- module Rack
2
- class SimpleUserAgent
3
- module Detector
4
- def from_smartphone?
5
- from_ios? || from_android? || from_windows_phone?
6
- end
7
-
8
- def from_ios?
9
- from_iphone? || from_ipad? || from_ipod?
10
- end
11
-
12
- def from_iphone?
13
- user_agent.to_s.include?("iPhone")
14
- end
15
-
16
- def from_ipad?
17
- user_agent.to_s.include?("iPad")
18
- end
19
-
20
- def from_ipod?
21
- user_agent.to_s.include?("iPod")
22
- end
23
-
24
- def from_android?
25
- user_agent.to_s.include?("Android")
26
- end
27
-
28
- def from_android_tablet?
29
- from_android? && !android_mobile?
30
- end
31
-
32
- def from_android_mobile?
33
- from_android? && android_mobile?
34
- end
35
-
36
- def from_windows_phone?
37
- user_agent.to_s.include?("Windows Phone")
38
- end
39
-
40
- private
41
-
42
- def android_mobile?
43
- !(user_agent =~ /Android.+Mobi(le)?/).nil?
44
- end
45
-
46
- end
47
- end
48
- end