browsernizer 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,2 @@
1
+ = Version 0.2.0
2
+ * ditched useragent, now using browser gem (backward compatibility might be broken)
data/README.md CHANGED
@@ -47,12 +47,12 @@ If you wish to completely prevent some browsers from accessing website
47
47
  config.supported "Internet Explorer", false
48
48
 
49
49
  There is also an option to provide block for more advanced checking.
50
- [UserAgent object](https://github.com/josh/useragent/tree/master/lib) will be
50
+ [Browser object](https://github.com/fnando/browser/blob/master/lib/browser.rb) will be
51
51
  passed to it. If you wish to state that *mobile safari* is not supported, you
52
52
  can declare it like this:
53
53
 
54
- config.supported do |agent|
55
- !(agent.browser == "Safari" && agent.mobile?)
54
+ config.supported do |browser|
55
+ !(browser.name == "Safari" && browser.mobile?)
56
56
  end
57
57
 
58
58
  Specifying location is optional. If you prefer handling unsupported browsers on
@@ -85,14 +85,15 @@ You should specify browser name as a string. Here are the available options:
85
85
  And some less popular:
86
86
 
87
87
  * Android
88
- * webOS
89
88
  * BlackBerry
90
- * Symbian
91
- * Camino
92
- * Iceweasel
93
- * Seamonkey
94
-
95
- Browser detection is done using [useragent gem](https://github.com/josh/useragent).
89
+ * iPad
90
+ * iPhone
91
+ * iPod Touch
92
+ * PlayStation Portable
93
+ * QuickTime
94
+ * Apple CoreMedia
95
+
96
+ Browser detection is done using [browser gem](https://github.com/fnando/browser).
96
97
 
97
98
 
98
99
 
data/browsernizer.gemspec CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_development_dependency "rake"
22
22
  s.add_development_dependency "rspec"
23
23
 
24
- s.add_runtime_dependency 'useragent', "~> 0.4.6"
24
+ s.add_runtime_dependency 'browser', "~> 0.1.4"
25
25
  end
data/lib/browsernizer.rb CHANGED
@@ -4,4 +4,4 @@ require "browsernizer/config"
4
4
  require "browsernizer/router"
5
5
  require "browsernizer/version"
6
6
 
7
- require 'useragent'
7
+ require 'browser'
@@ -13,8 +13,8 @@ module Browsernizer
13
13
  @env = env
14
14
  @env["browsernizer"] = {
15
15
  "supported" => true,
16
- "browser" => agent.name.to_s,
17
- "version" => agent.version.to_s
16
+ "browser" => browser.name.to_s,
17
+ "version" => browser.version.to_s
18
18
  }
19
19
  handle_request
20
20
  end
@@ -57,21 +57,21 @@ module Browsernizer
57
57
  @config.get_location && @config.get_location == @env["PATH_INFO"]
58
58
  end
59
59
 
60
- def raw_agent
61
- ::UserAgent.parse @env["HTTP_USER_AGENT"]
60
+ def raw_browser
61
+ ::Browser.new :ua => @env["HTTP_USER_AGENT"]
62
62
  end
63
63
 
64
- def agent
65
- Browser.new raw_agent.browser.to_s, raw_agent.version.to_s
64
+ def browser
65
+ Browser.new raw_browser.name.to_s, raw_browser.full_version.to_s
66
66
  end
67
67
 
68
68
  # supported by default
69
69
  def unsupported?
70
70
  @config.get_supported.any? do |requirement|
71
71
  supported = if requirement.respond_to?(:call)
72
- requirement.call(raw_agent)
72
+ requirement.call(raw_browser)
73
73
  else
74
- agent.meets?(requirement)
74
+ browser.meets?(requirement)
75
75
  end
76
76
  supported === false
77
77
  end
@@ -1,3 +1,3 @@
1
1
  module Browsernizer
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -8,8 +8,8 @@ describe Browsernizer::Router do
8
8
  Browsernizer::Router.new(app) do |config|
9
9
  config.supported "Firefox", false
10
10
  config.supported "Chrome", "7.1"
11
- config.supported do |agent|
12
- !(agent.browser == "Safari" && agent.mobile?)
11
+ config.supported do |browser|
12
+ !(browser.safari? && browser.mobile?)
13
13
  end
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browsernizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-20 00:00:00.000000000Z
12
+ date: 2012-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70114364841740 !ruby/object:Gem::Requirement
16
+ requirement: &70211448089400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70114364841740
24
+ version_requirements: *70211448089400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70114364841180 !ruby/object:Gem::Requirement
27
+ requirement: &70211448116560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,18 +32,18 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70114364841180
35
+ version_requirements: *70211448116560
36
36
  - !ruby/object:Gem::Dependency
37
- name: useragent
38
- requirement: &70114364840480 !ruby/object:Gem::Requirement
37
+ name: browser
38
+ requirement: &70211448115820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 0.4.6
43
+ version: 0.1.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70114364840480
46
+ version_requirements: *70211448115820
47
47
  description: Rack middleware for redirecting unsupported user agents to "please upgrade"
48
48
  page
49
49
  email:
@@ -53,6 +53,7 @@ extensions: []
53
53
  extra_rdoc_files: []
54
54
  files:
55
55
  - .gitignore
56
+ - CHANGELOG
56
57
  - Gemfile
57
58
  - LICENSE
58
59
  - README.md
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project: browsernizer
94
- rubygems_version: 1.8.10
95
+ rubygems_version: 1.8.11
95
96
  signing_key:
96
97
  specification_version: 3
97
98
  summary: Want friendly "please upgrade your browser" page? This gem is for you.