Add browser detection framework
authorTom Hughes <tom@compton.nu>
Wed, 30 Jan 2019 11:59:47 +0000 (11:59 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 30 Jan 2019 12:11:34 +0000 (12:11 +0000)
Gemfile
Gemfile.lock
config/initializers/browser.rb [new file with mode: 0644]

diff --git a/Gemfile b/Gemfile
index fa1bed4..0393c9e 100644 (file)
--- 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"
index 53fb236..7bd384a 100644 (file)
@@ -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 (file)
index 0000000..167fd29
--- /dev/null
@@ -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)