device_detector 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/device_detector.rb +4 -0
- data/lib/device_detector/device.rb +6 -1
- data/lib/device_detector/version.rb +1 -1
- data/spec/device_detector/device_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81f8d553f5a16ebe349f683f2a37c34c0cdb59f5
|
4
|
+
data.tar.gz: d12f646a552f2b167d28a8c20fdc71de66108964
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2185e70c4be666e91f66146fe929ce58438b499a8c10c1d4c8595e888cd14cae1c8b87c493237f9518f179ac5c17c5afd55e34713fe0e6385dd2dace85781a4b
|
7
|
+
data.tar.gz: d3c90c155ba23d60f779cb86711eb56b97fd10aa2e0337f9311ddab5ce27a095d5c2daac05efcd12203ee778a4f5db57d6d1f3abaf254dce2f3215750457989b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [0.8.2]
|
4
|
+
- Added device brand support. Thanks to [dnswus](https://github.com/dnswus).
|
5
|
+
|
6
|
+
## [0.8.1]
|
7
|
+
- Added Instacast detection rules
|
8
|
+
- Updated test fixtures
|
9
|
+
|
10
|
+
## [0.8.0]
|
11
|
+
- Added a better and more robust device detection. Thanks to [skaes](https://github.com/skaes).
|
12
|
+
- Added test fixture from the piwik project.
|
13
|
+
|
3
14
|
## [0.7.0]
|
4
15
|
- [Issue #8](https://github.com/podigee/device_detector/issues/8) Fixed Mac OS X full version format. Thanks to [aaronchi](https://github.com/aaronchi) for reporting.
|
5
16
|
|
data/lib/device_detector.rb
CHANGED
@@ -28,6 +28,10 @@ class DeviceDetector
|
|
28
28
|
hbbtv? ? 'tv' : regex_meta[:device]
|
29
29
|
end
|
30
30
|
|
31
|
+
def brand
|
32
|
+
regex_meta[:brand]
|
33
|
+
end
|
34
|
+
|
31
35
|
private
|
32
36
|
|
33
37
|
# The order of files needs to be the same as the order of device
|
@@ -50,7 +54,7 @@ class DeviceDetector
|
|
50
54
|
if regex && regex[:models]
|
51
55
|
model_regex = regex[:models].find { |m| user_agent =~ m[:regex]}
|
52
56
|
if model_regex
|
53
|
-
regex = regex.merge(:regex_model => model_regex[:regex], :model => model_regex[:model])
|
57
|
+
regex = regex.merge(:regex_model => model_regex[:regex], :model => model_regex[:model], :brand => model_regex[:brand])
|
54
58
|
regex[:device] = model_regex[:device] if model_regex.key?(:device)
|
55
59
|
regex.delete(:models)
|
56
60
|
end
|
@@ -80,6 +84,7 @@ class DeviceDetector
|
|
80
84
|
meta[:models].each do |model|
|
81
85
|
fail "invalid model spec: #{model.inspect}" unless model[:regex].is_a? String
|
82
86
|
model[:regex] = build_regex(model[:regex])
|
87
|
+
model[:brand] = brand.to_s unless model[:brand]
|
83
88
|
end
|
84
89
|
end
|
85
90
|
meta[:path] = path
|
@@ -82,6 +82,7 @@ describe DeviceDetector::Device do
|
|
82
82
|
it 'identifies the device' do
|
83
83
|
device.name.must_equal 'GALAXY S5'
|
84
84
|
device.type.must_equal 'smartphone'
|
85
|
+
device.brand.must_equal 'Samsung'
|
85
86
|
end
|
86
87
|
|
87
88
|
end
|
@@ -93,6 +94,7 @@ describe DeviceDetector::Device do
|
|
93
94
|
it 'identifies the device' do
|
94
95
|
device.name.must_equal 'GALAXY Camera'
|
95
96
|
device.type.must_equal 'camera'
|
97
|
+
device.brand.must_equal 'Samsung'
|
96
98
|
end
|
97
99
|
|
98
100
|
end
|
@@ -104,6 +106,7 @@ describe DeviceDetector::Device do
|
|
104
106
|
it 'identifies the device' do
|
105
107
|
device.name.must_equal 'Model S'
|
106
108
|
device.type.must_equal 'car browser'
|
109
|
+
device.brand.must_be_nil
|
107
110
|
end
|
108
111
|
|
109
112
|
end
|
@@ -115,6 +118,7 @@ describe DeviceDetector::Device do
|
|
115
118
|
it 'identifies the device' do
|
116
119
|
device.name.must_equal 'Wii'
|
117
120
|
device.type.must_equal 'console'
|
121
|
+
device.brand.must_be_nil
|
118
122
|
end
|
119
123
|
|
120
124
|
end
|
@@ -126,6 +130,7 @@ describe DeviceDetector::Device do
|
|
126
130
|
it 'identifies the device' do
|
127
131
|
device.name.must_equal 'iPod Touch'
|
128
132
|
device.type.must_equal 'portable media player'
|
133
|
+
device.brand.must_equal 'Apple'
|
129
134
|
end
|
130
135
|
|
131
136
|
end
|
@@ -137,6 +142,7 @@ describe DeviceDetector::Device do
|
|
137
142
|
it 'identifies the device' do
|
138
143
|
device.name.must_equal 'NetCast 4.0'
|
139
144
|
device.type.must_equal 'tv'
|
145
|
+
device.brand.must_equal 'LG'
|
140
146
|
end
|
141
147
|
|
142
148
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: device_detector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mati Sójka
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|