useragent 0.13.1 → 0.13.2

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: 96d4c326dbf2832b5851d5da2e1dd32fb8014918
4
- data.tar.gz: 0f6d567a382f9952042263eadfd8b02eec870c74
3
+ metadata.gz: 4f69cf2d44084d828233a9ba572469fc80fd0fb1
4
+ data.tar.gz: 7b27952c2d2299f6c8b4ed06134a57bee214ec90
5
5
  SHA512:
6
- metadata.gz: ed16ad54f08a1de0c19d7da8bf5bf331edf8d2311c7efc59489d35f41482dc3ccdd33c0441af4d5d6ff92eefa199848358deeaeab880e6d53a9b1f4ba9a7f49e
7
- data.tar.gz: c40a58ecd7f6b42ef7616177aa63af8a87cd68f8ea387598651b1776d59a34f60edcd4799774cff8a66a005dd6b1c66826e58310d26f4a4b967de7ba0c46aabc
6
+ metadata.gz: 9aee118761c02ab4e4d30aa3650e1c43cd7465e986b57f86faead6ddc9d2e00338a1e4e3543518e617efd44f0c660514c023c30dab963a1c22cfdd6bf6dc0b50
7
+ data.tar.gz: 7d5c68eb6f3cd951858045e3f870d5bdda079c6ee9de44d0e0af1cb342e180a5780733331c60036d275ad8507a14eddadb124b6ff6556b022ca5bd3dd31d1040
@@ -87,6 +87,32 @@ class UserAgent
87
87
  end
88
88
  end
89
89
 
90
+ def to_h
91
+ return nil unless application
92
+
93
+ hash = {
94
+ :browser => browser,
95
+ :platform => platform,
96
+ :os => os,
97
+ :mobile => mobile?,
98
+ :bot => bot?,
99
+ }
100
+
101
+ if version
102
+ hash[:version] = version.to_a
103
+ else
104
+ hash[:version] = nil
105
+ end
106
+
107
+ if comment = application.comment
108
+ hash[:comment] = comment.dup
109
+ else
110
+ hash[:comment] = nil
111
+ end
112
+
113
+ hash
114
+ end
115
+
90
116
  private
91
117
  def detect_product(product)
92
118
  detect { |useragent| useragent.product.to_s.downcase == product.to_s.downcase }
@@ -16,6 +16,8 @@ class UserAgent
16
16
  application.comment.detect{|c| c =~ /Opera Mini/}[/Opera Mini\/([\d\.]+)/, 1] rescue Version.new
17
17
  elsif product = detect_product('Version')
18
18
  product.version
19
+ elsif product = detect_product('OPR')
20
+ product.version
19
21
  else
20
22
  super
21
23
  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.13.1
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-15 00:00:00.000000000 Z
12
+ date: 2015-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake