useragent 0.11.0 → 0.12.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b5bc3c7403f99b975416f8a4c339e9054169051
4
- data.tar.gz: 2c62dedcd7aa755e42670197a480a27e3ec757f2
3
+ metadata.gz: 70923abee7e8ba999ee2cd327e6eda2af9f0d721
4
+ data.tar.gz: caeb5dea87e448b5d41d0d3946d1e6bb95e42cf7
5
5
  SHA512:
6
- metadata.gz: 3caceb0aefd8f62a314acf6a80f703c19e72fc81b7157ef06a95f0b86196fecf22cb7df27f3a7e721443f5a17e916878bd6747dabdab213ce50ceaade97d9851
7
- data.tar.gz: 5431d35a284d115f7d85abaf4ac361577eab2badaf450ee808e948f5d3e5aef4419247c14b4cfa115f81d99eb23221cc6ece450cff0acff754bc8fcbae05aa46
6
+ metadata.gz: 5acfcce5871ad92a637be4d463ca721c4688db4c873eaa8afb5f2bb8526fb22ceed31274a332fd6908310d537d2a2cfda30c3b23662b5562dd086b2ec8934481
7
+ data.tar.gz: c6e856cff6f0b873bcc95bf78925a950500f3509e1c2c3303b1a88f894f1f0cdf7a831e48f622b5334e2a0f236851fd60af53768fa9b67481ec9391c30aeec91
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Joshua Peek
1
+ Copyright (c) 2015 Garry Shutler
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -0,0 +1,41 @@
1
+ # UserAgent
2
+
3
+ [![Build Status](https://travis-ci.org/gshutler/useragent.svg?branch=master)](https://travis-ci.org/gshutler/useragent)
4
+
5
+ UserAgent is a Ruby library that parses and compares HTTP User Agents.
6
+
7
+ ## Installation
8
+
9
+ gem install useragent
10
+
11
+ ### Examples
12
+
13
+ #### Reporting
14
+
15
+ ```ruby
16
+ string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
17
+ user_agent = UserAgent.parse(string)
18
+ user_agent.browser
19
+ # => 'Chrome'
20
+ user_agent.version
21
+ # => '19.0.1084.56'
22
+ user_agent.platform
23
+ # => 'Macintosh'
24
+ ```
25
+
26
+ #### Comparison
27
+
28
+ ```ruby
29
+ Browser = Struct.new(:browser, :version)
30
+
31
+ SupportedBrowsers = [
32
+ Browser.new("Safari", "3.1.1"),
33
+ Browser.new("Firefox", "2.0.0.14"),
34
+ Browser.new("Internet Explorer", "7.0")
35
+ ]
36
+
37
+ user_agent = UserAgent.parse(request.user_agent)
38
+ SupportedBrowsers.detect { |browser| user_agent >= browser }
39
+ ```
40
+
41
+ Copyright (c) 2015 Garry Shutler, released under the MIT license
@@ -6,15 +6,15 @@ require 'user_agent/version'
6
6
  class UserAgent
7
7
  # http://www.texsoft.it/index.php?m=sw.php.useragent
8
8
  MATCHER = %r{
9
- ^([^/\s]+) # Product
10
- /?([^\s]*) # Version
11
- (\s\(([^\)]*)\))? # Comment
9
+ ^([^/\s]+) # Product
10
+ /?([^\s,]*) # Version
11
+ (\s\(([^\)]*)\)|,gzip\(gfe\))? # Comment
12
12
  }x.freeze
13
13
 
14
14
  DEFAULT_USER_AGENT = "Mozilla/4.0 (compatible)"
15
15
 
16
16
  def self.parse(string)
17
- if string.nil? || string == ""
17
+ if string.nil? || string.strip == ""
18
18
  string = DEFAULT_USER_AGENT
19
19
  end
20
20
 
@@ -14,7 +14,7 @@ class UserAgent
14
14
  }.freeze
15
15
 
16
16
  def self.all
17
- [InternetExplorer, Chrome, Webkit, Opera, Gecko]
17
+ [InternetExplorer, Opera, Chrome, Webkit, Gecko]
18
18
  end
19
19
 
20
20
  def self.extend(array)
@@ -6,6 +6,7 @@ class UserAgent
6
6
  end
7
7
 
