useragent 0.16.0 → 0.16.1

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: 751d90d864d4d4274012b45b1e90926759d7004d
4
- data.tar.gz: eb86f15579cb8d21ba4475e6f6142b54d8546c1d
3
+ metadata.gz: 2a7bfd625cd7795366a5f4975a64fa6980e795e0
4
+ data.tar.gz: 83d4de29ea9f43ee829b7f733efa0f4f7975051e
5
5
  SHA512:
6
- metadata.gz: 5a805566294d8832eb6def73486f653dd371dfe8690de198e772d661deea02f7d654bd8a4e71fd3e152f458ad761a0c8c93995428d206ba9658e9eb6e7bfac35
7
- data.tar.gz: 24baeef26f95ba6a0af1226f815f7e82b7b22dbd98421099849ed8ea52d9ec9ce370f2f3eca9e9bbb8f9af9a924c0ab920aa3e12050dd9b05e415c8019ff30ce
6
+ metadata.gz: e5b9d5851589353d62a0b585405de9e303be7ee04e697a4b0c6ffa151395cb1c34d001f975bd8bd395eda05137fd2cb2eca9bb7817f976e3d38cc7735430288d
7
+ data.tar.gz: 827f48ff99df6372b82000a202596426f89a2b74356807d7641e7946cb3827e07351640a09c69b3fed811494d2ce6c8aab76f4c4b85c1b5b677bd669270a8445
@@ -20,9 +20,23 @@ class UserAgent
20
20
  "I" => :weak
21
21
  }.freeze
22
22
 
23
+ ALL = [
24
+ Edge,
25
+ InternetExplorer,
26
+ Opera,
27
+ Chrome,
28
+ ITunes,
29
+ PlayStation,
30
+ PodcastAddict,
31
+ Webkit,
32
+ Gecko,
33
+ WindowsMediaPlayer,
34
+ AppleCoreMedia,
35
+ Libavformat,
36
+ ].freeze
37
+
23
38
  def self.all
24
- [Edge, InternetExplorer, Opera, Chrome, ITunes, PlayStation, PodcastAddict, Webkit, Gecko,
25
- WindowsMediaPlayer, AppleCoreMedia, Libavformat]
39
+ ALL
26
40
  end
27
41
 
28
42
  def self.extend(array)
