browser 0.4.1 → 0.5.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.
@@ -1,48 +1,48 @@
1
- require "test_helper"
1
+ require "spec_helper"
2
2
  require "browser/rails"
3
3
  require "sample_app"
4
4
 
5
- class MiddlewareTest < Test::Unit::TestCase
5
+ describe Browser::Middleware do
6
6
  include Rack::Test::Methods
7
7
 
8
8
  def app
9
9
  Rails.application
10
10
  end
11
11
 
12
- def test_redirect_uses_302
12
+ it "redirects with 302" do
13
13
  get "/", {}, {"HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "text/html"}
14
14
  assert_equal 302, last_response.status
15
15
  end
16
16
 
17
- def test_redirect_ie6_to_upgrade_path
17
+ it "redirects ie6 to upgrade path" do
18
18
  get "/", {}, {"HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "text/html"}
19
19
  follow_redirect!
20
20
 
21
21
  assert_equal "UPGRADE: ie6", last_response.body
22
22
  end
23
23
 
24
- def test_redirect_ie7_to_upgrade_path
24
+ it "redirects ie7 to upgrade path" do
25
25
  get "/", {}, {"HTTP_USER_AGENT" => "MSIE 7", "HTTP_ACCEPT" => "text/html"}
26
26
  follow_redirect!
27
27
 
28
28
  assert_equal "UPGRADE: ie7", last_response.body
29
29
  end
30
30
 
31
- def test_redirect_ie8_and_404
31
+ it "redirects ie8 and returns 404" do
32
32
  get "/", {}, {"HTTP_USER_AGENT" => "MSIE 8", "HTTP_ACCEPT" => "text/html"}
33
33
  follow_redirect!
34
34
 
35
35
  assert_equal 404, last_response.status
36
36
  end
37
37
 
38
- def test_redirect_ie8_with_wildcard_http_accept
38
+ it "redirects ie8 with wildcard http accept" do
39
39
  get "/", {}, {"HTTP_USER_AGENT" => "MSIE 8", "HTTP_ACCEPT" => "*/*"}
40
40
  follow_redirect!
41
41
 
42
42
  assert_equal 404, last_response.status
43
43
  end
44
44
 
45
- def test_ignores_non_html_requests
45
+ it "ignores non-html requests" do
46
46
  get "/", {}, {"HTTP_USER_AGENT" => "MSIE 6", "HTTP_ACCEPT" => "image/png"}
47
47
 
48
48
  assert_equal 200, last_response.status
@@ -0,0 +1,8 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
2
+ require "bundler/setup"
3
+ require "minitest/autorun"
4
+ require "minitest/unit"
5
+ require "browser"
6
+ require "yaml"
7
+
8
+ $ua = YAML.load_file("./test/ua.yml")
@@ -0,0 +1,67 @@
1
+ IPHONE: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/1A542a Safari/419.3"
2
+ IPOD: "Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A100a Safari/419.3"
3
+ IPAD: "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/7B367 Safari/531.21.10"
4
+ SAFARI: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.17.8 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8"
5
+ IE6: "Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"
6
+ IE7: "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)"
7
+ IE8: "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)"
8
+ IE8_COMPAT: "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; SLCC1; Media Center PC 5.0; .NET CLR 3.5.21022)"
9
+ IE9: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
10
+ IE9_COMPAT: "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)"
11
+ IE10: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; EIE10;ENUSMSN)"
12
+ IE10_COMPAT: "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; EIE10;ENUSMSN)"
13
+ IE10_X64_WINX64: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)"
14
+ IE11: "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
15
+ IE11_TOUCH_SCREEN: "Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; Touch; rv:11.0) like Gecko"
16
+ OPERA: "Opera/9.80 (Macintosh; Intel Mac OS X 10.7.4; U; en) Presto/2.10.229 Version/11.64"
17
+ OPERA_NEXT: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.37 Safari/537.36 OPR/15.0.1147.44 (Edition Next)"
18
+ FIREFOX: "Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8"
19
+ FIREFOX_MODERN: "Mozilla/5.0 (X11; Ubuntu; Linux armv7l; rv:17.0) Gecko/20100101 Firefox/17.0"
20
+ FIREFOX_TABLET: "Mozilla/5.0 (Android; Tablet; rv:14.0) Gecko/14.0 Firefox/14.0"
21
+ CHROME: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4"
22
+ MOBILE_CHROME: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3"
23
+ CHROME_OS: "Mozilla/5.0 (X11; CrOS x86_64 3701.81.0) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.57 Safari/537.31."
24
+ ANDROID: "Android SDK 1.5r3: Mozilla/5.0 (Linux; U; Android 1.5; de-; sdk Build/CUPCAKE) AppleWebkit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1"
25
+ TABLOID: "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13"
26
+ BLACKBERRY: "BlackBerry7100i/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/103"
27
+ BLACKBERRY4: "BlackBerry8100/4.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/103"
28
+ BLACKBERRY5: "BlackBerry9000/5.0.0.93 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/179"
29
+ BLACKBERRY6: "Mozilla/5.0 (BlackBerry; U; BlackBerry AAAA; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/6.0.0.141 Mobile Safari/534.11+"
30
+ BLACKBERRY7: "Mozilla/5.0 (BlackBerry; U; BlackBerry AAAA; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.1 Mobile Safari/534.11+"
31
+ BLACKBERRY10: "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.1675 Mobile Safari/537.10+"
32
+ PSP: "Mozilla/4.0 (PSP (PlayStation Portable); 2.00)"
33
+ PSP_VITA: "Mozilla/5.0 (Playstation Vita 1.61) AppleWebKit/531.22.8 (KHTML, like Gecko) Silk/3.2"
34
+ QUICKTIME: "QuickTime/7.6.8 (qtver=7.6.8;os=Windows NT 5.1Service Pack 3)"
35
+ COREMEDIA: "Apple Mac OS X v10.6.4 CoreMedia v1.0.0.10F569"
36
+ XOOM: "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13"
37
+ NEXUS_TABLET: "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19"
38
+ NOOK: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; NOOK BNTV250A Build/GINGERBREAD 1.4.3) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Safari/533.1"
39
+ SAMSUNG: "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; SAMSUNG-SGH-I497 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30"
40
+ OPERA_MINI: "Opera/9.80 (Android; Opera Mini/7.029952/28.2359;u; fr) Presto/2.8.119 Version/11.10"
41
+ OPERA_MOBI: "Opera/9.8 (Android 2.3.5; Linux; Opera Mobi/ADR-1205181138; U; en) Presto/2.10.254 Version/12.00"
42
+ WINDOWS_PHONE: "Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; DELL; Venue Pro)"
43
+ WINDOWS_PHONE8: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)"
44
+ WINDOWS_MOBILE: "Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 6.12)"
45
+ WINDOWS8: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"
46
+ WINDOWS81: "Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko"
47
+ SURFACE: "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)"
48
+ KINDLE: "Mozilla/5.0 (Linux; U; en-US) AppleWebKit/528.5+ (KHTML, like Gecko, Safari/528.5+) Version/4.0 Kindle/3.0 (screen 600×800; rotate)"
49
+ KINDLE_FIRE: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
50
+ KINDLE_FIRE_HD: "Mozilla/5.0 (Linux; U; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Safari/535.19 Silk-Accelerated=true"
51
+ KINDLE_FIRE_HD_MOBILE: "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.4 Mobile Safari/535.19 Silk-Accelerated=true"
52
+ PHANTOM_JS: "Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.0 Safari/534.34"
53
+ IOS4: "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7"
54
+ IOS5: "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
55
+ IOS6: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"
56
+ IOS7: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53"
57
+ PLAYBOOK: "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+"
58
+ NINTENDO_WII: "Opera/9.00 (Nintendo Wii; U; ; 1309-9; en)"
59
+ NINTENDO_WIIU: "Mozilla/5.0 (Nintendo WiiU) AppleWebKit/534.52 (KHTML, like Gecko) NX/2.1.0.8.23 NintendoBrowser/1.1.0.7579.EU"
60
+ PLAYSTATION3: "Mozilla/5.0 (PLAYSTATION 3; 3.55)"
61
+ PLAYSTATION4: "Mozilla/5.0 (PlayStation 4 1.020) AppleWebKit/536.26 (KHTML, like Gecko)"
62
+ XBOX360: "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; Xbox), or Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; Xbox)"
63
+ XBOXONE: "Mozilla/5.0 (Compatible; MSIE 10.0; Windows NT 6.2; Trident /6.0; Xbox; Xbox One)"
64
+ GOOGLE_BOT: "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
65
+ MSN_BOT: "msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)"
66
+ FACEBOOK_BOT: "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"
67
+ SMART_TV: "Mozilla/5.0 (SmartHub; SMART-TV; U; Linux/SmartTV) AppleWebKit/531.2+ (KHTML, like Gecko) WebBrowser/1.0 SmartTV Safari/531.2+"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,21 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry-meta
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: turn
70
+ name: minitest
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -102,6 +88,7 @@ extensions: []
102
88
  extra_rdoc_files: []
