Giter Site home page Giter Site logo

embedly-ruby's Introduction

embedly

embedly is the Embedly Ruby client library and commandline tool. It allows you to integrate Embedly into your Ruby applications, as well as use Embedly’s API from the commandline.

To find out what Embedly is all about, please visit embed.ly. To see our api documentation, visit api.embed.ly/docs.

Installing

To install the official latest stable version, please use rubygems.

gem install embedly

If you would like cutting edge, then you can clone and install HEAD.

git clone git://github.com/embedly/embedly-ruby.git
cd embedly-ruby
rake install

Requirements

* querystring <https://github/dokipen/querystring>

Getting Started

You can find rdocs at rubydoc.info/github/embedly/embedly-ruby/master/frames

require 'embedly'
require 'json'

embedly_api = Embedly::API.new :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; [email protected])'

# single url
obj = embedly_api.oembed :url => 'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos'
puts obj[0].marshal_dump
json_obj = JSON.pretty_generate(obj[0].marshal_dump)
puts json_obj

# multiple urls with opts
objs = embedly_api.oembed(
  :urls => ['http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos', 'http://twitpic.com/3yr7hk'],
  :maxwidth => 450,
  :wmode => 'transparent',
  :method => 'after'
)
json_obj = JSON.pretty_generate(objs.collect{|o| o.marshal_dump})
puts json_obj

# call api with key (you'll need a real key)
embedly_api = Embedly::API.new :key => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
        :user_agent => 'Mozilla/5.0 (compatible; mytestapp/1.0; [email protected])'
url = 'http://www.guardian.co.uk/media/2011/jan/21/andy-coulson-phone-hacking-statement'
obj = embedly_api.preview :url => url
puts JSON.pretty_generate(obj[0].marshal_dump)

Configuration options

You can configure some parameters in the api:

Embedly.configure do |config|
  # prints debug messages to the logger
  config.debug = true

  # use a custom logger
  config.logger = MyAwesomeLogger.new(STDERR)

  # disable typhoeus and use Net::HTTP instead
  config.request_with :net_http
end

Testing

gem install jeweler
rake spec
rake features # if it complains of missing deps install them

Some tests will fail due to missing api key. Set the EMBEDLY_KEY environmental variable with your key to get them to pass.

EMBEDLY_KEY=xxxxxxxxxxxxx rake features

To turn on debugging, set the EMBEDLY_VERBOSE environmental variable.

EMBEDLY_VERBOSE=1 EMBEDLY_KEY=xxxxxxxxxxx rake features

We have provided some commandline tools to test the Embedly interface.

* embedly_oembed
* embedly_objectify
* embedly_preview

Using –help with the commands should give you a good idea of how to use them.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2011 Embed.ly, Inc. See MIT-LICENSE for details.

embedly-ruby's People

Contributors

adie avatar arunthampi avatar coffeebite avatar devdazed avatar felipeelias avatar pablobm avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.