browser_sniffer 1.0.13 → 1.1.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: 557533e37c55a363ab5ef6eedac73022d665d25a
4
- data.tar.gz: 9a6c2d44a4c78ad76aecac81f5a47bb08877eec5
3
+ metadata.gz: cf033cc654dff84bed444330cf7d072b32dc0293
4
+ data.tar.gz: '096ac9e8880a0bf1cc824901a905d88f0b86225d'
5
5
  SHA512:
6
- metadata.gz: 4dad67f37b49accceecbdf5faff75e7196786876444faf6eead4363fdb524a1d25645980ef32cfe6681d7d9f08bfed1ebcdad46b63189cc34ca1763df8362c91
7
- data.tar.gz: cb954fed3a0fcbf6b783dd88f2aaaf6c44025075f454768481aa1d1a714c70c8ba843a6a4aebeb425ca82993199b15778f244abc42218155eb85e58a5aa42114
6
+ metadata.gz: 9f505b862e380c86fbe8bb5642298ecf9726215725ce1efb9b90fb921549363c505da096691d6f73cf51babc11d0f6b481e5bb6db3fca7ef8af9e685083e44ff
7
+ data.tar.gz: 5c44d0be93014a810d7183eac1fc4ed0fc81669b943bfde6ee3e4cf8988b319cc61e5c83b96717b0fe9692ece44b72ad43ee5652e137500f1d7a3348d92aca19
@@ -0,0 +1,2 @@
1
+ enabled:
2
+ - cla
@@ -18,5 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.required_ruby_version = ">= 1.9.3"
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "minitest"
21
22
  spec.add_development_dependency "rake"
22
23
  end
