user_agent 1.0.0 → 1.1.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
@@ -52,7 +52,10 @@ class UserAgent
52
52
  Wii = /wii/i
53
53
  Playstation = /playstation/i
54
54
  Ipad = /ipad/i
55
+ Ipod = /ipod/i
55
56
  Iphone = /iphone/i
57
+ Android = /android/i
58
+ Blackberry = /blackberry/i
56
59
  end
57
60
 
58
61
  def self.engine(string)
@@ -128,10 +131,13 @@ class UserAgent
128
131
  case string
129
132
  when Platform::Windows then :windows
130
133
  when Platform::Mac then :macintosh
134
+ when Platform::Android then :android
135
+ when Platform::Blackberry then :blackberry
131
136
  when Platform::Linux then :linux
132
137
  when Platform::Wii then :wii
133
138
  when Platform::Playstation then :playstation
134
139
  when Platform::Ipad then :ipad
140
+ when Platform::Ipod then :ipod
135
141
  when Platform::Iphone then :iphone
136
142
  else
137
143
  :unknown
@@ -1,3 +1,3 @@
1
1
  class UserAgent
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -5,9 +5,15 @@ describe UserAgent do
5
5
  @agent = UserAgent.new 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/528.4+ (KHTML, like Gecko) Version/4.0dp1 Safari/526.11.2'
6
6
  end
7
7
 
8
- describe ".engine_version" do
9
- it "can detect webkit" do
8
+ describe ".platform" do
9
+ it "can detect blackberry" do
10
+ agent = 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.246 Mobile Safari/534.1+'
11
+ UserAgent.platform(agent).should == :blackberry
12
+ end
10
13
 
14
+ it "can detect ipod" do
15
+ agent = 'Mozilla/5.0 (iPod; U; CPU iPhone OS 2_0 like Mac OS X; de-de) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5A347 Safari/525.20'
16
+ UserAgent.platform(agent).should == :ipod
11
17
  end
12
18
  end
13
19
 
@@ -23,6 +23,7 @@ describe UserAgent do
23
23
  test :safari, '4.0.4', :ipad, 'iPad OS 3.2', :webkit, '531.21.10', 'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'
24
24
  test :safari, '4.0.4', :ipad, 'iPad OS 3.2', :webkit, '531.21.10', 'Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'
25
25
  test :safari, '4.0', :iphone, 'iPhone OS 3.0', :webkit, '528.18', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
26
+ test :safari, '4.0', :android, 'Linux', :webkit, '533.1', 'Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'
26
27
  test :ie, '8.0', :windows, 'Windows 7', :msie, '8.0', 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)'
27
28
  test :ie, '7.0b', :windows, 'Windows 2003', :msie, '7.0b', 'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)'
28
29
  test :ie, '7.0', :windows, 'Windows XP', :msie, '7.0', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2)'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_agent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - TJ Holowaychuk