device_detector 0.8.1 → 0.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dafeb69d5740bff28a730522bfcb0487ed419b8
4
- data.tar.gz: e82f903f97d49b743d6572bd6a5f4c50b6ab5c61
3
+ metadata.gz: 81f8d553f5a16ebe349f683f2a37c34c0cdb59f5
4
+ data.tar.gz: d12f646a552f2b167d28a8c20fdc71de66108964
5
5
  SHA512:
6
- metadata.gz: 9ee6f2f50425f367ca9a1823d3f133d410d77d854fe9b88d991a1f07f2fd2c9ea35799c530ace6220d87b74b839b581b48bc6d9d186f9bff9da618439fe498f8
7
- data.tar.gz: e047fd31175b2c09e17ac6fa0d7bdee576c579f675059c0cf3144e257c4d3e1c524d18aa286cfe1610d63611b3d7449fc5465685797b686d1a287a6a7d394d5c
6
+ metadata.gz: 2185e70c4be666e91f66146fe929ce58438b499a8c10c1d4c8595e888cd14cae1c8b87c493237f9518f179ac5c17c5afd55e34713fe0e6385dd2dace85781a4b
7
+ data.tar.gz: d3c90c155ba23d60f779cb86711eb56b97fd10aa2e0337f9311ddab5ce27a095d5c2daac05efcd12203ee778a4f5db57d6d1f3abaf254dce2f3215750457989b
@@ -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
 
@@ -40,6 +40,10 @@ class DeviceDetector
40
40
  device.name
41
41
  end
42
42
 
43
+ def device_brand
44
+ device.brand
45
+ end
46
+
43
47
  def device_type
44
48
  t = device.type
45
49
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  class DeviceDetector
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.2'
3
3
  end
@@ -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.1
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-06-21 00:00:00.000000000 Z
12
+ date: 2015-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest