useragent 0.4.4 → 0.4.5

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.
Files changed (2) hide show
  1. data/lib/user_agent/browsers/webkit.rb +14 -11
  2. metadata +5 -5
@@ -15,7 +15,7 @@ class UserAgent
15
15
  elsif detect_product('Chrome')
16
16
  'Chrome'
17
17
  elsif platform == 'webOS' || platform == 'BlackBerry' || platform == 'Symbian'
18
- platform
18
+ platform
19
19
  else
20
20
  'Safari'
21
21
  end
@@ -71,15 +71,16 @@ class UserAgent
71
71
 
72
72
  Version.new(str) if str
73
73
  end
74
-
74
+
75
75
  def application
76
- apps = self.reject{|agent| agent.comment.nil? || agent.comment.empty?}
77
- apps.first
76
+ self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first
78
77
  end
79
78
 
80
- def platform
81
- if application.comment[0] =~ /Symbian/
82
- 'Symbian'
79
+ def platform
80
+ if application.nil?
81
+ nil
82
+ elsif application.comment[0] =~ /Symbian/
83
+ 'Symbian'
83
84
  elsif application.comment[0] =~ /webOS/
84
85
  'webOS'
85
86
  else
@@ -100,20 +101,22 @@ class UserAgent
100
101
  "Palm #{last.product} #{last.version}"
101
102
  elsif platform == 'Symbian'
102
103
  application.comment[0]
103
- else
104
+ elsif application
104
105
  OperatingSystems.normalize_os(application.comment[2])
106
+ else
107
+ nil
105
108
  end
106
109
  end
107
110
 
108
111
  def localization
109
- # TODO: Ensure that this is common to all webOS UserAgent
110
- if platform == 'webOS'
112
+ if application.nil?
113
+ nil
114
+ elsif platform == 'webOS'
111
115
  application.comment[2]
112
116
  else
113
117
  application.comment[3]
114
118
  end
115
119
  end
116
-
117
120
  end
118
121
  end
119
122
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Peek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-01 00:00:00 -05:00
18
+ date: 2011-11-02 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  requirements: []
99
99
 
100
100
  rubyforge_project:
101
- rubygems_version: 1.5.2
101
+ rubygems_version: 1.6.2
102
102
  signing_key:
103
103
  specification_version: 3
104
104
  summary: HTTP User Agent parser