lightweight_user_agent_parser 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d4a832dabf1e799e41f3e7923924f742f3bbea3
4
- data.tar.gz: 02963528db35f5ff59c17d46533b754f07fb7887
3
+ metadata.gz: 04a55b38d3ecf70c795febaa61b68981bc1888b5
4
+ data.tar.gz: 9b13ef73e36f46ad8de140375f87b18a1c36dc9e
5
5
  SHA512:
6
- metadata.gz: 82cd70103cc1fe4c65acb1063d5958a4103a85304f5c4110600125519b873407aab2922ce46dd2cac02080dd7f4de1f248af5469ac5aa5b77cdfa9cdcda8bde5
7
- data.tar.gz: ac138337c6af9a100005121de9e02b5fb174ae820c3a44d524be4d6726037bd8822b238f5d8ea424b8f6cf238c743e4d5d16e8a00858d1f9ac40051662f75342
6
+ metadata.gz: ad069fbad7fb6c497930c71b397c6248bb692f3883d67095396d358b4149139be6de207507a22ad816d642e188f49798ccc080ef6fefdb9d5ac015d60f6fd8aa
7
+ data.tar.gz: 2dab9275d52f62360b5af65e95ef2e15cb3ca38c8f7e0f4736495ffd7fe341186567d794b52860c54fa57ee4987fb670798ce87efb17fb575391997d4101ca1d
@@ -12,7 +12,7 @@ class LightweightUserAgentParser
12
12
  alias to_s user_agent_string
13
13
 
14
14
  def initialize(user_agent_str)
15
- @user_agent_string = user_agent_str || raise(ArgumentError)
15
+ @user_agent_string = (user_agent_str || raise(ArgumentError)).to_s
16
16
  end
17
17
 
18
18
  def platform
@@ -30,7 +30,6 @@ class LightweightUserAgentParser
30
30
  end
31
31
  end
32
32
 
33
- # if detected as a mobile such as Nokia C2-01 and others than Symbian
34
33
  return :other
35
34
 
36
35
  }.call
@@ -40,7 +39,7 @@ class LightweightUserAgentParser
40
39
  mobile = !!(user_agent_string =~ MOBILE_REGEXP)
41
40
  desktop = !!(user_agent_string =~ DESKTOP_REGEXP)
42
41
 
43
- (mobile or not desktop) #and not anonymized?
42
+ (mobile or not desktop) and not empty?
44
43
  end
45
44
 
46
45
  alias mobile? is_mobile?
@@ -49,4 +48,10 @@ class LightweightUserAgentParser
49
48
  !!(user_agent_string =~ ANONYMIZED_REGEXP)
50
49
  end
51
50
 
51
+ protected
52
+
53
+ def empty?
54
+ user_agent_string.empty?
55
+ end
56
+
52
57
  end
@@ -1,3 +1,3 @@
1
1
  class LightweightUserAgentParser
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.3.1'.freeze
3
3
  end
@@ -3,6 +3,12 @@ require 'spec_helper'
3
3
  RSpec.describe LightweightUserAgentParser do
4
4
 
5
5
  TEST_CASES = [
6
+
7
+ {
8
+ ua_str: '',
9
+ mobile: false,
10
+ platform: 'other'
11
+ },
6
12
  {
7
13
  ua_str: 'UCWEB/2.0 (Linux; U; Adr 4.2.1; zh-CN; Lenovo A3000) U2/1.0.0 UCBrowser/9.8.5.442 U2/1.0.0 Mobile',
8
14
  mobile: true,
@@ -112,11 +118,15 @@ RSpec.describe LightweightUserAgentParser do
112
118
  TEST_CASES.each do |meta|
113
119
 
114
120
  context "when platform is #{meta[:platform]}" do
115
- let(:ua_str) { meta[:ua_str] }
116
121
 
117
- it "then the mobile state should be #{meta[:mobile]}" do
118
- is_expected.to eq meta[:mobile]
122
+ context "and the user agent string is: #{meta[:ua_str].inspect}" do
123
+ let(:ua_str) { meta[:ua_str] }
124
+
125
+ it "then the mobile state should be #{meta[:mobile]}" do
126
+ is_expected.to eq meta[:mobile]
127
+ end
119
128
  end
129
+
120
130
  end
121
131
 
122
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightweight_user_agent_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emarsys Technologies