From 45a454c2c8482d5775247feb8f9b1ac2c2191bfb Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 30 Jan 2019 11:59:47 +0000 Subject: [PATCH] Add browser detection framework --- Gemfile | 3 +++ Gemfile.lock | 2 ++ config/initializers/browser.rb | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 config/initializers/browser.rb diff --git a/Gemfile b/Gemfile index fa1bed468..0393c9e7f 100644 --- a/Gemfile +++ b/Gemfile @@ -117,6 +117,9 @@ gem "logstasher" # Used to generate images for traces gem "gd2-ffij" +# Used for browser detection +gem "browser" + # Gems useful for development group :development do gem "annotate" diff --git a/Gemfile.lock b/Gemfile.lock index 53fb23691..7bd384a9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,6 +67,7 @@ GEM debug_inspector (>= 0.0.1) bootsnap (1.3.2) msgpack (~> 1.0) + browser (2.5.3) builder (3.2.3) cancancan (2.3.0) canonical-rails (0.2.5) @@ -394,6 +395,7 @@ DEPENDENCIES bigdecimal (~> 1.1.0) binding_of_caller bootsnap (>= 1.1.0) + browser cancancan canonical-rails capybara (~> 2.13) diff --git a/config/initializers/browser.rb b/config/initializers/browser.rb new file mode 100644 index 000000000..167fd293c --- /dev/null +++ b/config/initializers/browser.rb @@ -0,0 +1,19 @@ +module OpenStreetMap + module Browser + module Features + def html5? + webkit? || firefox? || safari? || edge? || ie?(">8") + end + + def es5? + webkit? || firefox? || safari? || edge? || ie?(">8") + end + + def es6? + webkit? || firefox? || safari? || edge? + end + end + end +end + +Browser::Base.include(OpenStreetMap::Browser::Features) -- 2.39.5