device_detector 1.0.0 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +58 -4
- data/README.md +57 -21
- data/lib/device_detector/bot.rb +2 -2
- data/lib/device_detector/browser.rb +691 -0
- data/lib/device_detector/client.rb +11 -2
- data/lib/device_detector/client_hint.rb +249 -0
- data/lib/device_detector/device.rb +1954 -23
- data/lib/device_detector/memory_cache.rb +26 -19
- data/lib/device_detector/metadata_extractor.rb +7 -8
- data/lib/device_detector/model_extractor.rb +3 -3
- data/lib/device_detector/name_extractor.rb +2 -2
- data/lib/device_detector/os.rb +289 -112
- data/lib/device_detector/parser.rb +49 -13
- data/lib/device_detector/vendor_fragment.rb +25 -0
- data/lib/device_detector/version.rb +3 -1
- data/lib/device_detector/version_extractor.rb +29 -2
- data/lib/device_detector.rb +192 -44
- data/regexes/bots.yml +3399 -91
- data/regexes/client/browser_engine.yml +28 -4
- data/regexes/client/browsers.yml +2697 -408
- data/regexes/client/feed_readers.yml +60 -22
- data/regexes/client/hints/apps.yml +150 -0
- data/regexes/client/hints/browsers.yml +292 -0
- data/regexes/client/libraries.yml +598 -4
- data/regexes/client/mediaplayers.yml +110 -5
- data/regexes/client/mobile_apps.yml +2451 -14
- data/regexes/client/pim.yml +128 -3
- data/regexes/device/cameras.yml +6 -6
- data/regexes/device/car_browsers.yml +39 -3
- data/regexes/device/consoles.yml +40 -6
- data/regexes/device/mobiles.yml +38844 -2907
- data/regexes/device/notebooks.yml +127 -0
- data/regexes/device/portable_media_player.yml +75 -12
- data/regexes/device/shell_tv.yml +145 -0
- data/regexes/device/televisions.yml +981 -40
- data/regexes/oss.yml +1560 -311
- data/regexes/vendorfragments.yml +6 -2
- metadata +31 -105
- data/.gitignore +0 -14
- data/.travis.yml +0 -18
- data/Gemfile +0 -8
- data/Rakefile +0 -79
- data/device_detector.gemspec +0 -26
- data/spec/device_detector/bot_fixtures_spec.rb +0 -30
- data/spec/device_detector/client_fixtures_spec.rb +0 -31
- data/spec/device_detector/concrete_user_agent_spec.rb +0 -136
- data/spec/device_detector/detector_fixtures_spec.rb +0 -60
- data/spec/device_detector/device_fixtures_spec.rb +0 -36
- data/spec/device_detector/device_spec.rb +0 -151
- data/spec/device_detector/memory_cache_spec.rb +0 -116
- data/spec/device_detector/model_extractor_spec.rb +0 -63
- data/spec/device_detector/os_fixtures_spec.rb +0 -26
- data/spec/device_detector/version_extractor_spec.rb +0 -80
- data/spec/device_detector_spec.rb +0 -198
- data/spec/fixtures/client/browser.yml +0 -1313
- data/spec/fixtures/client/feed_reader.yml +0 -187
- data/spec/fixtures/client/library.yml +0 -84
- data/spec/fixtures/client/mediaplayer.yml +0 -168
- data/spec/fixtures/client/mobile_app.yml +0 -30
- data/spec/fixtures/client/pim.yml +0 -96
- data/spec/fixtures/detector/bots.yml +0 -2418
- data/spec/fixtures/detector/camera.yml +0 -115
- data/spec/fixtures/detector/car_browser.yml +0 -20
- data/spec/fixtures/detector/console.yml +0 -267
- data/spec/fixtures/detector/desktop.yml +0 -4828
- data/spec/fixtures/detector/feature_phone.yml +0 -782
- data/spec/fixtures/detector/feed_reader.yml +0 -486
- data/spec/fixtures/detector/mediaplayer.yml +0 -179
- data/spec/fixtures/detector/mobile_apps.yml +0 -149
- data/spec/fixtures/detector/phablet.yml +0 -2140
- data/spec/fixtures/detector/portable_media_player.yml +0 -153
- data/spec/fixtures/detector/smart_display.yml +0 -58
- data/spec/fixtures/detector/smartphone-1.yml +0 -9469
- data/spec/fixtures/detector/smartphone-2.yml +0 -9414
- data/spec/fixtures/detector/smartphone-3.yml +0 -9396
- data/spec/fixtures/detector/smartphone-4.yml +0 -5742
- data/spec/fixtures/detector/smartphone.yml +0 -9411
- data/spec/fixtures/detector/tablet-1.yml +0 -9495
- data/spec/fixtures/detector/tablet-2.yml +0 -248
- data/spec/fixtures/detector/tablet.yml +0 -9484
- data/spec/fixtures/detector/tv.yml +0 -2582
- data/spec/fixtures/detector/unknown.yml +0 -3196
- data/spec/fixtures/device/camera.yml +0 -18
- data/spec/fixtures/device/car_browser.yml +0 -6
- data/spec/fixtures/device/console.yml +0 -78
- data/spec/fixtures/parser/oss.yml +0 -800
- data/spec/fixtures/parser/vendorfragments.yml +0 -162
- data/spec/spec_helper.rb +0 -9
data/regexes/vendorfragments.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
###############
|
2
2
|
# Device Detector - The Universal Device Detection library for parsing User Agents
|
3
3
|
#
|
4
|
-
# @link
|
4
|
+
# @link https://matomo.org
|
5
5
|
# @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
|
6
6
|
###############
|
7
7
|
|
@@ -20,7 +20,7 @@ Sony:
|
|
20
20
|
|
21
21
|
Asus:
|
22
22
|
- 'MAAU'
|
23
|
-
- 'NP0[
|
23
|
+
- 'NP0[26789]'
|
24
24
|
- 'ASJB'
|
25
25
|
- 'ASU2(JS)?'
|
26
26
|
|
@@ -69,3 +69,7 @@ HP:
|
|
69
69
|
|
70
70
|
Hyrican:
|
71
71
|
- 'MANM(JS)?'
|
72
|
+
|
73
|
+
Ordissimo:
|
74
|
+
- 'Ordissimo'
|
75
|
+
- 'webissimo3'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: device_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mati Sójka
|
8
8
|
- Ben Zimmer
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0.10'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rubocop
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.85.1
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.85.1
|
56
70
|
description: Precise and fast user agent parser and device detector, backed by the
|
57
71
|
largest and most up-to-date agent and device database
|
58
72
|
email:
|
@@ -61,17 +75,14 @@ executables: []
|
|
61
75
|
extensions: []
|
62
76
|
extra_rdoc_files: []
|
63
77
|
files:
|
64
|
-
- ".gitignore"
|
65
|
-
- ".travis.yml"
|
66
78
|
- CHANGELOG.md
|
67
|
-
- Gemfile
|
68
79
|
- LICENSE.txt
|
69
80
|
- README.md
|
70
|
-
- Rakefile
|
71
|
-
- device_detector.gemspec
|
72
81
|
- lib/device_detector.rb
|
73
82
|
- lib/device_detector/bot.rb
|
83
|
+
- lib/device_detector/browser.rb
|
74
84
|
- lib/device_detector/client.rb
|
85
|
+
- lib/device_detector/client_hint.rb
|
75
86
|
- lib/device_detector/device.rb
|
76
87
|
- lib/device_detector/memory_cache.rb
|
77
88
|
- lib/device_detector/metadata_extractor.rb
|
@@ -79,12 +90,15 @@ files:
|
|
79
90
|
- lib/device_detector/name_extractor.rb
|
80
91
|
- lib/device_detector/os.rb
|
81
92
|
- lib/device_detector/parser.rb
|
93
|
+
- lib/device_detector/vendor_fragment.rb
|
82
94
|
- lib/device_detector/version.rb
|
83
95
|
- lib/device_detector/version_extractor.rb
|
84
96
|
- regexes/bots.yml
|
85
97
|
- regexes/client/browser_engine.yml
|
86
98
|
- regexes/client/browsers.yml
|
87
99
|
- regexes/client/feed_readers.yml
|
100
|
+
- regexes/client/hints/apps.yml
|
101
|
+
- regexes/client/hints/browsers.yml
|
88
102
|
- regexes/client/libraries.yml
|
89
103
|
- regexes/client/mediaplayers.yml
|
90
104
|
- regexes/client/mobile_apps.yml
|
@@ -93,60 +107,18 @@ files:
|
|
93
107
|
- regexes/device/car_browsers.yml
|
94
108
|
- regexes/device/consoles.yml
|
95
109
|
- regexes/device/mobiles.yml
|
110
|
+
- regexes/device/notebooks.yml
|
96
111
|
- regexes/device/portable_media_player.yml
|
112
|
+
- regexes/device/shell_tv.yml
|
97
113
|
- regexes/device/televisions.yml
|
98
114
|
- regexes/oss.yml
|
99
115
|
- regexes/vendorfragments.yml
|
100
|
-
- spec/device_detector/bot_fixtures_spec.rb
|
101
|
-
- spec/device_detector/client_fixtures_spec.rb
|
102
|
-
- spec/device_detector/concrete_user_agent_spec.rb
|
103
|
-
- spec/device_detector/detector_fixtures_spec.rb
|
104
|
-
- spec/device_detector/device_fixtures_spec.rb
|
105
|
-
- spec/device_detector/device_spec.rb
|
106
|
-
- spec/device_detector/memory_cache_spec.rb
|
107
|
-
- spec/device_detector/model_extractor_spec.rb
|
108
|
-
- spec/device_detector/os_fixtures_spec.rb
|
109
|
-
- spec/device_detector/version_extractor_spec.rb
|
110
|
-
- spec/device_detector_spec.rb
|
111
|
-
- spec/fixtures/client/browser.yml
|
112
|
-
- spec/fixtures/client/feed_reader.yml
|
113
|
-
- spec/fixtures/client/library.yml
|
114
|
-
- spec/fixtures/client/mediaplayer.yml
|
115
|
-
- spec/fixtures/client/mobile_app.yml
|
116
|
-
- spec/fixtures/client/pim.yml
|
117
|
-
- spec/fixtures/detector/bots.yml
|
118
|
-
- spec/fixtures/detector/camera.yml
|
119
|
-
- spec/fixtures/detector/car_browser.yml
|
120
|
-
- spec/fixtures/detector/console.yml
|
121
|
-
- spec/fixtures/detector/desktop.yml
|
122
|
-
- spec/fixtures/detector/feature_phone.yml
|
123
|
-
- spec/fixtures/detector/feed_reader.yml
|
124
|
-
- spec/fixtures/detector/mediaplayer.yml
|
125
|
-
- spec/fixtures/detector/mobile_apps.yml
|
126
|
-
- spec/fixtures/detector/phablet.yml
|
127
|
-
- spec/fixtures/detector/portable_media_player.yml
|
128
|
-
- spec/fixtures/detector/smart_display.yml
|
129
|
-
- spec/fixtures/detector/smartphone-1.yml
|
130
|
-
- spec/fixtures/detector/smartphone-2.yml
|
131
|
-
- spec/fixtures/detector/smartphone-3.yml
|
132
|
-
- spec/fixtures/detector/smartphone-4.yml
|
133
|
-
- spec/fixtures/detector/smartphone.yml
|
134
|
-
- spec/fixtures/detector/tablet-1.yml
|
135
|
-
- spec/fixtures/detector/tablet-2.yml
|
136
|
-
- spec/fixtures/detector/tablet.yml
|
137
|
-
- spec/fixtures/detector/tv.yml
|
138
|
-
- spec/fixtures/detector/unknown.yml
|
139
|
-
- spec/fixtures/device/camera.yml
|
140
|
-
- spec/fixtures/device/car_browser.yml
|
141
|
-
- spec/fixtures/device/console.yml
|
142
|
-
- spec/fixtures/parser/oss.yml
|
143
|
-
- spec/fixtures/parser/vendorfragments.yml
|
144
|
-
- spec/spec_helper.rb
|
145
116
|
homepage: http://podigee.github.io/device_detector
|
146
117
|
licenses:
|
147
118
|
- LGPL-3.0
|
148
|
-
metadata:
|
149
|
-
|
119
|
+
metadata:
|
120
|
+
changelog_uri: https://github.com/podigee/device_detector/blob/develop/CHANGELOG.md
|
121
|
+
post_install_message:
|
150
122
|
rdoc_options: []
|
151
123
|
require_paths:
|
152
124
|
- lib
|
@@ -154,61 +126,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
126
|
requirements:
|
155
127
|
- - ">="
|
156
128
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
129
|
+
version: 2.7.5
|
158
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
131
|
requirements:
|
160
132
|
- - ">="
|
161
133
|
- !ruby/object:Gem::Version
|
162
134
|
version: '0'
|
163
135
|
requirements: []
|
164
|
-
|
165
|
-
|
166
|
-
signing_key:
|
136
|
+
rubygems_version: 3.4.1
|
137
|
+
signing_key:
|
167
138
|
specification_version: 4
|
168
139
|
summary: Precise and fast user agent parser and device detector
|
169
|
-
test_files:
|
170
|
-
- spec/device_detector/bot_fixtures_spec.rb
|
171
|
-
- spec/device_detector/client_fixtures_spec.rb
|
172
|
-
- spec/device_detector/concrete_user_agent_spec.rb
|
173
|
-
- spec/device_detector/detector_fixtures_spec.rb
|
174
|
-
- spec/device_detector/device_fixtures_spec.rb
|
175
|
-
- spec/device_detector/device_spec.rb
|
176
|
-
- spec/device_detector/memory_cache_spec.rb
|
177
|
-
- spec/device_detector/model_extractor_spec.rb
|
178
|
-
- spec/device_detector/os_fixtures_spec.rb
|
179
|
-
- spec/device_detector/version_extractor_spec.rb
|
180
|
-
- spec/device_detector_spec.rb
|
181
|
-
- spec/fixtures/client/browser.yml
|
182
|
-
- spec/fixtures/client/feed_reader.yml
|
183
|
-
- spec/fixtures/client/library.yml
|
184
|
-
- spec/fixtures/client/mediaplayer.yml
|
185
|
-
- spec/fixtures/client/mobile_app.yml
|
186
|
-
- spec/fixtures/client/pim.yml
|
187
|
-
- spec/fixtures/detector/bots.yml
|
188
|
-
- spec/fixtures/detector/camera.yml
|
189
|
-
- spec/fixtures/detector/car_browser.yml
|
190
|
-
- spec/fixtures/detector/console.yml
|
191
|
-
- spec/fixtures/detector/desktop.yml
|
192
|
-
- spec/fixtures/detector/feature_phone.yml
|
193
|
-
- spec/fixtures/detector/feed_reader.yml
|
194
|
-
- spec/fixtures/detector/mediaplayer.yml
|
195
|
-
- spec/fixtures/detector/mobile_apps.yml
|
196
|
-
- spec/fixtures/detector/phablet.yml
|
197
|
-
- spec/fixtures/detector/portable_media_player.yml
|
198
|
-
- spec/fixtures/detector/smart_display.yml
|
199
|
-
- spec/fixtures/detector/smartphone-1.yml
|
200
|
-
- spec/fixtures/detector/smartphone-2.yml
|
201
|
-
- spec/fixtures/detector/smartphone-3.yml
|
202
|
-
- spec/fixtures/detector/smartphone-4.yml
|
203
|
-
- spec/fixtures/detector/smartphone.yml
|
204
|
-
- spec/fixtures/detector/tablet-1.yml
|
205
|
-
- spec/fixtures/detector/tablet-2.yml
|
206
|
-
- spec/fixtures/detector/tablet.yml
|
207
|
-
- spec/fixtures/detector/tv.yml
|
208
|
-
- spec/fixtures/detector/unknown.yml
|
209
|
-
- spec/fixtures/device/camera.yml
|
210
|
-
- spec/fixtures/device/car_browser.yml
|
211
|
-
- spec/fixtures/device/console.yml
|
212
|
-
- spec/fixtures/parser/oss.yml
|
213
|
-
- spec/fixtures/parser/vendorfragments.yml
|
214
|
-
- spec/spec_helper.rb
|
140
|
+
test_files: []
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
rvm:
|
4
|
-
- 1.9.3
|
5
|
-
- 2.0.0-p648
|
6
|
-
- 2.1.10
|
7
|
-
- 2.2.5
|
8
|
-
- 2.3.1
|
9
|
-
- ruby-head
|
10
|
-
- rbx-2
|
11
|
-
before_install:
|
12
|
-
- gem update --system
|
13
|
-
- gem --version
|
14
|
-
- gem update bundler
|
15
|
-
- bundler --version
|
16
|
-
cache: bundler
|
17
|
-
script:
|
18
|
-
bundle exec rake test
|
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
|
4
|
-
$:.unshift 'lib'
|
5
|
-
require 'device_detector'
|
6
|
-
|
7
|
-
Rake::TestTask.new do |t|
|
8
|
-
t.pattern = 'spec/**/*_spec.rb'
|
9
|
-
t.libs.push 'spec'
|
10
|
-
end
|
11
|
-
|
12
|
-
task default: :test
|
13
|
-
|
14
|
-
task :detectable_names do
|
15
|
-
bot_names = DeviceDetector::Bot.new.send(:regexes).map { |r| r[:name] }.uniq.sort_by { |n| n.downcase }
|
16
|
-
bot_names.delete('$1')
|
17
|
-
client_names = DeviceDetector::Client.new.send(:regexes).map { |r| r[:name] }.uniq.sort_by { |n| n.downcase }
|
18
|
-
client_names.delete('$1')
|
19
|
-
device = DeviceDetector::Device.new
|
20
|
-
device_paths = device.send(:filepaths)
|
21
|
-
device_regexes = device.send(:load_regexes, device_paths)
|
22
|
-
device_names = device_regexes.flat_map { |dn| dn[1].keys }.uniq.sort_by { |n| n.downcase }
|
23
|
-
|
24
|
-
today = Date.today.strftime
|
25
|
-
|
26
|
-
puts '## Detectable clients, bots and devices'
|
27
|
-
puts
|
28
|
-
puts "Updated on #{today}"
|
29
|
-
puts
|
30
|
-
puts '### Bots'
|
31
|
-
puts
|
32
|
-
puts bot_names.join(', ')
|
33
|
-
puts
|
34
|
-
puts '### Clients'
|
35
|
-
puts
|
36
|
-
puts client_names.join(', ')
|
37
|
-
puts
|
38
|
-
puts '### Devices'
|
39
|
-
puts
|
40
|
-
puts device_names.join(', ')
|
41
|
-
puts
|
42
|
-
end
|
43
|
-
|
44
|
-
PIWIK_REPO_URL = 'https://github.com/piwik/device-detector.git'.freeze
|
45
|
-
PIWIK_CHECKOUT_LOCATION = '/tmp/piwik_device_detector'.freeze
|
46
|
-
|
47
|
-
def get_latest_piwik_checkout
|
48
|
-
if File.exist?(PIWIK_CHECKOUT_LOCATION)
|
49
|
-
system "cd #{PIWIK_CHECKOUT_LOCATION}; git reset --hard HEAD; git pull origin master"
|
50
|
-
else
|
51
|
-
system "git clone --depth 1 #{PIWIK_REPO_URL} #{PIWIK_CHECKOUT_LOCATION}"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
desc 'update regex database from piwik project'
|
56
|
-
task :update_regexes do
|
57
|
-
top = File.expand_path('..', __FILE__)
|
58
|
-
get_latest_piwik_checkout
|
59
|
-
system "cp -R #{PIWIK_CHECKOUT_LOCATION}/regexes/* #{top}/regexes"
|
60
|
-
end
|
61
|
-
|
62
|
-
desc 'update fixtures from piwik project'
|
63
|
-
task :update_fixtures do
|
64
|
-
top = File.expand_path('..', __FILE__)
|
65
|
-
get_latest_piwik_checkout
|
66
|
-
|
67
|
-
fixture_mappings = [
|
68
|
-
{target_path: "#{top}/spec/fixtures/detector", source_path: 'Tests/fixtures/*.yml'},
|
69
|
-
{target_path: "#{top}/spec/fixtures/client", source_path: 'Tests/Parser/Client/fixtures/*.yml'},
|
70
|
-
{target_path: "#{top}/spec/fixtures/parser", source_path: 'Tests/Parser/fixtures/*.yml'},
|
71
|
-
{target_path: "#{top}/spec/fixtures/device", source_path: 'Tests/Parser/Devices/fixtures/*.yml'},
|
72
|
-
]
|
73
|
-
|
74
|
-
fixture_mappings.each do |mapping|
|
75
|
-
source_path = mapping.fetch(:source_path)
|
76
|
-
target_path = mapping.fetch(:target_path)
|
77
|
-
system "cp -R #{PIWIK_CHECKOUT_LOCATION}/#{source_path} #{target_path}"
|
78
|
-
end
|
79
|
-
end
|
data/device_detector.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'device_detector/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'device_detector'
|
8
|
-
spec.version = DeviceDetector::VERSION
|
9
|
-
spec.authors = ['Mati Sójka', 'Ben Zimmer']
|
10
|
-
spec.email = ['yagooar@gmail.com']
|
11
|
-
spec.summary = %q{Precise and fast user agent parser and device detector}
|
12
|
-
spec.description = %q{Precise and fast user agent parser and device detector, backed by the largest and most up-to-date agent and device database}
|
13
|
-
spec.homepage = 'http://podigee.github.io/device_detector'
|
14
|
-
spec.license = 'LGPL-3.0'
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = []
|
18
|
-
spec.test_files = spec.files.grep(%r{^(spec)/})
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.required_ruby_version = '>= 1.9.3'
|
22
|
-
|
23
|
-
spec.add_development_dependency 'minitest'
|
24
|
-
spec.add_development_dependency 'rake'
|
25
|
-
spec.add_development_dependency 'pry', '>= 0.10'
|
26
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
describe DeviceDetector::Bot do
|
4
|
-
|
5
|
-
fixture_dir = File.expand_path('../../fixtures/parser', __FILE__)
|
6
|
-
fixture_files = Dir["#{fixture_dir}/bots.yml"]
|
7
|
-
fixture_files.each do |fixture_file|
|
8
|
-
|
9
|
-
describe File.basename(fixture_file) do
|
10
|
-
|
11
|
-
fixtures = YAML.load_file(fixture_file)
|
12
|
-
|
13
|
-
fixtures.each do |f|
|
14
|
-
user_agent = f["user_agent"]
|
15
|
-
bot = DeviceDetector::Bot.new(user_agent)
|
16
|
-
|
17
|
-
describe user_agent do
|
18
|
-
it "should be a bot" do
|
19
|
-
assert bot.bot?, "isn't a bot"
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should have the expected name" do
|
23
|
-
assert_equal f["bot"]["name"], bot.name, "failed bot name detection"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
describe DeviceDetector::Client do
|
4
|
-
|
5
|
-
fixture_dir = File.expand_path('../../fixtures/client', __FILE__)
|
6
|
-
fixture_files = Dir["#{fixture_dir}/*.yml"]
|
7
|
-
fixture_files.each do |fixture_file|
|
8
|
-
|
9
|
-
describe File.basename(fixture_file) do
|
10
|
-
|
11
|
-
fixtures = YAML.load_file(fixture_file)
|
12
|
-
fixtures.each do |f|
|
13
|
-
|
14
|
-
user_agent = f["user_agent"]
|
15
|
-
client = DeviceDetector::Client.new(user_agent)
|
16
|
-
|
17
|
-
describe user_agent do
|
18
|
-
|
19
|
-
it "should be known" do
|
20
|
-
assert client.known?, "isn't known as a client"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should have the expected name" do
|
24
|
-
assert_equal f["client"]["name"], client.name, "failed client name detection"
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
describe DeviceDetector do
|
4
|
-
|
5
|
-
subject { DeviceDetector.new(user_agent) }
|
6
|
-
|
7
|
-
alias :client :subject
|
8
|
-
|
9
|
-
describe 'mobile iPhone 5S' do
|
10
|
-
|
11
|
-
let(:user_agent) { 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B440 [FBDV/iPhone6,1]' }
|
12
|
-
|
13
|
-
describe '#device_name' do
|
14
|
-
|
15
|
-
it 'returns device name' do
|
16
|
-
client.device_name.must_equal 'iPhone 5S'
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#device_type' do
|
22
|
-
|
23
|
-
it 'returns the device type' do
|
24
|
-
client.device_type.must_equal 'smartphone'
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'Ubuntu 10' do
|
32
|
-
|
33
|
-
let(:user_agent) { 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Ubuntu/10.10 Chromium/10.0.648.133 Chrome/10.0.648.133 Safari/534.16' }
|
34
|
-
|
35
|
-
describe '#os_name' do
|
36
|
-
|
37
|
-
it 'returns the OS name' do
|
38
|
-
client.os_name.must_equal 'Ubuntu'
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'Mac OS X' do
|
46
|
-
|
47
|
-
let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36' }
|
48
|
-
|
49
|
-
describe '#full_version' do
|
50
|
-
|
51
|
-
it 'returns the correct OS version' do
|
52
|
-
client.os_full_version.must_equal '10.10.1'
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'Chrome on Windows' do
|
60
|
-
|
61
|
-
describe '32bit' do
|
62
|
-
|
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
|
-
|
65
|
-
it 'returns the correct client name' do
|
66
|
-
client.name.must_equal 'Chrome'
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'recognizes the device name' do
|
70
|
-
client.device_name.must_be_nil
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'recognizes the device type' do
|
74
|
-
client.device_type.must_equal "desktop"
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '64bit' do
|
80
|
-
|
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
|
-
|
83
|
-
it 'returns the correct client name' do
|
84
|
-
client.name.must_equal 'Chrome'
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'recognizes the device name' do
|
88
|
-
client.device_name.must_be_nil
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'recognizes the device type' do
|
92
|
-
client.device_type.must_equal "desktop"
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
describe 'recognize and ignore sprd- prefix' do
|
100
|
-
|
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
|
-
|
103
|
-
it 'returns the correct client name' do
|
104
|
-
client.name.must_equal "Android Browser"
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'recognizes the device name' do
|
108
|
-
client.device_name.must_equal "GALAXY S5"
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'recognizes the device type' do
|
112
|
-
client.device_type.must_equal "smartphone"
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'remove TD suffix from model' do
|
118
|
-
|
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
|
-
|
121
|
-
it 'returns the correct client name' do
|
122
|
-
client.name.must_equal "Android Browser"
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'recognizes the device name' do
|
126
|
-
client.device_name.must_equal "A398t+"
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'recognizes the device type' do
|
130
|
-
client.device_type.must_equal "smartphone"
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
describe DeviceDetector do
|
4
|
-
|
5
|
-
fixture_dir = File.expand_path('../../fixtures/detector', __FILE__)
|
6
|
-
fixture_files = Dir["#{fixture_dir}/*.yml"]
|
7
|
-
fixture_files.each do |fixture_file|
|
8
|
-
|
9
|
-
describe File.basename(fixture_file) do
|
10
|
-
|
11
|
-
fixtures = nil
|
12
|
-
begin
|
13
|
-
fixtures = YAML.load(File.read(fixture_file))
|
14
|
-
rescue Psych::SyntaxError => e
|
15
|
-
fail "Failed to parse #{fixture_file}, reason: #{e}"
|
16
|
-
end
|
17
|
-
|
18
|
-
fixtures.each do |f|
|
19
|
-
|
20
|
-
user_agent = f["user_agent"]
|
21
|
-
detector = DeviceDetector.new(user_agent)
|
22
|
-
os = detector.send(:os)
|
23
|
-
|
24
|
-
describe user_agent do
|
25
|
-
it "should be detected" do
|
26
|
-
if detector.bot?
|
27
|
-
assert_equal f["bot"]["name"], detector.bot_name, "failed bot name detection"
|
28
|
-
else
|
29
|
-
if f["client"]
|
30
|
-
assert_equal f["client"]["name"], detector.name, "failed client name detection"
|
31
|
-
end
|
32
|
-
if f["os_family"] != "Unknown"
|
33
|
-
assert_equal f["os_family"], os.family, "failed os family detection"
|
34
|
-
assert_equal f["os"]["name"], os.name, "failed os name detection"
|
35
|
-
assert_equal f["os"]["short_name"], os.short_name, "failed os short name detection"
|
36
|
-
assert_equal f["os"]["version"], os.full_version, "failed os version detection"
|
37
|
-
end
|
38
|
-
if f["device"]
|
39
|
-
expected_type = f["device"]["type"]
|
40
|
-
actual_type = detector.device_type
|
41
|
-
if expected_type != actual_type
|
42
|
-
# puts "\n", f.inspect, expected_type, actual_type, detector.device_name, regex_meta.inspect
|
43
|
-
# debugger
|
44
|
-
# detector.device_type
|
45
|
-
end
|
46
|
-
assert_equal expected_type, actual_type, "failed device type detection"
|
47
|
-
model = f["device"]["model"]
|
48
|
-
model = model.to_s unless model.nil?
|
49
|
-
assert_equal model, detector.device_name, "failed device name detection"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require_relative '../spec_helper'
|
2
|
-
|
3
|
-
describe DeviceDetector::Device do
|
4
|
-
|
5
|
-
fixture_dir = File.expand_path('../../fixtures/devices', __FILE__)
|
6
|
-
fixture_files = Dir["#{fixture_dir}/*.yml"]
|
7
|
-
fixture_files.each do |fixture_file|
|
8
|
-
|
9
|
-
describe File.basename(fixture_file) do
|
10
|
-
|
11
|
-
fixtures = YAML.load_file(fixture_file)
|
12
|
-
fixtures.each do |f|
|
13
|
-
|
14
|
-
user_agent = f["user_agent"]
|
15
|
-
device = DeviceDetector::Device.new(user_agent)
|
16
|
-
|
17
|
-
describe user_agent do
|
18
|
-
|
19
|
-
it "should be known" do
|
20
|
-
assert device.known?, "isn't known as a device"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should have the expected model" do
|
24
|
-
assert_equal f["device"]["model"], device.name, "failed model detection"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should have the expected type" do
|
28
|
-
expected_device_type = DeviceDetector::Device::DEVICE_NAMES[f["device"]["type"]]
|
29
|
-
assert_equal expected_device_type, device.type, "failed device name detection"
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|