@@ -45,6 +45,39 @@ class BrowserSniffer
45
45
  REGEX_MAP = {
46
46
  :browser => [
47
47
  [
48
+ # Shopify Mobile for iPhone or iPad
49
+ %r{^Shopify/\d+\s\((iPhone|iPad)\;\siOS\s[\d\.]+}i
50
+ ], [[:name, 'Shopify Mobile']], [
51
+ # Shopify Mobile for Android
52
+ %r{^Dalvik/[a-z0-9\.]+.*Shopify\s[\d+\.\/]+}i
53
+ ], [[:name, 'Shopify Mobile']], [
54
+ # Shopify POS for iOS
55
+ %r{.*(Shopify\sPOS)\/([\d\.]+)\s\((iPhone|iPad|iPod\stouch)\;}i,
56
+ ], [:name, :version], [
57
+ # Old Shopify POS for Android
58
+ %r{^Dalvik/[a-z0-9\.]+.*(Shopify\sPOS)\s(\d(?:\.\d+)*)(\/\d*)*}i,
59
+ ], [:name, :version], [
60
+ # Shopify POS for Android (Native App)
61
+ %r{.*(\sPOS\s-).*\s([\d+\.]+)(\/\d*)*\s}i,
62
+ ], [[:name, 'Shopify POS'], :version], [
63
+ # Shopify POS for Android (SmartWebView)
64
+ %r{.*(Shopify\sPOS)\s.*Android.*\s([\d+\.]+)(\/\d*)*\s}i,
65
+ ], [:name, :version], [
66
+ # Shopify POS uses this user agent
67
+ %r{^(okhttp)\/([\d\.]+)}i
68
+ ], [:name, :version], [
69
+ # Shopify Mobile for iPhone or iPad
70
+ %r{^(Shopify Mobile)\/(?:iPhone\sOS|iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
71
+ ], [[:name, 'Shopify Mobile'], :version], [
72
+ # Shopify Mobile for Android
73
+ %r{^(Shopify Mobile)\/Android\/([\d\.]+(?: \(debug(?:|-push)\))?) \(Build (\d+) with API (\d+)}i
74
+ ], [[:name, 'Shopify Mobile'], :version, :build, :sdk_version], [
75
+ # ShopifyFoundation shared library
76
+ /^(ShopifyFoundation)/i,
77
+ ], [:name], [
78
+ # Shopify Ping iOS
79
+ %r{^(Shopify Ping)\/(?:iPhone\sOS|iOS)\/([\d\.]+) \((iPhone|iPad|iPod)}i
80
+ ], [[:name, 'Shopify Ping'], :version], [
48
81
  # Presto based
49
82
  /(opera\smini)\/((\d+)?[\w\.-]+)/i, # Opera Mini
50
83
  /(opera\s[mobiletab]+).+:version\/((\d+)?[\w\.-]+)/i, # Opera Mobi/Tablet
@@ -117,6 +150,36 @@ class BrowserSniffer
117
150
  ],
118
151
  :device => [
119
152
  [
153
+ # Shopify Mobile for iPhone
154
+ %r{^Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
155
+ ], [[:type, :handheld], :model], [
156
+ # Shopify Mobile for iPad
157
+ %r{^Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPad)([\d,]+)}i
158
+ ], [[:type, :tablet], :model], [
159
+ # Shopify Mobile for iPod touch
160
+ %r{^Shopify Mobile/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPod)([\d,]+)}i
161
+ ], [[:type, :handheld], :model], [
162
+ # Shopify Ping for iPhone
163
+ %r{^Shopify Ping/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
164
+ ], [[:type, :handheld], :model], [
165
+ # Shopify Mobile for Android
166
+ %r{^Shopify Mobile\/(Android)\/[\d\.]+(?: \(debug(?:|-push)\))? \(Build \d+ with API \d+ on (.*?) (.*)\)}i
167
+ ], [[:type, :handheld], :vendor, :model], [
168
+ # Shopify POS for iPhone
169
+ %r{.*Shopify POS\/[\d\.]+ \((iPhone)\;.*Scale/([\d\.]+)}i,
170
+ ], [[:type, :handheld], :scale], [
171
+ # Shopify POS for iPad
172
+ %r{.*Shopify POS\/[\d\.]+ \((iPad)\;.*Scale/([\d\.]+)}i,
173
+ ], [[:type, :tablet], :scale], [
174
+ # Shopify POS for iPod touch
175
+ %r{.*Shopify POS\/[\d\.]+ \((iPod touch)\;.*Scale/([\d\.]+)}i,
176
+ ], [[:type, :handheld], :scale], [
177
+ # Shopify POS for Android (SmartWebView)
178
+ %r{.*Shopify\sPOS.*\(.*(Android)\s[\d\.]+\;\s(.*)\sBuild/.*\)\sPOS.*[\d+\.]+}i,
179
+ ], [[:type, :handheld], :model], [
180
+ # Shopify POS for Android (Native App)
181
+ %r{.*\(.*(Android)\s[\d\.]+\;\s(.*)\sBuild/.*\)\sPOS.*[\d+\.]+}i,
182
+ ], [[:type, :handheld], :model], [
120
183
  /\((playbook);[\w\s\);-]+(rim)/i # PlayBook
121
184
  ], [:model, :vendor, [:type, :tablet]], [
122
185
  /\((ipad);[\w\s\);-]+(apple)/i # iPad
@@ -198,6 +261,30 @@ class BrowserSniffer
198
261
  ],
199
262
  :os => [
200
263
  [
264
+ # Shopify Mobile for iOS
265
+ %r{^Shopify/\d+\s\((?:iPhone|iPad)\;\s(iOS)\s([\d\.]+)}i
266
+ ], [[:type, :ios], :version, [:name, 'iOS']], [
267
+ # Shopify POS for iOS
268
+ %r{.*Shopify\sPOS/[\d\.]+\s\((?:iPhone|iPad|iPod\stouch)\;\s(iOS)\s([\d\.]+)}i,
269
+ ], [[:type, :ios], :version, [:name, 'iOS']], [
270
+ # Old Shopify POS for Android
271
+ /^Dalvik.*(Android)\s([\d\.]+)\;\s.*\s[\d+\.]+/i,
272
+ ], [[:type, :android], :version, [:name, 'Android']], [
273
+ # Shopify POS for Android
274
+ /.*Shopify\sPOS\s.*(Android)\s([\d\.]+)\;\s.*\s[\d+\.]+\s/i,
275
+ ], [[:type, :android], :version, [:name, 'Android']], [
276
+ # Shopify Mobile for iOS
277
+ %r{^Shopify Mobile\/(iPhone\sOS|iOS)\/[\d\.]+ \(.*\/OperatingSystemVersion\((.*)\)}i
278
+ ], [[:type, :ios], [:version, lambda { |str| str && str.scan(/\d+/).join(".") }], [:name, 'iOS']], [
279
+ # Shopify Mobile for iPhone or iPad
280
+ %r{^(Shopify Mobile)\/(?:iPhone\sOS|iOS)[\/\d\.]* \((iPhone|iPad|iPod).*\/([\d\.]+)}i
281
+ ], [[:type, :ios], [:name, 'iOS'], :version], [
282
+ # Shopify Ping for iOS
283
+ %r{^Shopify Ping\/(iOS)\/[\d\.]+ \(.* Simulator\/.*\/([\d\.]+)\)}i
284
+ ], [[:type, :ios], :version, [:name, 'iOS']], [
285
+ # Shopify Mobile for Android
286
+ %r{^Shopify Mobile\/(Android)\/[\d\.]+ }i
287
+ ], [:name, [:type, :android]], [
201
288
  # Windows based
202
289
  /(windows)\snt\s6\.2;\s(arm)/i, # Windows RT
203
290
  /(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i,
@@ -1,3 +1,3 @@
1
1
  class BrowserSniffer
2
- VERSION = "1.0.13"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class BrowserSnifferTest < MiniTest::Unit::TestCase
3
+ class BrowserSnifferTest < Minitest::Test
4
4
  AGENTS = {
5
5
  :ipad_old => {
6
6
  :user_agent => "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10",
@@ -221,7 +221,6 @@ class BrowserSnifferTest < MiniTest::Unit::TestCase
221
221
  :major_engine_version => 528,
222
222
  :os => :android,
223
223
  :os_version => '1.6',
224
- :os => :android,
225
224
  :major_browser_version => 3
226
225
  },
227
226
  :hp_ipaq => {
@@ -552,7 +551,11 @@ class BrowserSnifferTest < MiniTest::Unit::TestCase
552
551
  define_method "test_sniff_#{agent}_correctly" do
553
552
  sniffer = BrowserSniffer.new(attributes[:user_agent])
554
553
  attributes.reject{|attr| attr == :user_agent}.each do |attribute, value|
555
- assert_equal value, sniffer.send(attribute), "#{attribute.to_s} did not match"
554
+ if value.nil?
555
+ assert_nil sniffer.send(attribute), "#{attribute.to_s} did not match"
556
+ else
557
+ assert_equal value, sniffer.send(attribute), "#{attribute.to_s} did not match"
558
+ end
556
559
  end
557
560
  end
558
561
  end
@@ -0,0 +1,365 @@
1
+ require "test_helper"
2
+
3
+ describe "Shopify agents" do
4
+ it "Shopify Mobile on iOS can be sniffed" do
5
+ user_agent = "Shopify Mobile/iOS/5.4.4 "\
6
+ "(iPhone9,3/com.jadedpixel.shopify/OperatingSystemVersion(majorVersion: 10, minorVersion: 3, patchVersion: 2))"
7
+ sniffer = BrowserSniffer.new(user_agent)
8
+
9
+ assert_equal ({
10
+ name: 'Shopify Mobile',
11
+ version: '5.4.4',
12
+ }), sniffer.browser_info
13
+
14
+ assert_equal ({
15
+ type: :handheld,
16
+ model: '9,3',
17
+ }), sniffer.device_info
18
+
19
+ assert_equal ({
20
+ type: :ios,
21
+ version: '10.3.2',
22
+ name: 'iOS',
23
+ }), sniffer.os_info
24
+ end
25
+
26
+ it "Shopify Mobile on iPod touch can be sniffed" do
27
+ user_agent = "Shopify Mobile/iPhone OS/5.4.4 "\
28
+ "(iPod5,1/com.jadedpixel.shopify/OperatingSystemVersion(majorVersion: 9, minorVersion: 3, patchVersion: 5))"
29
+ sniffer = BrowserSniffer.new(user_agent)
30
+
31
+ assert_equal ({
32
+ name: 'Shopify Mobile',
33
+ version: '5.4.4',
34
+ }), sniffer.browser_info
35
+
36
+ assert_equal ({
37
+ type: :handheld,
38
+ model: '5,1',
39
+ }), sniffer.device_info
40
+
41
+ assert_equal ({
42
+ type: :ios,
43
+ version: '9.3.5',
44
+ name: 'iOS',
45
+ }), sniffer.os_info
46
+ end
47
+
48
+ it "Shopify Mobile on iPhone is detected as handheld" do
49
+ user_agent = "Shopify Mobile/iOS/5.4.4 "\
50
+ "(iPhone9,3/com.jadedpixel.shopify/OperatingSystemVersion(majorVersion: 10, minorVersion: 3, patchVersion: 2))"
51
+ sniffer = BrowserSniffer.new(user_agent)
52
+ assert_equal :handheld, sniffer.form_factor
53
+ assert sniffer.handheld?
54
+ end
55
+
56
+ it "Shopify Mobile on iPad is detected as tablet" do
57
+ user_agent = "Shopify Mobile/iOS/5.4.4 "\
58
+ "(iPad9,3/com.jadedpixel.shopify/OperatingSystemVersion(majorVersion: 10, minorVersion: 3, patchVersion: 2))"
59
+ sniffer = BrowserSniffer.new(user_agent)
60
+ assert_equal :tablet, sniffer.form_factor
61
+ assert sniffer.tablet?
62
+ end
63
+
64
+ it "Shopify Mobile on iPhone OS is detected as iOS" do
65
+ user_agent = "Shopify Mobile/iPhone OS/5.4.4 "\
66
+ "(iPad2,4/com.jadedpixel.shopify/OperatingSystemVersion(majorVersion: 9, minorVersion: 3, patchVersion: 5))"
67
+ sniffer = BrowserSniffer.new(user_agent)
68
+ assert_equal :ios, sniffer.os
69
+ assert sniffer.ios?
70
+ end
71
+
72
+ it "Shopify Mobile version is delected on iPhone OS" do
73
+ user_agent = "Shopify Mobile/iOS/6.6.2 (iPhone10,1/com.jadedpixel.shopify/11.0.2)"
74
+ sniffer = BrowserSniffer.new(user_agent)
75
+ assert_equal "6.6.2", sniffer.browser_version
76
+ assert_equal "11.0.2", sniffer.os_version
77
+ assert sniffer.ios?
78
+ end
79
+
80
+ it "Shopify Mobile on Android can be sniffed" do
81
+ user_agent = "Shopify Mobile/Android/5.4.4 (Build 12005 with API 25 on OnePlus ONEPLUS A3003)"
82
+ sniffer = BrowserSniffer.new(user_agent)
83
+
84
+ assert_equal ({
85
+ name: 'Shopify Mobile',
86
+ version: '5.4.4',
87
+ build: '12005',
88
+ sdk_version: '25',
89
+ }), sniffer.browser_info
90
+
91
+ assert_equal ({
92
+ type: :handheld,
93
+ vendor: 'OnePlus',
94
+ model: 'ONEPLUS A3003',
95
+ }), sniffer.device_info
96
+
97
+ assert_equal ({
98
+ name: 'Android',
99
+ type: :android,
100
+ }), sniffer.os_info
101
+ end
102
+
103
+ it "Shopify Mobile on Android simulator can be sniffed" do
104
+ user_agent = "Shopify Mobile/Android/6.2.0 "\
105
+ "(debug) (Build 1 with API 25 on Unknown Android "\
106
+ "SDK built for x86) Mozilla/5.0 (Linux; Android 7.1.1; Android SDK built for x86 Build/NYC; wv) "\
107
+ "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Mobile Safari/537.36"
108
+ sniffer = BrowserSniffer.new(user_agent)
109
+
110
+ assert_equal ({
111
+ name: 'Shopify Mobile',
112
+ version: '6.2.0 (debug)',
113
+ build: '1',
114
+ sdk_version: '25',
115
+ }), sniffer.browser_info
116
+
117
+ assert_equal ({
118
+ name: 'Android',
119
+ type: :android,
120
+ }), sniffer.os_info
121
+ end
122
+
123
+ it "Shopify POS on Android MAL can be sniffed" do
124
+ user_agent = "Dalvik/2.1.0 (Linux; U; Android 7.1.1; Android SDK built for x86 Build/NYC) "\
125
+ "Shopify POS 2.4.11.mal/18038"
126
+ sniffer = BrowserSniffer.new(user_agent)
127
+
128
+ assert_equal ({
129
+ name: 'Shopify POS',
130
+ version: '2.4.11',
131
+ }), sniffer.browser_info
132
+
133
+ assert_equal ({
134
+ name: 'Android',
135
+ type: :android,
136
+ version: '7.1.1',
137
+ }), sniffer.os_info
138
+ end
139
+
140
+ it "Shopify POS on iPhone can be sniffed" do
141
+ user_agent = "Shopify POS/3.12.1 (iPhone; iOS 10.3.1; Scale/2.00)"
142
+ sniffer = BrowserSniffer.new(user_agent)
143
+
144
+ assert_equal ({
145
+ name: 'Shopify POS',
146
+ version: '3.12.1',
147
+ }), sniffer.browser_info
148
+
149
+ assert_equal ({
150
+ type: :handheld,
151
+ scale: '2.00',
152
+ }), sniffer.device_info
153
+
154
+ assert_equal ({
155
+ type: :ios,
156
+ version: '10.3.1',
157
+ name: 'iOS',
158
+ }), sniffer.os_info
159
+ end
160
+
161
+ it "Shopify POS on iPod touch can be sniffed" do
162
+ user_agent = "Shopify POS/3.12.1 (iPod touch; iOS 9.3.5; Scale/2.00)"
163
+ sniffer = BrowserSniffer.new(user_agent)
164
+
165
+ assert_equal ({
166
+ name: 'Shopify POS',
167
+ version: '3.12.1',
168
+ }), sniffer.browser_info
169
+
170
+ assert_equal ({
171
+ type: :handheld,
172
+ scale: '2.00',
173
+ }), sniffer.device_info
174
+
175
+ assert_equal ({
176
+ type: :ios,
177
+ version: '9.3.5',
178
+ name: 'iOS',
179
+ }), sniffer.os_info
180
+ end
181
+
182
+ it "Shopify POS on iPad is detected as tablet" do
183
+ user_agent = "Shopify POS/3.10.12 (iPad; iOS 10.3.1; Scale/2.00)"
184
+ sniffer = BrowserSniffer.new(user_agent)
185
+
186
+ assert_equal :tablet, sniffer.form_factor
187
+ end
188
+
189
+ it "Shopify POS with okhttp user agent can be parsed" do
190
+ user_agent = "okhttp/3.6.0"
191
+ sniffer = BrowserSniffer.new(user_agent)
192
+
193
+ assert_equal ({
194
+ name: 'okhttp',
195
+ version: '3.6.0',
196
+ }), sniffer.browser_info
197
+ end
198
+
199
+ it "Shopify POS on Android can be sniffed (SmartWebView)" do
200
+ user_agent = "com.jadedpixel.pos Shopify POS Dalvik/2.1.0 (Linux; U; Android 7.1.1; " \
201
+ "SM-T560NU Build/NMF26X) POS - Debug 2.4.10 (1a5a407d00)/3405 Mozilla/5.0 " \
202
+ "(Linux; Android 7.1.1; SM-T560NU Build/NMF26X; wv) AppleWebKit/537.36 " \
203
+ "(KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Safari/537.36"
204
+ sniffer = BrowserSniffer.new(user_agent)
205
+
206
+ user_agent_with_suffix = "com.jadedpixel.pos Shopify POS Dalvik/2.1.0 (Linux; U; Android 7.1.1; " \
207
+ "SM-T560NU Build/NMF26X) POS - Debug 2.4.10/1337 (1a5a407d00)/3405 Mozilla/5.0 " \
208
+ "(Linux; Android 7.1.1; SM-T560NU Build/NMF26X; wv) AppleWebKit/537.36 " \
209
+ "(KHTML, like Gecko) Version/4.0 Chrome/67.0.3396.87 Safari/537.36"
210
+ sniffer_with_suffix = BrowserSniffer.new(user_agent_with_suffix)
211
+
212
+ assert_equal ({
213
+ name: 'Shopify POS',
214
+ version: '2.4.10',
215
+ }), sniffer.browser_info
216
+
217
+ assert_equal ({
218
+ type: :handheld,
219
+ model: 'SM-T560NU',
220
+ }), sniffer.device_info
221
+
222
+ assert_equal ({
223
+ type: :android,
224
+ version: '7.1.1',
225
+ name: 'Android',
226
+ }), sniffer.os_info
227
+
228
+ assert_equal sniffer.browser_info, sniffer_with_suffix.browser_info
229
+ assert_equal sniffer.device_info, sniffer_with_suffix.device_info
230
+ assert_equal sniffer.os_info, sniffer_with_suffix.os_info
231
+ end
232
+
233
+ it "Shopify POS on Android can be sniffed (Native App)" do
234
+ user_agent = "Dalvik/2.1.0 (Linux; U; Android 7.1.1; SM-T560NU Build/NMF26X) " \
235
+ "POS - Debug 2.4.10 (1a5a407d00)/3405"
236
+ sniffer = BrowserSniffer.new(user_agent)
237
+
238
+ user_agent_with_suffix = "Dalvik/2.1.0 (Linux; U; Android 7.1.1; SM-T560NU Build/NMF26X) " \
239
+ "POS - Debug 2.4.10/1337 (1a5a407d00)/3405"
240
+ sniffer_with_suffix = BrowserSniffer.new(user_agent_with_suffix)
241
+
242
+ assert_equal ({
243
+ name: 'Shopify POS',
244
+ version: '2.4.10',
245
+ }), sniffer.browser_info
246
+
247
+ assert_equal ({
248
+ type: :handheld,
249
+ model: 'SM-T560NU',
250
+ }), sniffer.device_info
251
+
252
+ assert_equal ({
253
+ type: :android,
254
+ version: '7.1.1',
255
+ name: 'Android',
256
+ }), sniffer.os_info
257
+
258
+ assert_equal sniffer.browser_info, sniffer_with_suffix.browser_info
259
+ assert_equal sniffer.device_info, sniffer_with_suffix.device_info
260
+ assert_equal sniffer.os_info, sniffer_with_suffix.os_info
261
+ end
262
+
263
+ it "Shopify Mobile in debug mode can be parsed" do
264
+ user_agent = "Shopify Mobile/Android/6.0.0 (debug) (Build 1 with API 25 on Unknown Android SDK built for x86)"
265
+ sniffer = BrowserSniffer.new(user_agent)
266
+
267
+ assert_equal ({
268
+ name: 'Shopify Mobile',
269
+ version: '6.0.0 (debug)',
270
+ build: '1',
271
+ sdk_version: '25',
272
+ }), sniffer.browser_info
273
+
274
+ assert_equal ({
275
+ type: :handheld,
276
+ vendor: 'Unknown',
277
+ model: 'Android SDK built for x86',
278
+ }), sniffer.device_info
279
+
280
+ assert_equal ({
281
+ name: 'Android',
282
+ type: :android,
283
+ }), sniffer.os_info
284
+ end
285
+
286
+ it "Shopify Mobile in debug-push mode can be parsed" do
287
+ user_agent = "Shopify Mobile/Android/6.0.0 (debug-push) (Build 1 with API 25 on Unknown Android SDK built for x86)"
288
+ sniffer = BrowserSniffer.new(user_agent)
289
+
290
+ assert_equal ({
291
+ name: 'Shopify Mobile',
292
+ version: '6.0.0 (debug-push)',
293
+ build: '1',
294
+ sdk_version: '25',
295
+ }), sniffer.browser_info
296
+
297
+ assert_equal ({
298
+ type: :handheld,
299
+ vendor: 'Unknown',
300
+ model: 'Android SDK built for x86',
301
+ }), sniffer.device_info
302
+
303
+ assert_equal ({
304
+ name: 'Android',
305
+ type: :android,
306
+ }), sniffer.os_info
307
+ end
308
+
309
+ it "ShopifyFoundation user agent can be parsed" do
310
+ user_agent = "ShopifyFoundation"
311
+ sniffer = BrowserSniffer.new(user_agent)
312
+
313
+ assert_equal ({ name: 'ShopifyFoundation' }), sniffer.browser_info
314
+ assert_predicate sniffer.device_info, :empty?
315
+ assert_predicate sniffer.os_info, :empty?
316
+ end
317
+
318
+ it "old Shopify POS user agent can be parsed" do
319
+ user_agent = "Dalvik/2.1.0 (Linux; U; Android 5.1; KUAIKABAO/R5100 Build/LMY47I) Shopify POS 0.9.4"
320
+ sniffer = BrowserSniffer.new(user_agent)
321
+
322
+ user_agent_with_suffix = "Dalvik/2.1.0 (Linux; U; Android 5.1; KUAIKABAO/R5100 Build/LMY47I) Shopify POS 0.9.4/7"
323
+ sniffer_with_suffix = BrowserSniffer.new(user_agent_with_suffix)
324
+
325
+ assert_equal ({
326
+ name: 'Shopify POS',
327
+ version: '0.9.4',
328
+ }), sniffer.browser_info
329
+
330
+ assert_equal ({
331
+ type: :handheld,
332
+ }), sniffer.device_info
333
+
334
+ assert_equal ({
335
+ name: 'Android',
336
+ type: :android,
337
+ version: '5.1',
338
+ }), sniffer.os_info
339
+
340
+ assert_equal sniffer.browser_info, sniffer_with_suffix.browser_info
341
+ assert_equal sniffer.device_info, sniffer_with_suffix.device_info
342
+ assert_equal sniffer.os_info, sniffer_with_suffix.os_info
343
+ end
344
+
345
+ it "Shopify Ping on iOS can be sniffed" do
346
+ user_agent = "Shopify Ping/iOS/1.0.0 (iPhone9,1 Simulator/com.shopify.ping/11.1.0)"
347
+ sniffer = BrowserSniffer.new(user_agent)
348
+
349
+ assert_equal ({
350
+ name: 'Shopify Ping',
351
+ version: '1.0.0',
352
+ }), sniffer.browser_info
353
+
354
+ assert_equal ({
355
+ type: :handheld,
356
+ model: '9,1',
357
+ }), sniffer.device_info
358
+
359
+ assert_equal ({
360
+ type: :ios,
361
+ version: '11.1.0',
362
+ name: 'iOS',
363
+ }), sniffer.os_info
364
+ end
365
+ end
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
 
4
4
  require "#{File.dirname(__FILE__)}/../init"
5
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2018-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -45,6 +59,7 @@ executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
62
+ - ".github/probots.yml"
48
63
  - ".gitignore"
49
64
  - ".travis.yml"
50
65
  - Gemfile
@@ -58,6 +73,7 @@ files:
58
73
  - lib/browser_sniffer/version.rb
59
74
  - shipit.rubygems.yml
60
75
  - test/browser_sniffer_test.rb
76
+ - test/shopify_agents_test.rb
61
77
  - test/test_helper.rb
62
78
  homepage: https://github.com/Shopify/browser_sniffer
63
79
  licenses:
@@ -80,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
96
  version: '0'
81
97
  requirements: []
82
98
  rubyforge_project:
83
- rubygems_version: 2.5.2
99
+ rubygems_version: 2.6.14
84
100
  signing_key:
85
101
  specification_version: 4
86
102
  summary: Parses user agent strings and boils it all down to a few simple classifications.