device_detector 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -5
  3. data/CHANGELOG.md +3 -0
  4. data/README.md +5 -5
  5. data/Rakefile +13 -0
  6. data/lib/device_detector/version.rb +1 -1
  7. data/regexes/bots.yml +89 -2
  8. data/regexes/client/browser_engine.yml +3 -0
  9. data/regexes/client/browsers.yml +325 -76
  10. data/regexes/client/feed_readers.yml +6 -0
  11. data/regexes/client/libraries.yml +9 -0
  12. data/regexes/client/mobile_apps.yml +40 -1
  13. data/regexes/client/pim.yml +5 -0
  14. data/regexes/device/mobiles.yml +1607 -431
  15. data/regexes/oss.yml +1 -1
  16. data/regexes/vendorfragments.yml +1 -1
  17. data/spec/device_detector/concrete_user_agent_spec.rb +16 -17
  18. data/spec/device_detector/device_spec.rb +25 -25
  19. data/spec/device_detector/memory_cache_spec.rb +19 -19
  20. data/spec/device_detector/model_extractor_spec.rb +3 -3
  21. data/spec/device_detector/version_extractor_spec.rb +5 -6
  22. data/spec/device_detector_spec.rb +26 -26
  23. data/spec/fixtures/client/browser.yml +655 -322
  24. data/spec/fixtures/client/feed_reader.yml +39 -45
  25. data/spec/fixtures/client/library.yml +24 -11
  26. data/spec/fixtures/client/mediaplayer.yml +29 -28
  27. data/spec/fixtures/client/mobile_app.yml +100 -41
  28. data/spec/fixtures/client/pim.yml +32 -19
  29. data/spec/fixtures/detector/bots.yml +140 -23
  30. data/spec/fixtures/detector/camera.yml +2 -2
  31. data/spec/fixtures/detector/console.yml +3 -3
  32. data/spec/fixtures/detector/desktop.yml +312 -73
  33. data/spec/fixtures/detector/feature_phone.yml +48 -0
  34. data/spec/fixtures/detector/feed_reader.yml +141 -126
  35. data/spec/fixtures/detector/mediaplayer.yml +39 -38
  36. data/spec/fixtures/detector/mobile_apps.yml +86 -85
  37. data/spec/fixtures/detector/phablet.yml +715 -236
  38. data/spec/fixtures/detector/portable_media_player.yml +17 -0
  39. data/spec/fixtures/detector/smartphone-1.yml +3534 -3512
  40. data/spec/fixtures/detector/smartphone-10.yml +3848 -6286
  41. data/spec/fixtures/detector/smartphone-11.yml +5548 -3298
  42. data/spec/fixtures/detector/smartphone-12.yml +8655 -0
  43. data/spec/fixtures/detector/smartphone-2.yml +3645 -3625
  44. data/spec/fixtures/detector/smartphone-3.yml +4099 -4176
  45. data/spec/fixtures/detector/smartphone-4.yml +3861 -3865
  46. data/spec/fixtures/detector/smartphone-5.yml +3991 -4037
  47. data/spec/fixtures/detector/smartphone-6.yml +4074 -4047
  48. data/spec/fixtures/detector/smartphone-7.yml +4355 -4362
  49. data/spec/fixtures/detector/smartphone-8.yml +4087 -4136
  50. data/spec/fixtures/detector/smartphone-9.yml +4420 -4408
  51. data/spec/fixtures/detector/smartphone.yml +2900 -2904
  52. data/spec/fixtures/detector/tablet-1.yml +3946 -3912
  53. data/spec/fixtures/detector/tablet-2.yml +3593 -3617
  54. data/spec/fixtures/detector/tablet-3.yml +2738 -85
  55. data/spec/fixtures/detector/tablet.yml +3604 -3616
  56. data/spec/fixtures/detector/tv.yml +131 -51
  57. data/spec/fixtures/detector/unknown.yml +64 -27
  58. data/spec/fixtures/device/camera.yml +4 -3
  59. data/spec/fixtures/device/car_browser.yml +3 -2
  60. data/spec/fixtures/device/console.yml +15 -14
  61. metadata +4 -2
