/ogp

Simple Ruby library for parsing Open Graph prototocol information. See http://ogp.me for more information.

Primary LanguageRubyMIT LicenseMIT

ogp
OGP is a minimalist Ruby library that does only one thing: parse Open Graph protocol information. For more information: http://ogp.me.

Installation

Add this line to your application’s Gemfile:

gem 'ogp'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ogp

Usage

In order to keep OGP very simple, it does not perform any HTTP operations. As such, in this example, Faraday is used to achieve this functionality.

require 'faraday'
require 'ogp'

response = Faraday.get('http://ogp.me')

open_graph = OGP::OpenGraph.new(response.body)
open_graph.title # => "Open Graph protocol"
open_graph.type # => "website"
open_graph.image.url # => "http://ogp.me/logo.png"
open_graph.url # => "http://ogp.me/"

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jcouture/ogp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

The OGP pirate logo is based on this icon by Simon Child, from the Noun Project. Used under a Creative Commons BY 3.0 license.