wrapping an api with a ruby gem

14
Wrapping an API WITH A RUBY GEM

Upload: james-thompson

Post on 17-Jan-2017

102 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Wrapping an api with a ruby gem

Wrapping an APIWITH A RUBY GEM

Page 2: Wrapping an api with a ruby gem

James Thompson

● Engineering Team Lead with Mavenlink

● Software Developer since 2003

○ Ruby since 2006

○ Rails since 2007

plainprogrammer

Page 3: Wrapping an api with a ruby gem

WHY?

Page 4: Wrapping an api with a ruby gem

RTFM — Become comfortable with what you want to wrap

UnderstandTHE API YOU’RE WRAPPING

Page 5: Wrapping an api with a ruby gem

Develop a general strategy early on

UnderstandTHE API YOU’RE WRAPPING

Page 6: Wrapping an api with a ruby gem

Delve into the purpose of the API and your Gem

UnderstandTHE API YOU’RE WRAPPING

Page 7: Wrapping an api with a ruby gem

Make ChoicesDON’T FEAR YOUR BIASES

What is important, and what can wait?

Page 8: Wrapping an api with a ruby gem

Make ChoicesDON’T FEAR YOUR BIASES

How do you want to handle configuration?

Page 9: Wrapping an api with a ruby gem

Make ChoicesDON’T FEAR YOUR BIASES

What things would you change?

Page 10: Wrapping an api with a ruby gem

Some AdviceTHESE ARE MY BIASES

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

Page 11: Wrapping an api with a ruby gem

Some AdviceTHESE ARE MY BIASES

Avoid implementing protocol wrappers — reading formal specs sucks

Page 12: Wrapping an api with a ruby gem

simple_bitly

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

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

Page 13: Wrapping an api with a ruby gem

bitly# lib/bitly.rbrequire 'multi_json'

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

Page 14: Wrapping an api with a ruby gem

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)