device_detector 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ ###############
2
+ # Device Detector - The Universal Device Detection library for parsing User Agents
3
+ #
4
+ # @link http://piwik.org
5
+ # @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
6
+ ###############
7
+
8
+ - regex: 'Outlook-Express(?:/(\d+[\.\d]+))?'
9
+ name: 'Outlook Express'
10
+ version: '$1'
11
+
12
+ - regex: 'Microsoft Outlook(?:[/ ](\d+[\.\d]+))?'
13
+ name: 'Microsoft Outlook'
14
+ version: '$1'
15
+
16
+ - regex: '(?:Thunderbird|Icedove)(?:/(\d+[\.\d]+))?'
17
+ name: 'Thunderbird'
18
+ version: '$1'
19
+
20
+ - regex: 'Airmail(?: (\d+[\.\d]+))?'
21
+ name: 'Airmail'
22
+ version: '$1'
23
+
24
+ - regex: 'Lotus-Notes(?:/(\d+[\.\d]+))?'
25
+ name: 'Lotus Notes'
26
+ version: '$1'
27
+
28
+ - regex: 'Barca(?:Pro)?(?:[/ ](\d+[\.\d]+))?'
29
+ name: 'Barca'
30
+ version: '$1'
31
+
32
+ - regex: 'Postbox(?:[/ ](\d+[\.\d]+))?'
33
+ name: 'Postbox'
34
+ version: '$1'
35
+
36
+ - regex: 'The Bat!(?: Voyager)?(?:[/ ](\d+[\.\d]+))?'
37
+ name: 'The Bat!'
38
+ version: '$1'
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DeviceDetector::ClientDetector do
4
+
5
+ subject(:detector) { DeviceDetector::ClientDetector.new(user_agent) }
6
+ let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69' }
7
+
8
+ describe '#call' do
9
+
10
+ it 'returns a DeviceDetector::Client' do
11
+ expect(detector.call).to be_a(DeviceDetector::Client)
12
+ end
13
+
14
+ it 'returns the correct name' do
15
+ expect(detector.call.name).to eq('Chrome')
16
+ end
17
+
18
+ end
19
+
20
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DeviceDetector::Client do
4
+
5
+ subject(:client) { DeviceDetector::Client.new(user_agent, regex_meta) }
6
+
7
+ let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69' }
8
+
9
+ let(:regex_meta) do
10
+ {
11
+ 'regex' => 'Chrome(?:/(\d+[\.\d]+))?',
12
+ 'name' => 'Chrome',
13
+ 'version' => '$1'
14
+ }
15
+ end
16
+
17
+ describe '#name' do
18
+
19
+ it 'returns the correct name' do
20
+ expect(client.name).to eq('Chrome')
21
+ end
22
+
23
+ end
24
+
25
+ describe '#full_version' do
26
+
27
+ it 'returns the correct version' do
28
+ expect(client.full_version).to eq('30.0.1599.69')
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DeviceDetector::OSDetector do
4
+
5
+ subject(:detector) { DeviceDetector::OSDetector.new(user_agent) }
6
+ let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69' }
7
+
8
+
9
+ describe '#call' do
10
+
11
+ it 'returns a DeviceDetector::OS' do
12
+ expect(detector.call).to be_a(DeviceDetector::OS)
13
+ end
14
+
15
+ it 'returns the correct name' do
16
+ expect(detector.call.name).to eq('Mac')
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DeviceDetector::OS do
4
+
5
+ subject(:os) { DeviceDetector::OS.new(user_agent, regex_meta) }
6
+
7
+ let(:user_agent) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69' }
8
+
9
+ let(:regex_meta) do
10
+ {
11
+ 'regex' => 'Mac OS X(?: (?:Version )?(\d+(?:[_\.]\d+)+))?',
12
+ 'name' => 'Mac',
13
+ 'version' => '$1'
14
+ }
15
+ end
16
+
17
+ describe '#name' do
18
+
19
+ it 'returns the correct name' do
20
+ expect(os.name).to eq('Mac')
21
+ end
22
+
23
+ end
24
+
25
+ describe '#full_version' do
26
+
27
+ it 'returns the correct version' do
28
+ expect(os.full_version).to eq('10_8_5')
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DeviceDetector::VersionExtractor do
4
+
5
+ subject(:extractor) { DeviceDetector::VersionExtractor.new(user_agent, regex_meta) }
6
+
7
+ describe '#call' do
8
+
9
+ context 'extractor without version' do
10
+
11
+ let(:user_agent) { 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Avant Browser; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)' }
12
+
13
+ let(:regex_meta) do
14
+ {
15
+ 'regex' => 'Avant Browser',
16
+ 'name' => 'Avant Browser',
17
+ 'version' => ''
18
+ }
19
+ end
20
+
21
+ it 'returns nil' do
22
+ expect(extractor.call).to eq('')
23
+ end
24
+
25
+ end
26
+
27
+ context 'regex with dynamic matching' do
28
+
29
+ let(:user_agent) { 'Mozilla/5.0 (X11; U; Linux i686; nl; rv:1.8.1b2) Gecko/20060821 BonEcho/2.0b2 (Debian-1.99+2.0b2+dfsg-1)' }
30
+ let(:regex_meta) do
31
+ {
32
+ 'regex' => '(BonEcho|GranParadiso|Lorentz|Minefield|Namoroka|Shiretoko)/(\d+[\.\d]+)',
33
+ 'name' => 'Firefox',
34
+ 'version' => '$1 ($2)'
35
+ }
36
+ end
37
+
38
+ it 'returns the correct version' do
39
+ expect(extractor.call).to eq('BonEcho (2.0)')
40
+ end
41
+
42
+ end
43
+
44
+ context 'extractor with fixed version' do
45
+
46
+ let(:user_agent) { 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)' }
47
+ let(:regex_meta) do
48
+ {
49
+ 'regex' => 'MSIE.*Trident/4.0',
50
+ 'version' => '8.0'
51
+ }
52
+ end
53
+
54
+ it 'returns the correct version' do
55
+ expect(extractor.call).to eq('8.0')
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+ end
62
+
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe DeviceDetector do
4
+
5
+ subject(:detector) { DeviceDetector.new(nil) }
6
+
7
+ describe '#os' do
8
+
9
+ it 'returns a DeviceDetector::OS' do
10
+ expect(detector.os).to be_a(DeviceDetector::OS)
11
+ end
12
+
13
+ end
14
+
15
+ describe '#client' do
16
+
17
+ it 'returns a DeviceDetector::Client' do
18
+ expect(detector.client).to be_a(DeviceDetector::Client)
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'rspec'
5
+ require 'device_detector'
6
+ require 'pry'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: device_detector
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mati Sójka
8
+ - Ben Zimmer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-12-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '3.1'
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '3.1'
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: pry
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.10'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.10'
48
+ description: The Universal Device Detection library will parse any User Agent and
49
+ detect the browser, operating system, device, brand and model.
50
+ email:
51
+ - yagooar@gmail.com
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - ".gitignore"
57
+ - Gemfile
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - device_detector.gemspec
62
+ - lib/device_detector.rb
63
+ - lib/device_detector/client.rb
64
+ - lib/device_detector/client_detector.rb
65
+ - lib/device_detector/os.rb
66
+ - lib/device_detector/os_detector.rb
67
+ - lib/device_detector/version.rb
68
+ - lib/device_detector/version_extractor.rb
69
+ - regexes/browser_engines.yml
70
+ - regexes/browsers.yml
71
+ - regexes/feed_readers.yml
72
+ - regexes/libraries.yml
73
+ - regexes/mediaplayers.yml
74
+ - regexes/mobile_apps.yml
75
+ - regexes/oss.yml
76
+ - regexes/pim.yml
77
+ - spec/device_detector/client_detector_spec.rb
78
+ - spec/device_detector/client_spec.rb
79
+ - spec/device_detector/os_detector_spec.rb
80
+ - spec/device_detector/os_spec.rb
81
+ - spec/device_detector/version_extractor_spec.rb
82
+ - spec/device_detector_spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: https://github.com/podigee/device_detector
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.2.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Universal Device Detection
108
+ test_files:
109
+ - spec/device_detector/client_detector_spec.rb
110
+ - spec/device_detector/client_spec.rb
111
+ - spec/device_detector/os_detector_spec.rb
112
+ - spec/device_detector/os_spec.rb
113
+ - spec/device_detector/version_extractor_spec.rb
114
+ - spec/device_detector_spec.rb
115
+ - spec/spec_helper.rb