@@ -31,7 +31,7 @@
31
31
  ##########
32
32
  # Windows Mobile
33
33
  ##########
34
- - regex: 'Windows Phone (?:OS)?[ ]?(\d+[\.\d]+)'
34
+ - regex: '(?:Windows Phone (?:OS)?|wds)[ ]?(\d+[\.\d]+)'
35
35
  name: 'Windows Phone'
36
36
  version: '$1'
37
37
 
@@ -20,7 +20,7 @@ Sony:
20
20
 
21
21
  Asus:
22
22
  - 'MAAU'
23
- - 'NP0[6789]'
23
+ - 'NP0[26789]'
24
24
  - 'ASJB'
25
25
  - 'ASU2(JS)?'
26
26
 
@@ -13,7 +13,7 @@ describe DeviceDetector do
13
13
  describe '#device_name' do
14
14
 
15
15
  it 'returns device name' do
16
- client.device_name.must_equal 'iPhone 5S'
16
+ value(client.device_name).must_equal 'iPhone 5S'
17
17
  end
18
18
 
19
19
  end
@@ -21,7 +21,7 @@ describe DeviceDetector do
21
21
  describe '#device_type' do
22
22
 
23
23
  it 'returns the device type' do
24
- client.device_type.must_equal 'smartphone'
24
+ value(client.device_type).must_equal 'smartphone'
25
25
  end
26
26
 
27
27
  end
@@ -35,7 +35,7 @@ describe DeviceDetector do
35
35
  describe '#os_name' do
36
36
 
37
37
  it 'returns the OS name' do
38
- client.os_name.must_equal 'Ubuntu'
38
+ value(client.os_name).must_equal 'Ubuntu'
39
39
  end
40
40
 
41
41
  end
@@ -49,7 +49,7 @@ describe DeviceDetector do
49
49
  describe '#full_version' do
50
50
 
51
51
  it 'returns the correct OS version' do
52
- client.os_full_version.must_equal '10.10.1'
52
+ value(client.os_full_version).must_equal '10.10.1'
53
53
  end
54
54
 
55
55
  end
@@ -63,15 +63,15 @@ describe DeviceDetector do
63
63
  let(:user_agent) { 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36' }
64
64
 
65
65
  it 'returns the correct client name' do
66
- client.name.must_equal 'Chrome'
66
+ value(client.name).must_equal 'Chrome'
67
67
  end
68
68
 
69
69
  it 'recognizes the device name' do
70
- client.device_name.must_be_nil
70
+ value(client.device_name).must_be_nil
71
71
  end
72
72
 
73
73
  it 'recognizes the device type' do
74
- client.device_type.must_equal "desktop"
74
+ value(client.device_type).must_equal "desktop"
75
75
  end
76
76
 
77
77
  end
@@ -81,15 +81,15 @@ describe DeviceDetector do
81
81
  let(:user_agent) { 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' }
82
82
 
83
83
  it 'returns the correct client name' do
84
- client.name.must_equal 'Chrome'
84
+ value(client.name).must_equal 'Chrome'
85
85
  end
86
86
 
87
87
  it 'recognizes the device name' do
88
- client.device_name.must_be_nil
88
+ value(client.device_name).must_be_nil
89
89
  end
90
90
 
91
91
  it 'recognizes the device type' do
92
- client.device_type.must_equal "desktop"
92
+ value(client.device_type).must_equal "desktop"
93
93
  end
94
94
 
95
95
  end
@@ -101,15 +101,15 @@ describe DeviceDetector do
101
101
  let(:user_agent) { 'sprd-Galaxy-S5/1.0 Linux/2.6.35.7 Android/4.4.4 Release/11.29.2014 Browser/AppleWebKit533.1 (KHTML, like Gecko) Mozilla/5.0 Mobile' }
102
102
 
103
103
  it 'returns the correct client name' do
104
- client.name.must_equal "Android Browser"
104
+ value(client.name).must_equal "Android Browser"
105
105
  end
106
106
 
107
107
  it 'recognizes the device name' do
108
- client.device_name.must_equal "GALAXY S5"
108
+ value(client.device_name).must_equal "GALAXY S5"
109
109
  end
110
110
 
111
111
  it 'recognizes the device type' do
112
- client.device_type.must_equal "smartphone"
112
+ value(client.device_type).must_equal "smartphone"
113
113
  end
114
114
 
115
115
  end
@@ -119,18 +119,17 @@ describe DeviceDetector do
119
119
  let(:user_agent) { 'Lenovo-A398t+_TD/S100 Linux/3.4.5 Android/4.1.2 Release/09.10.2013 Browser/AppleWebKit534.30 Mobile Safari/534.30' }
120
120
 
121
121
  it 'returns the correct client name' do
122
- client.name.must_equal "Android Browser"
122
+ value(client.name).must_equal "Android Browser"
123
123
  end
124
124
 
125
125
  it 'recognizes the device name' do
126
- client.device_name.must_equal "A398t+"
126
+ value(client.device_name).must_equal "A398t+"
127
127
  end
128
128
 
129
129
  it 'recognizes the device type' do
130
- client.device_type.must_equal "smartphone"
130
+ value(client.device_type).must_equal "smartphone"
131
131
  end
132
132
 
133
133
  end
134
134
 
135
135
  end
136
-
@@ -12,7 +12,7 @@ describe DeviceDetector::Device do
12
12
  let(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B466 [FBDV/iPhone7,2]' }
13
13
 
14
14
  it 'finds an Apple iPhone 6' do
15
- device.name.must_equal 'iPhone 6'
15
+ value(device.name).must_equal 'iPhone 6'
16
16
  end
17
17
  end
18
18
 
@@ -20,7 +20,7 @@ describe DeviceDetector::Device do
20
20
  let(:user_agent) { 'AIRNESS-AIR99/REV 2.2.1/Teleca Q03B1' }
21
21
 
22
22
  it 'finds an Airness AIR99' do
23
- device.name.must_equal 'AIR99'
23
+ value(device.name).must_equal 'AIR99'
24
24
  end
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ describe DeviceDetector::Device do
28
28
  let(:user_agent) { 'UNKNOWN MODEL NAME' }
29
29
 
30
30
  it 'returns nil' do
31
- device.name.must_be_nil
31
+ value(device.name).must_be_nil
32
32
  end
33
33
  end
34
34
 
@@ -40,7 +40,7 @@ describe DeviceDetector::Device do
40
40
  let(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B466 [FBDV/iPhone7,2]' }
41
41
 
42
42
  it 'finds device of Apple iPhone 6' do
43
- device.type.must_equal 'smartphone'
43
+ value(device.type).must_equal 'smartphone'
44
44
  end
45
45
  end
46
46
 
@@ -48,7 +48,7 @@ describe DeviceDetector::Device do
48
48
  let(:user_agent) { 'AIRNESS-AIR99/REV 2.2.1/Teleca Q03B1' }
49
49
 
50
50
  it 'finds the device of Airness AIR99' do
51
- device.type.must_equal 'feature phone'
51
+ value(device.type).must_equal 'feature phone'
52
52
  end
53
53
  end
54
54
 
@@ -56,7 +56,7 @@ describe DeviceDetector::Device do
56
56
  let(:user_agent) { 'UNKNOWN MODEL TYPE' }
57
57
 
58
58
  it 'returns nil' do
59
- device.type.must_be_nil
59
+ value(device.type).must_be_nil
60
60
  end
61
61
 
62
62
  end
@@ -66,7 +66,7 @@ describe DeviceDetector::Device do
66
66
  let(:user_agent) { 'Mozilla/5.0 (Linux; Android 4.4.2; es-us; SAMSUNG SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko)' }
67
67
 
68
68
  it 'falls back to top-level device' do
69
- device.type.must_equal 'smartphone'
69
+ value(device.type).must_equal 'smartphone'
70
70
  end
71
71
 
72
72
  end
@@ -80,9 +80,9 @@ describe DeviceDetector::Device do
80
80
  let(:user_agent) { 'Mozilla/5.0 (Linux; Android 4.4.2; es-us; SAMSUNG SM-G900F Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko)' }
81
81
 
82
82
  it 'identifies the device' do
83
- device.name.must_equal 'GALAXY S5'
84
- device.type.must_equal 'smartphone'
85
- device.brand.must_equal 'Samsung'
83
+ value(device.name).must_equal 'GALAXY S5'
84
+ value(device.type).must_equal 'smartphone'
85
+ value(device.brand).must_equal 'Samsung'
86
86
  end
87
87
 
88
88
  end
@@ -92,9 +92,9 @@ describe DeviceDetector::Device do
92
92
  let(:user_agent) { 'Mozilla/5.0 (Linux; U; Android 4.0; xx-xx; EK-GC100 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30' }
93
93
 
94
94
  it 'identifies the device' do
95
- device.name.must_equal 'GALAXY Camera'
96
- device.type.must_equal 'camera'
97
- device.brand.must_equal 'Samsung'
95
+ value(device.name).must_equal 'GALAXY Camera'
96
+ value(device.type).must_equal 'camera'
97
+ value(device.brand).must_equal 'Samsung'
98
98
  end
99
99
 
100
100
  end
@@ -104,9 +104,9 @@ describe DeviceDetector::Device do
104
104
  let(:user_agent) { 'Mozilla/5.0 (X11; Linux) AppleWebKit/534.34 (KHTML, like Gecko) QtCarBrowser Safari/534.34' }
105
105
 
106
106
  it 'identifies the device' do
107
- device.name.must_equal 'Model S'
108
- device.type.must_equal 'car browser'
109
- device.brand.must_be_nil
107
+ value(device.name).must_equal 'Model S'
108
+ value(device.type).must_equal 'car browser'
109
+ value(device.brand).must_be_nil
110
110
  end
111
111
 
112
112
  end
@@ -116,9 +116,9 @@ describe DeviceDetector::Device do
116
116
  let(:user_agent) { 'Opera/9.30 (Nintendo Wii; U; ; 2047-7;en)' }
117
117
 
118
118
  it 'identifies the device' do
119
- device.name.must_equal 'Wii'
120
- device.type.must_equal 'console'
121
- device.brand.must_be_nil
119
+ value(device.name).must_equal 'Wii'
120
+ value(device.type).must_equal 'console'
121
+ value(device.brand).must_be_nil
122
122
  end
123
123
 
124
124
  end
@@ -128,9 +128,9 @@ describe DeviceDetector::Device do
128
128
  let(:user_agent) { 'Mozilla/5.0 (iPod touch; CPU iPhone OS 7_0_6 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B651 Safari/9537.53' }
129
129
 
130
130
  it 'identifies the device' do
131
- device.name.must_equal 'iPod Touch'
132
- device.type.must_equal 'portable media player'
133
- device.brand.must_equal 'Apple'
131
+ value(device.name).must_equal 'iPod Touch'
132
+ value(device.type).must_equal 'portable media player'
133
+ value(device.brand).must_equal 'Apple'
134
134
  end
135
135
 
136
136
  end
@@ -140,9 +140,9 @@ describe DeviceDetector::Device do
140
140
  let(:user_agent) { 'Mozilla/5.0 (Unknown; Linux armv7l) AppleWebKit/537.1+ (KHTML, like Gecko) Safari/537.1+ HbbTV/1.1.1 ( ;LGE ;NetCast 4.0 ;03.10.81 ;1.0M ;)' }
141
141
 
142
142
  it 'identifies the device' do
143
- device.name.must_equal 'NetCast 4.0'
144
- device.type.must_equal 'tv'
145
- device.brand.must_equal 'LG'
143
+ value(device.name).must_equal 'NetCast 4.0'
144
+ value(device.type).must_equal 'tv'
145
+ value(device.brand).must_equal 'LG'
146
146
  end
147
147
 
148
148
  end
@@ -14,12 +14,12 @@ describe DeviceDetector::MemoryCache do
14
14
  it 'sets the value under the key' do
15
15
  subject.set(key, 'value')
16
16
 
17
- subject.data[key].must_equal 'value'
17
+ value(subject.data[key]).must_equal 'value'
18
18
  end
19
19
 
20
20
  it 'returns the value' do
21
- subject.set(key, 'value').must_equal 'value'
22
- subject.set(key, false).must_equal false
21
+ value(subject.set(key, 'value')).must_equal 'value'
22
+ value(subject.set(key, false)).must_equal false
23
23
  assert_nil subject.set(key, nil)
24
24
  end
25
25
  end
@@ -30,7 +30,7 @@ describe DeviceDetector::MemoryCache do
30
30
  it 'sets the value under the key' do
31
31
  subject.set(key, 'value')
32
32
 
33
- subject.data[String(key)].must_equal 'value'
33
+ value(subject.data[String(key)]).must_equal 'value'
34
34
  end
35
35
  end
36
36
 
@@ -41,14 +41,14 @@ describe DeviceDetector::MemoryCache do
41
41
  it 'sets the value under the key' do
42
42
  subject.set(key, nil)
43
43
 
44
- subject.data[String(key)].must_equal internal_value
44
+ value(subject.data[String(key)]).must_equal internal_value
45
45
  assert_nil subject.get(key)
46
46
  end
47
47
 
48
48
  it 'sets the value under the key' do
49
49
  subject.get_or_set(key, nil)
50
50
 
51
- subject.data[String(key)].must_equal internal_value
51
+ value(subject.data[String(key)]).must_equal internal_value
52
52
  assert_nil subject.get(key)
53
53
  end
54
54
  end
@@ -59,15 +59,15 @@ describe DeviceDetector::MemoryCache do
59
59
  it 'sets the value under the key' do
60
60
  subject.set(key, false)
61
61
 
62
- subject.data[String(key)].must_equal false
63
- subject.get(key).must_equal false
62
+ value(subject.data[String(key)]).must_equal false
63
+ value(subject.get(key)).must_equal false
64
64
  end
65
65
 
66
66
  it 'sets the value under the key' do
67
67
  subject.get_or_set(key, false)
68
68
 
69
- subject.data[String(key)].must_equal false
70
- subject.get(key).must_equal false
69
+ value(subject.data[String(key)]).must_equal false
70
+ value(subject.get(key)).must_equal false
71
71
  end
72
72
  end
73
73
  end
@@ -79,7 +79,7 @@ describe DeviceDetector::MemoryCache do
79
79
  it 'gets the value for the key' do
80
80
  subject.data[key] = 'value'
81
81
 
82
- subject.get(key).must_equal 'value'
82
+ value(subject.get(key)).must_equal 'value'
83
83
  end
84
84
  end
85
85
 
@@ -89,7 +89,7 @@ describe DeviceDetector::MemoryCache do
89
89
  it 'gets the value for the key' do
90
90
  subject.data[String(key)] = 'value'
91
91
 
92
- subject.get(key).must_equal 'value'
92
+ value(subject.get(key)).must_equal 'value'
93
93
  end
94
94
  end
95
95
  end
@@ -106,13 +106,13 @@ describe DeviceDetector::MemoryCache do
106
106
  block_called = true
107
107
  end
108
108
 
109
- value.must_equal 'value'
110
- block_called.must_equal false
109
+ value(value).must_equal 'value'
110
+ value(block_called).must_equal false
111
111
  end
112
112
 
113
113
  it 'returns the value' do
114
114
  subject.data[key] = 'value2'
115
- subject.get_or_set(key, 'value').must_equal 'value2'
115
+ value(subject.get_or_set(key, 'value')).must_equal 'value2'
116
116
  end
117
117
  end
118
118
 
@@ -123,12 +123,12 @@ describe DeviceDetector::MemoryCache do
123
123
  block_called = true
124
124
  end
125
125
 
126
- block_called.must_equal true
127
- subject.data[key].must_equal true
126
+ value(block_called).must_equal true
127
+ value(subject.data[key]).must_equal true
128
128
  end
129
129
 
130
130
  it 'returns the value' do
131
- subject.get_or_set(key, 'value').must_equal 'value'
131
+ value(subject.get_or_set(key, 'value')).must_equal 'value'
132
132
  end
133
133
  end
134
134
  end
@@ -142,7 +142,7 @@ describe DeviceDetector::MemoryCache do
142
142
  subject.set('3', 'baz')
143
143
  subject.set('4', 'boz')
144
144
 
145
- subject.data.keys.size.must_equal 3
145
+ value(subject.data.keys.size).must_equal 3
146
146
  end
147
147
  end
148
148
  end
@@ -23,7 +23,7 @@ describe DeviceDetector::ModelExtractor do
23
23
  let(:device_name) { 'iPhone' }
24
24
 
25
25
  it 'returns the textual portion without trailing whitespace' do
26
- extractor.call.must_equal device_name
26
+ value(extractor.call).must_equal device_name
27
27
  end
28
28
 
29
29
  end
@@ -33,7 +33,7 @@ describe DeviceDetector::ModelExtractor do
33
33
  let(:device_name) { 'iPhone 5S' }
34
34
 
35
35
  it 'returns the full device name' do
36
- extractor.call.must_equal device_name
36
+ value(extractor.call).must_equal device_name
37
37
  end
38
38
 
39
39
  end
@@ -53,7 +53,7 @@ describe DeviceDetector::ModelExtractor do
53
53
  end
54
54
 
55
55
  it 'returns the model name' do
56
- extractor.call.must_equal device_name
56
+ value(extractor.call).must_equal device_name
57
57
  end
58
58
 
59
59
  end
@@ -21,7 +21,7 @@ describe DeviceDetector::VersionExtractor do
21
21
  end
22
22
 
23
23
  it 'returns nil' do
24
- extractor.call.must_equal ''
24
+ value(extractor.call).must_equal ''
25
25
  end
26
26
 
27
27
  end
@@ -39,12 +39,12 @@ describe DeviceDetector::VersionExtractor do
39
39
  end
40
40
 
41
41
  it 'returns the correct version' do
42
- extractor.call.must_equal version
42
+ value(extractor.call).must_equal version
43
43
  end
44
44
 
45
45
  it 'removes trailing white spaces' do
46
46
  regex_meta[:version] = regex_meta[:version] + ' '
47
- extractor.call.must_equal version
47
+ value(extractor.call).must_equal version
48
48
  end
49
49
 
50
50
  end
@@ -60,7 +60,7 @@ describe DeviceDetector::VersionExtractor do
60
60
  end
61
61
 
62
62
  it 'returns the correct version' do
63
- extractor.call.must_equal '8.0'
63
+ value(extractor.call).must_equal '8.0'
64
64
  end
65
65
 
66
66
  end
@@ -71,10 +71,9 @@ describe DeviceDetector::VersionExtractor do
71
71
  let(:regex_meta) { {} }
72
72
 
73
73
  it 'returns nil' do
74
- extractor.call.must_be_nil
74
+ value(extractor.call).must_be_nil
75
75
  end
76
76
 
77
77
  end
78
78
  end
79
79
  end
80
-