103
89
  files:
104
90
  - ".gitignore"
91
+ - ".hound.yml"
105
92
  - ".travis.yml"
106
93
  - Gemfile
107
94
  - README.md
@@ -110,6 +97,7 @@ files:
110
97
  - browser.gemspec
111
98
  - config.ru
112
99
  - gemfiles/rails3.gemfile
100
+ - languages.yml
113
101
  - lib/browser.rb
114
102
  - lib/browser/action_controller.rb
115
103
  - lib/browser/meta/base.rb
@@ -136,10 +124,11 @@ files:
136
124
  - lib/browser/middleware/context/url_methods.rb
137
125
  - lib/browser/rails.rb
138
126
  - lib/browser/version.rb
139
- - test/browser_test.rb
140
- - test/middleware_test.rb
127
+ - test/browser_spec.rb
128
+ - test/middleware_spec.rb
141
129
  - test/sample_app.rb
142
- - test/test_helper.rb
130
+ - test/spec_helper.rb
131
+ - test/ua.yml
143
132
  homepage: http://github.com/fnando/browser
144
133
  licenses: []
145
134
  metadata: {}
@@ -163,4 +152,9 @@ rubygems_version: 2.2.2
163
152
  signing_key:
164
153
  specification_version: 4
165
154
  summary: Do some browser detection with Ruby.
166
- test_files: []
155
+ test_files:
156
+ - test/browser_spec.rb
157
+ - test/middleware_spec.rb
158
+ - test/sample_app.rb
159
+ - test/spec_helper.rb
160
+ - test/ua.yml
@@ -1,9 +0,0 @@
1
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
2
- require "bundler/setup"
3
- require "test/unit"
4
- require "browser"
5
- require "turn"
6
- require "turn/reporter"
7
-
8
- Turn.config.format = :dot
9
- $RUBY_IGNORE_CALLERS += [%r[/gems/], %r[minitest/unit.rb]]