diff --git a/README.md b/README.md index 72150ff..0f94763 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ 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 @@ -62,7 +62,7 @@ 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 diff --git a/browsernizer.gemspec b/browsernizer.gemspec index e4f5153..36e7933 100644 --- a/browsernizer.gemspec +++ b/browsernizer.gemspec @@ -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 diff --git a/lib/browsernizer/router.rb b/lib/browsernizer/router.rb index bcbec10..9a427e7 100644 --- a/lib/browsernizer/router.rb +++ b/lib/browsernizer/router.rb @@ -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 diff --git a/spec/browsernizer/router_spec.rb b/spec/browsernizer/router_spec.rb index 9cb6ad6..112585a 100644 --- a/spec/browsernizer/router_spec.rb +++ b/spec/browsernizer/router_spec.rb @@ -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