Sha256: 26c1701b9a971d154867d5f37fa3a3ee4e68abb18d5df3d529e5665936d909e2

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

# frozen_string_literal: true

require 'oembed_proxy/first_party'
require 'oembed_proxy/utility'

module OembedProxy
  # Embedly provider
  class Embedly < FirstParty
    EMBEDLY_URL = 'https://api.embed.ly/1/oembed'

    def initialize(embedly_key)
      # Import the expected embed.ly providers.
      @pattern_hash = {}
      @embedly_key = embedly_key

      File.open(File.expand_path('../../providers/embedly_patterns.def', __FILE__), 'r') do |f|
        f.each do |line|
          regex = Utility.clean_pattern(line)
          @pattern_hash[regex] = EMBEDLY_URL
        end
      end
    end

    def get_data(url, other_params = {})
      other_params[:key] = @embedly_key
      super
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oembed_proxy-0.1.1 lib/oembed_proxy/embedly.rb