useragent 0.2.3 → 0.3.0

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.
data/lib/user_agent.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'user_agent/comparable'
2
2
  require 'user_agent/browsers'
3
3
  require 'user_agent/operating_systems'
4
+ require 'user_agent/version'
4
5
 
5
6
  class UserAgent
6
7
  # http://www.texsoft.it/index.php?m=sw.php.useragent
@@ -30,7 +31,7 @@ class UserAgent
30
31
  end
31
32
 
32
33
  if version && !version.empty?
33
- @version = version
34
+ @version = Version.new(version)
34
35
  else
35
36
  @version = nil
36
37
  end
@@ -59,15 +59,17 @@ class UserAgent
59
59
 
60
60
  # Prior to Safari 3, the user agent did not include a version number
61
61
  def version
62
- if os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
62
+ str = if os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
63
63
  $1.gsub(/_/, '.')
64
64
  elsif product = detect_product('Version')
65
65
  product.version
66
66
  elsif browser == 'Chrome'
67
67
  chrome.version
68
68
  else
69
- BuildVersions[build]
69
+ BuildVersions[build.to_s]
70
70
  end
71
+
72
+ Version.new(str) if str
71
73
  end
72
74
 
73
75
  def platform
@@ -95,8 +97,14 @@ class UserAgent
95
97
  end
96
98
 
97
99
  def localization
98
- application.comment[3]
100
+ # TODO: Ensure that this is common to all webOS UserAgent
101
+ if platform == 'webOS'
102
+ application.comment[2]
103
+ else
104
+ application.comment[3]
105
+ end
99
106
  end
107
+
100
108
  end
101
109
  end
102
110
  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: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
8
  - 3
10
- version: 0.2.3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Peek
@@ -15,19 +15,18 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-20 00:00:00 -06:00
18
+ date: 2011-02-20 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
22
- description: HTTP User Agent parser
22
+ description: " HTTP User Agent parser\n"
23
23
  email: josh@joshpeek.com
24
24
  executables: []
25
25
 
26
26
  extensions: []
27
27
 
28
- extra_rdoc_files:
29
- - LICENSE
30
- - README.rdoc
28
+ extra_rdoc_files: []
29
+
31
30
  files:
32
31
  - lib/user_agent.rb
33
32
  - lib/user_agent/browsers.rb
@@ -39,8 +38,10 @@ files:
39
38
  - lib/user_agent/comparable.rb
40
39
  - lib/user_agent/operating_systems.rb
41
40
  - lib/useragent.rb
41
+ - LICENSE
42
+ - README.rdoc
42
43
  has_rdoc: true
43
- homepage: https://github.com/josh/useragent
44
+ homepage: http://github.com/josh/useragent
44
45
  licenses: []
45
46
 
46
47
  post_install_message:
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  requirements: []
70
71
 
71
72
  rubyforge_project:
72
- rubygems_version: 1.4.2
73
+ rubygems_version: 1.5.0
73
74
  signing_key:
74
75
  specification_version: 3
75
76
  summary: HTTP User Agent parser