@@ -0,0 +1,80 @@
1
+ class UserAgent
2
+ module Browsers
3
+ # Mozilla/5.0 (PLAYSTATION 3 4.75) AppleWebKit/531.22.8 (KHTML, like Gecko)
4
+ # Mozilla/5.0 (PLAYSTATION 3 4.76) AppleWebKit/531.22.8 (KHTML, like Gecko)
5
+ # Mozilla/5.0 (PLAYSTATION 3; 1.00)
6
+ # Mozilla/5.0 (PlayStation Vita 3.52) AppleWebKit/537.73 (KHTML, like Gecko) Silk/3.2
7
+ # Mozilla/5.0 (PlayStation 4 2.57) AppleWebKit/537.73 (KHTML, like Gecko)
8
+ class PlayStation < Base
9
+ def self.extend?(agent)
10
+ !agent.application.nil? && !agent.application.comment.nil? && (
11
+ agent.application.comment.first.include?('PLAYSTATION 3') ||
12
+ agent.application.comment.first.include?('PlayStation Vita') ||
13
+ agent.application.comment.first.include?('PlayStation 4')
14
+ )
15
+ end
16
+
17
+ # Returns the name of the browser in use.
18
+ #
19
+ # @return [nil, String] the name of the browser
20
+ def browser
21
+ if application.comment.first.include?('PLAYSTATION 3')
22
+ 'PS3 Internet Browser'
23
+ elsif last.product == 'Silk'
24
+ 'Silk'
25
+ elsif application.comment.first.include?('PlayStation 4')
26
+ 'PS4 Internet Browser'
27
+ else
28
+ nil
29
+ end
30
+ end
31
+
32
+ # PS Vita is mobile, others are not.
33
+ #
34
+ # @return [true, false] is this a mobile browser?
35
+ def mobile?
36
+ platform == 'PlayStation Vita'
37
+ end
38
+
39
+ # Returns the operating system in use.
40
+ #
41
+ # @return [String] the operating system in use
42
+ def os
43
+ application.comment.join(' ')
44
+ end
45
+
46
+ # Returns the platform in use.
47
+ #
48
+ # @return [nil, "PlayStation 3", "PlayStation 4", "PlayStation Vita"] the platform in use
49
+ def platform
50
+ if os.include?('PLAYSTATION 3')
51
+ 'PlayStation 3'
52
+ elsif os.include?('PlayStation 4')
53
+ 'PlayStation 4'
54
+ elsif os.include?('PlayStation Vita')
55
+ 'PlayStation Vita'
56
+ else
57
+ nil
58
+ end
59
+ end
60
+
61
+ # Returns the browser version in use. If Silk, returns the version of Silk.
62
+ # Otherwise, returns the PS3/PS4 firmware version.
63
+ #
64
+ # @return [nil, Version] the version
65
+ def version
66
+ if browser == 'Silk'
67
+ last.version
68
+ elsif platform == 'PlayStation 3'
69
+ Version.new(os.split('PLAYSTATION 3 ').last)
70
+ elsif platform == 'PlayStation 4'
71
+ Version.new(os.split('PlayStation 4 ').last)
72
+ elsif platform == 'PlayStation Vita'
73
+ Version.new(os.split('PlayStation Vita ').last)
74
+ else
75
+ nil
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,103 @@
1
+ class UserAgent
2
+ module Browsers
3
+ # Podcast Addict - Dalvik/1.6.0 (Linux; U; Android 4.4.2; LG-D631 Build/KOT49I.D63110b)
4
+ # Podcast Addict - Dalvik/2.1.0 (Linux; U; Android 5.1; XT1093 Build/LPE23.32-21.3)
5
+ # Podcast Addict - Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; ALCATEL ONE TOUCH Fierce Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.2 Mobile Safari/534.30
6
+ # Podcast Addict - Mozilla/5.0 (Linux; U; Android 4.2.2; en-ca; ALCATEL ONE TOUCH 6040A Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.2 Mobile Safari/534.30
7
+ # Podcast Addict - Dalvik/2.1.0 (Linux; U; Android M Build/MPZ79M)
8
+ class PodcastAddict < Base
9
+ def self.extend?(agent)
10
+ agent.length >= 3 && agent[0].product == 'Podcast' && agent[1].product == 'Addict' && agent[2].product == '-'
11
+ end
12
+
13
+ def browser
14
+ 'Podcast Addict'
15
+ end
16
+
17
+ # If we can figure out the device, return it.
18
+ #
19
+ # @return [nil, String] the device model
20
+ def device
21
+ return nil unless length >= 4
22
+ return nil unless self[3].comment.last.include?(' Build/')
23
+
24
+ self[3].comment.last.split(' Build/').first
25
+ end
26
+
27
+ # If we can figure out the device build, return it.
28
+ #
29
+ # @return [nil, String] the device build
30
+ def device_build
31
+ return nil unless length >= 4
32
+ return nil unless self[3].comment.last.include?(' Build/')
33
+
34
+ self[3].comment.last.split(' Build/').last
35
+ end
36
+
37
+ # Returns the localization, if known. We currently only know this for certain devices.
38
+ #
39
+ # @return [nil, String] the localization
40
+ def localization
41
+ return nil unless length >= 4
42
+ return nil unless self[3].comment.last.include?('ALCATEL ')
43
+ return nil unless self[3].comment.length >= 5
44
+
45
+ self[3].comment[3]
46
+ end
47
+
48
+ # This is a mobile app, always return true.
49
+ #
50
+ # @return [true]
51
+ def mobile?
52
+ true
53
+ end
54
+
55
+ # Gets the operating system (some variant of Android, if we're certain that is the case)
56
+ #
57
+ # @return [nil, String] the operating system
58
+ def os
59
+ return nil unless length >= 4
60
+
61
+ # comment[0] = 'Linux'
62
+ # comment[1] = 'U'
63
+ # comment[2] = 'Android x.y.z' except when there are only 3 tokens, then we don't know the version
64
+ if (self[3].product == 'Dalvik' || self[3].product == 'Mozilla') && self[3].comment.length > 3
65
+ self[3].comment[2]
66
+ elsif (self[3].product == 'Dalvik' || self[3].product == 'Mozilla') && self[3].comment.length == 3
67
+ 'Android'
68
+ else
69
+ nil
70
+ end
71
+ end
72
+
73
+ # Gets the platform (Android, if we're certain)
74
+ #
75
+ # @return [nil, "Android"] the platform
76
+ def platform
77
+ if os.include?('Android')
78
+ 'Android'
79
+ else
80
+ nil
81
+ end
82
+ end
83
+
84
+
85
+ # Get the security level reported
86
+ #
87
+ # @return [:weak, :strong, :none] the security level
88
+ def security
89
+ return nil unless length >= 4
90
+ return nil unless self[3].product == 'Dalvik' || self[3].product == 'Mozilla'
91
+
92
+ Security[self[3].comment[1]]
93
+ end
94
+
95
+ # We aren't provided with the version :(
96
+ #
97
+ # @return [nil]
98
+ def version
99
+ nil
100
+ end
101
+ end
102
+ end
103
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -59,6 +59,8 @@ files:
59
59
  - lib/user_agent/browsers/itunes.rb
60
60
  - lib/user_agent/browsers/libavformat.rb
61
61
  - lib/user_agent/browsers/opera.rb
62
+ - lib/user_agent/browsers/playstation.rb
63
+ - lib/user_agent/browsers/podcast_addict.rb
62
64
  - lib/user_agent/browsers/webkit.rb
63
65
  - lib/user_agent/browsers/windows_media_player.rb
64
66
  - lib/user_agent/comparable.rb