# frozen_string_literal: true require 'oembed_proxy/inactive_support' module OembedProxy # Tableau Fauxembed class Tableau using InactiveSupport TABLEAU_REGEX = %r{\Ahttps://public\.tableau\.com/(?:profile/[^/]+/vizhome|views)/([^?]+)} def handles_url?(url) !TABLEAU_REGEX.match(url).nil? end def get_data(url, _other_params = {}) # rubocop:disable Metrics/MethodLength return nil unless handles_url? url chart_id = url.match(TABLEAU_REGEX)[1] div_id = self.class.build_div_id(chart_id) { 'type' => 'rich', 'version' => '1.0', 'provider_name' => 'Tableau', 'provider_url' => 'https://tableau.com/', 'width' => 500, 'height' => 500, 'html' => <<~HTML
HTML } end # Make a unique div_id by slapping a random 10-digit number on the end def self.build_div_id(chart_id) chart_slug = chart_id.parameterize format('%