Sha256: 75bcec7c423f0f72f4153db38711618dcd59daff298dcc9b1c47ebee0228a4e5

Contents?: true

Size: 782 Bytes

Versions: 7

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

require 'oembed_proxy/inactive_support'

module OembedProxy
  # NPR Fauxembed
  class Npr
    using InactiveSupport
    NPR_REGEX = %r{\Ahttps:\/\/(?:[a-z0-9-]+\.)+npr\.org\/.+}.freeze

    def handles_url?(url)
      !NPR_REGEX.match(url).nil?
    end

    def get_data(url, _other_params = {}) # rubocop:disable Metrics/MethodLength
      return nil unless handles_url? url

      escaped_url = url.gsub('"', '"')
      {
        'type' => 'rich',
        'version' => '1.0',
        'provider_name' => 'NPR',
        'provider_url' => 'https://www.npr.org/',
        'html' => <<~HTML,
          <div class='sidechain-wrapper'>
            <side-chain src="#{escaped_url}"></side-chain>
          </div>
        HTML
      }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
oembed_proxy-0.3 lib/oembed_proxy/npr.rb
oembed_proxy-0.2.6 lib/oembed_proxy/npr.rb
oembed_proxy-0.2.5 lib/oembed_proxy/npr.rb
oembed_proxy-0.2.4 lib/oembed_proxy/npr.rb
oembed_proxy-0.2.3 lib/oembed_proxy/npr.rb
oembed_proxy-0.2.2 lib/oembed_proxy/npr.rb
oembed_proxy-0.2.1 lib/oembed_proxy/npr.rb