agent_helpers 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/agent_helpers/detector.rb +9 -10
- data/lib/agent_helpers/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0190dfb12343c6b25627b5f580597bbc94e23a8a
|
4
|
+
data.tar.gz: 17dc94c8998343cac7d140d75f2c96d535cbfb98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f9830113b5074bcde51fe68ca806e44d414b1ae6fcfec581b510fa322bbf8b65db4ce46787c59ac8b015eb57f12b9f016b656d7b845757d029a778baf840b30
|
7
|
+
data.tar.gz: e280fc56f9469cd13c89dab1f780cda67bd0a26a678a51898db1bd77ff474b17df1eb679c862b4819c4bfb5bb28c96f098800680b7ab584a7d10671cc8321467
|
@@ -31,7 +31,6 @@ class AgentHelpers::Detector
|
|
31
31
|
raise "No request was given." unless @request
|
32
32
|
@env = @request.env
|
33
33
|
@user_agent = @request.user_agent.to_s.downcase.strip
|
34
|
-
raise "No user agent was given." if @user_agent.empty?
|
35
34
|
|
36
35
|
browsers = [:chrome, :ie, :firefox, :opera, :safari]
|
37
36
|
browsers.each do |browser|
|
@@ -43,7 +42,7 @@ class AgentHelpers::Detector
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def version_major
|
46
|
-
if match = version.to_s.match(/^(\d+)/)
|
45
|
+
if (match = version.to_s.match(/^(\d+)/))
|
47
46
|
return match[1].to_i
|
48
47
|
else
|
49
48
|
return nil
|
@@ -53,7 +52,7 @@ class AgentHelpers::Detector
|
|
53
52
|
private
|
54
53
|
|
55
54
|
def parse_chrome
|
56
|
-
if match = @user_agent.match(/chrome\/([\d+\.]+)/)
|
55
|
+
if (match = @user_agent.match(/chrome\/([\d+\.]+)/))
|
57
56
|
@browser = :chrome
|
58
57
|
@title = "Google Chrome"
|
59
58
|
@version = match[1]
|
@@ -61,7 +60,7 @@ private
|
|
61
60
|
end
|
62
61
|
|
63
62
|
def parse_ie
|
64
|
-
if match = @user_agent.match(/msie\s*([\d+\.]+)/)
|
63
|
+
if (match = @user_agent.match(/msie\s*([\d+\.]+)/))
|
65
64
|
@browser = :ie
|
66
65
|
@title = "Microsoft Internet Explorer"
|
67
66
|
@version = match[1]
|
@@ -69,7 +68,7 @@ private
|
|
69
68
|
end
|
70
69
|
|
71
70
|
def parse_firefox
|
72
|
-
if match = @user_agent.match(/firefox\/([\d+\.]+)/)
|
71
|
+
if (match = @user_agent.match(/firefox\/([\d+\.]+)/))
|
73
72
|
@browser = :firefox
|
74
73
|
@title = "Mozilla Firefox"
|
75
74
|
@version = match[1]
|
@@ -77,7 +76,7 @@ private
|
|
77
76
|
end
|
78
77
|
|
79
78
|
def parse_opera
|
80
|
-
if match = @user_agent.match(/opera\/([\d+\.]+)/)
|
79
|
+
if (match = @user_agent.match(/opera\/([\d+\.]+)/))
|
81
80
|
@browser = :opera
|
82
81
|
@title = "Opera"
|
83
82
|
@version = match[1]
|
@@ -85,7 +84,7 @@ private
|
|
85
84
|
end
|
86
85
|
|
87
86
|
def parse_safari
|
88
|
-
if match = @user_agent.match(/safari\/([\d+\.]+)/)
|
87
|
+
if (match = @user_agent.match(/safari\/([\d+\.]+)/))
|
89
88
|
@browser = :safari
|
90
89
|
@title = "Safari"
|
91
90
|
@version = match[1]
|
@@ -93,11 +92,11 @@ private
|
|
93
92
|
end
|
94
93
|
|
95
94
|
def parse_apps
|
96
|
-
if match = @user_agent.match(/wget\/([\d+\.]+)/)
|
95
|
+
if (match = @user_agent.match(/wget\/([\d+\.]+)/))
|
97
96
|
@browser = :app
|
98
97
|
@title = "Wget"
|
99
98
|
@version = match[1]
|
100
|
-
elsif match = @user_agent.match(/java\/([\d\.]+)/)
|
99
|
+
elsif (match = @user_agent.match(/java\/([\d\.]+)/))
|
101
100
|
@browser = :app
|
102
101
|
@title = "Java"
|
103
102
|
@version = match[1]
|
@@ -157,7 +156,7 @@ private
|
|
157
156
|
|
158
157
|
def parse_regex_list(list, browser)
|
159
158
|
list.each do |regex|
|
160
|
-
if match = @user_agent.match(regex)
|
159
|
+
if (match = @user_agent.match(regex))
|
161
160
|
@browser = browser
|
162
161
|
@title = match[1].to_s.capitalize
|
163
162
|
@version = match[2] if match[2]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agent_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.5.1
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Easily detect robots, browser, versions and more with convenient helpers.
|