8
8
  GeckoBrowsers = %w(
9
+ PaleMoon
9
10
  Firefox
10
11
  Camino
11
12
  Iceweasel
@@ -36,7 +36,7 @@ class UserAgent
36
36
  end
37
37
 
38
38
  def os
39
- OperatingSystems.normalize_os(application.comment.join('; ').match(/Windows NT [\d\.]+|Windows Phone OS [\d\.]+/).to_s)
39
+ OperatingSystems.normalize_os(application.comment.join('; ').match(/Windows NT [\d\.]+|Windows Phone (OS )?[\d\.]+/).to_s)
40
40
  end
41
41
  end
42
42
  end
@@ -3,7 +3,12 @@ class UserAgent
3
3
  class Opera < Base
4
4
  def self.extend?(agent)
5
5
  (agent.first && agent.first.product == 'Opera') ||
6
- (agent.application && agent.application.product == 'Opera')
6
+ (agent.application && agent.application.product == 'Opera') ||
7
+ (agent.last && agent.last.product == 'OPR')
8
+ end
9
+
10
+ def browser
11
+ 'Opera'
7
12
  end
8
13
 
9
14
  def version
metadata CHANGED
@@ -1,52 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
8
+ - Garry Shutler
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-02-23 00:00:00.000000000 Z
12
+ date: 2015-03-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ">="
18
+ - - ~>
18
19
  - !ruby/object:Gem::Version
19
- version: '0'
20
+ version: '10.0'
20
21
  type: :development
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ">="
25
+ - - ~>
25
26
  - !ruby/object:Gem::Version
26
- version: '0'
27
+ version: '10.0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rspec
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
- - - ">="
32
+ - - ~>
32
33
  - !ruby/object:Gem::Version
33
- version: '0'
34
+ version: '3.0'
34
35
  type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
38
- - - ">="
39
+ - - ~>
39
40
  - !ruby/object:Gem::Version
40
- version: '0'
41
+ version: '3.0'
41
42
  description: |2
42
43
  HTTP User Agent parser
43
- email: josh@joshpeek.com
44
+ email: garry@robustsoftware.co.uk
44
45
  executables: []
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
48
49
  - LICENSE
49
- - README.rdoc
50
+ - README.md
50
51
  - lib/user_agent.rb
51
52
  - lib/user_agent/browsers.rb
52
53
  - lib/user_agent/browsers/base.rb
@@ -59,7 +60,7 @@ files:
59
60
  - lib/user_agent/operating_systems.rb
60
61
  - lib/user_agent/version.rb
61
62
  - lib/useragent.rb
62
- homepage: http://github.com/josh/useragent
63
+ homepage: http://github.com/gshutler/useragent
63
64
  licenses:
64
65
  - MIT
65
66
  metadata: {}
@@ -69,12 +70,12 @@ require_paths:
69
70
  - lib
70
71
  required_ruby_version: !ruby/object:Gem::Requirement
71
72
  requirements:
72
- - - ">="
73
+ - - '>='
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  requirements:
77
- - - ">="
78
+ - - '>='
78
79
  - !ruby/object:Gem::Version
79
80
  version: '0'
80
81
  requirements: []
@@ -1,35 +0,0 @@
1
- = UserAgent
2
-
3
- UserAgent is a Ruby library that parses and compares HTTP User Agents.
4
-
5
- === Installation
6
-
7
- gem install useragent
8
-
9
- === Examples
10
-
11
- ==== Reporting
12
-
13
- string = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
14
- user_agent = UserAgent.parse(string)
15
- user_agent.browser
16
- # => 'Chrome'
17
- user_agent.version
18
- # => '19.0.1084.56'
19
- user_agent.platform
20
- # => 'Macintosh'
21
-
22
- ==== Comparison
23
-
24
- Browser = Struct.new(:browser, :version)
25
- SupportedBrowsers = [
26
- Browser.new("Safari", "3.1.1"),
27
- Browser.new("Firefox", "2.0.0.14"),
28
- Browser.new("Internet Explorer", "7.0")
29
- ]
30
-
31
- user_agent = UserAgent.parse(request.user_agent)
32
- SupportedBrowsers.detect { |browser| user_agent >= browser }
33
-
34
-
35
- Copyright (c) 2013 Joshua Peek, released under the MIT license