useragent 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Joshua Peek
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = UserAgent
2
+
3
+ UserAgent is a Ruby library that parses and compares HTTP User Agents.
4
+
5
+
6
+ === Example
7
+
8
+ Browser = Struct.new(:browser, :version)
9
+ SupportedBrowsers = [
10
+ Browser.new("Safari", "3.1.1"),
11
+ Browser.new("Firefox", "2.0.0.14"),
12
+ Browser.new("Internet Explorer", "7.0")
13
+ ]
14
+
15
+ user_agent = UserAgent.parse(request.user_agent)
16
+ SupportedBrowsers.detect { |browser| user_agent >= browser }
17
+
18
+
19
+ Copyright (c) 2009 Joshua Peek, released under the MIT license
@@ -2,7 +2,7 @@ class UserAgent
2
2
  module Browsers
3
3
  module Webkit
4
4
  def self.extend?(agent)
5
- agent.detect { |useragent| useragent.product == "Safari" }
5
+ agent.detect { |useragent| useragent.product == "Safari" || useragent.product == "Chrome" }
6
6
  end
7
7
 
8
8
  def browser
@@ -14,23 +14,47 @@ class UserAgent
14
14
  end
15
15
 
16
16
  def build
17
- safari.version
17
+ webkit.version
18
18
  end
19
19
 
20
20
  BuildVersions = {
21
- "125.12" => "1.2.4",
22
- "312.6" => "1.3.2",
23
- "412.2.2" => "2.0",
24
- "412.5" => "2.0.1",
25
- "416.13" => "2.0.2",
26
- "417.9.3" => "2.0.3",
27
- "419.3" => "2.0.4"
21
+ "85.7" => "1.0",
22
+ "85.8.5" => "1.0.3",
23
+ "85.8.2" => "1.0.3",
24
+ "124" => "1.2",
25
+ "125.2" => "1.2.2",
26
+ "125.4" => "1.2.3",
27
+ "125.5.5" => "1.2.4",
28
+ "125.5.6" => "1.2.4",
29
+ "125.5.7" => "1.2.4",
30
+ "312.1.1" => "1.3",
31
+ "312.1" => "1.3",
32
+ "312.5" => "1.3.1",
33
+ "312.5.1" => "1.3.1",
34
+ "312.5.2" => "1.3.1",
35
+ "312.8" => "1.3.2",
36
+ "312.8.1" => "1.3.2",
37
+ "412" => "2.0",
38
+ "412.6" => "2.0",
39
+ "412.6.2" => "2.0",
40
+ "412.7" => "2.0.1",
41
+ "416.11" => "2.0.2",
42
+ "416.12" => "2.0.2",
43
+ "417.9" => "2.0.3",
44
+ "418" => "2.0.3",
45
+ "418.8" => "2.0.4",
46
+ "418.9" => "2.0.4",
47
+ "418.9.1" => "2.0.4",
48
+ "419" => "2.0.4",
49
+ "425.13" => "2.2"
28
50
  }.freeze
29
51
 
30
52
  # Prior to Safari 3, the user agent did not include a version number
31
53
  def version
32
54
  if browser == "Chrome"
33
55
  chrome.version
56
+ elsif os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
57
+ $1.gsub(/_/, '.')
34
58
  elsif product = detect_product("Version")
35
59
  product.version
36
60
  else
@@ -1,6 +1,7 @@
1
1
  class UserAgent
2
2
  module OperatingSystems
3
3
  Windows = {
4
+ "Windows NT 6.1" => "Windows 7",
4
5
  "Windows NT 6.0" => "Windows Vista",
5
6
  "Windows NT 5.2" => "Windows XP x64 Edition",
6
7
  "Windows NT 5.1" => "Windows XP",
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 5
10
+ version: 0.1.5
5
11
  platform: ruby
6
12
  authors:
7
13
  - Joshua Peek
@@ -9,28 +15,29 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-18 00:00:00 -06:00
18
+ date: 2010-06-13 00:00:00 -05:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
16
- description: " UserAgent is a Ruby library that parses and compares HTTP User Agents.\n"
22
+ description: HTTP User Agent parser
17
23
  email: josh@joshpeek.com
18
24
  executables: []
19
25
 
20
26
  extensions: []
21
27
 
22
- extra_rdoc_files: []
23
-
28
+ extra_rdoc_files:
29
+ - LICENSE
30
+ - README.rdoc
24
31
  files:
32
+ - lib/user_agent.rb
33
+ - lib/user_agent/browsers.rb
25
34
  - lib/user_agent/browsers/all.rb
26
35
  - lib/user_agent/browsers/gecko.rb
27
36
  - lib/user_agent/browsers/internet_explorer.rb
28
37
  - lib/user_agent/browsers/opera.rb
29
38
  - lib/user_agent/browsers/webkit.rb
30
- - lib/user_agent/browsers.rb
31
39
  - lib/user_agent/comparable.rb
32
40
  - lib/user_agent/operating_systems.rb
33
- - lib/user_agent.rb
34
41
  - lib/useragent.rb
35
42
  has_rdoc: true
36
43
  homepage: http://github.com/josh/useragent
@@ -42,21 +49,27 @@ rdoc_options: []
42
49
  require_paths:
43
50
  - lib
44
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
45
53
  requirements:
46
54
  - - ">="
47
55
  - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
48
59
  version: "0"
49
- version:
50
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
51
62
  requirements:
52
63
  - - ">="
53
64
  - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
54
68
  version: "0"
55
- version:
56
69
  requirements: []
57
70
 
58
71
  rubyforge_project:
59
- rubygems_version: 1.3.5
72
+ rubygems_version: 1.3.7
60
73
  signing_key:
61
74
  specification_version: 3
62
75
  summary: HTTP User Agent parser