wrapping an api with a ruby gem

Post on 17-Jan-2017

102 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Wrapping an APIWITH A RUBY GEM

James Thompson

● Engineering Team Lead with Mavenlink

● Software Developer since 2003

○ Ruby since 2006

○ Rails since 2007

plainprogrammer

WHY?

RTFM — Become comfortable with what you want to wrap

UnderstandTHE API YOU’RE WRAPPING

Develop a general strategy early on

UnderstandTHE API YOU’RE WRAPPING

Delve into the purpose of the API and your Gem

UnderstandTHE API YOU’RE WRAPPING

Make ChoicesDON’T FEAR YOUR BIASES

What is important, and what can wait?

Make ChoicesDON’T FEAR YOUR BIASES

How do you want to handle configuration?

Make ChoicesDON’T FEAR YOUR BIASES

What things would you change?

Some AdviceTHESE ARE MY BIASES

Start out by favoring a concrete implementation, rather than getting too fancy or abstract

Some AdviceTHESE ARE MY BIASES

Avoid implementing protocol wrappers — reading formal specs sucks

simple_bitly

module SimpleBitly # ... class Client def initialize(username, api_key) # ... end def shorten(long_url) # ... end

def expand(*short_urls) # ... end endend

bitly# lib/bitly.rbrequire 'multi_json'

require 'bitly/config'require 'bitly/utils'require 'bitly/client'require 'bitly/url'require 'bitly/version'require 'bitly/v3'

odata

# lib/odata.rbrequire 'uri'require 'date'require 'bigdecimal'require 'nokogiri'require 'typhoeus'require 'andand'

# require 'active_support'# require 'active_support/core_ext'# require 'active_support/concern'

require 'odata/version'require 'odata/property_registry'require 'odata/property'require 'odata/properties'require 'odata/complex_type'require 'odata/association'require 'odata/entity'require 'odata/entity_set'require 'odata/query/criteria'require 'odata/query/result'require 'odata/query'require 'odata/service'require 'odata/service_registry'

require 'odata/railtie' if defined?(::Rails)

top related