oEmbed for Ruby

3 years after

= ruby-oembed

An oEmbed consumer library written in Ruby, letting you easily get embeddable HTML representations of supported web pages, based on their URLs. See {}[] for more about the protocol.

= Installation

gem install ruby-oembed

= Get Started

== Providers

Get information about a URL via an OEmbed::Provider. This library comes with many Providers built right in, to make your life easy.

resource = OEmbed::Providers::Youtube.get("") #=> true resource.thumbnail_url #=> "" resource.html #=> <<-HTML


If you'd like to use a provider that isn't included in the library, it's easy to create one. Just provide the oEmbed API endpoint and URL scheme(s).

my_provider ="{format}") my_provider << "http://*" my_provider << "*" resource = my_provider.get("") #=> OEmbed::Response #=> "My Cool Service"

To use multiple Providers at once, simply register them.

OEmbed::Providers.register(OEmbed::Providers::Youtube, my_provider) resource = OEmbed::Providers.get("") #=> OEmbed::Response resource.type #=> "video" #=> "Youtube"

Last but not least, ruby-oembed supports both {oohEmbed}[] and {Embedly}[]. These services are provider aggregators. Each supports a wide array of websites ranging from {}[] to {xkcd}[].

== Formatters

This library works wonderfully on its own, but can get a speed boost by using 3rd party libraries to parse oEmbed data. To use a 3rd party Formatter, just be sure to require the library before ruby-oembed.

require 'json' require 'xmlsimple' require 'oembed'

OEmbed::Formatter::JSON.backend #=> OEmbed::Formatter::JSON::Backends::JSONGem OEmbed::Formatter::XML.backend #=> OEmbed::Formatter::XML::Backends::XmlSimple

The following, optional, backends are currently supported:

= Lend a Hand

Code for the ruby-oembed library is {hosted on GitHub}[].

Get the code.

git clone git:// cd ruby-oembed

Install all development-related gems.

gem install bundler bundle install

Run the tests.

bundle exec rake

If you encounter any bug, feel free to {create an Issue}[].

We gladly accept pull requests! Just {fork}[] the library and commit your changes along with relevant tests. Once you're happy with the changes, {send a pull request}[].

We do our best to {keep our tests green}[]

= Contributors

Thanks to {all who have made contributions}[] to this gem, both large and small.

= License

This code is free to use under the terms of the MIT license.

Related Repositories



Markdown + oEmbed + Sanitize + CodeRay = the ultimate user input rendering pipel ...



Ruby Embedly Client ...



A slim library to work with oEmbed format. ...



OhEmbedr is a super simple ruby OEmbed library. ...



Thin OEmbed wrapper ...

Top Contributors

metavida judofyr evaryont voidfiles graaff kyleslattery taf2 bradleypriest florianguenther jeremyhaile hypomodern rrichards