Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gem to support only Browser v2 #18

Merged
merged 1 commit into from Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -54,15 +54,15 @@ passed to it. If you wish to state that *mobile safari* is not supported, you
can declare it like this:

config.supported do |browser|
!(browser.name == "Safari" && browser.mobile?)
!(browser.name == "Safari" && browser.device.mobile?)
end

The block should return false to block the browser, true to allow it, and nil if it
cannot decide. This way you can make any arbitrary User-Agent explicitly allowed,
even if its version would have been blocked otherwise:

config.supported do |browser|
true if browser.user_agent.include?('Linux')
true if browser.ua.include?('Linux')
end

Please note, that the order is important, thus the first block or requirement returning
Expand Down
2 changes: 1 addition & 1 deletion browsernizer.gemspec
Expand Up @@ -21,5 +21,5 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake"
s.add_development_dependency "rspec"

s.add_runtime_dependency "browser", "> 0.1.4"
s.add_runtime_dependency "browser", ">= 2.0", "< 3.0"
end
2 changes: 1 addition & 1 deletion lib/browsernizer/router.rb
Expand Up @@ -47,7 +47,7 @@ def on_redirection_path?(env)
end

def get_browsers(env)
raw_browser = ::Browser.new :ua => env["HTTP_USER_AGENT"]
raw_browser = ::Browser.new env["HTTP_USER_AGENT"]
browser = Browsernizer::Browser.new raw_browser.name.to_s, raw_browser.full_version.to_s
[raw_browser, browser]
end
Expand Down
4 changes: 2 additions & 2 deletions spec/browsernizer/router_spec.rb
Expand Up @@ -7,12 +7,12 @@
subject do
Browsernizer::Router.new(app) do |config|
config.supported do |browser|
true if browser.user_agent.include?('Spec')
true if browser.ua.include?('Spec')
end
config.supported "Firefox", false
config.supported "Chrome", "7.1"
config.supported do |browser|
!(browser.safari? && browser.mobile?)
!(browser.safari? && browser.device.mobile?)
end
end
end
Expand Down