Sep Presentation Slot

From: Ho-Sheng H.
Sent on: Monday, August 15, 2011 8:26 PM
Hey people (and meetup organizers),

I asked for a presentation slot for the Sep. meetup but had to clear it with my boss. I just talked with him and it's cleared up.

I want to present a gem I extracted from internal Sparkfly code called Intermodal. This gem lets you quickly put together an authenticated (private) RESTful API. I have it out on github now at: https://github.com/hosh/intermodal

By way of example:

module EventApp
  module API
    class V1_0 < Intermodal::Base

      map_data do

        presentation_for :event do
          include Intermodal::Presenters::NamedResource
          presents :description
          presents :starts_at
          presents :ends_at
          presents :status
        end

        acceptance_for :event do
          include Intermodal::Acceptors::NamedResource
          accepts :description
          accepts :starts_at
          accepts :ends_at
        end
     end

     controllers do
        resources :events
     end

     self.routes = proc do
       resources :events
     end
  end
end

This will create the five RESTful CRUD+I endpoints for events:

GET /events.json
POST /events.json
GET /events/:id.json
PUT /events/:id.json
DELETE /events/:id.json

Combined with rspec macros that look like:

  describe EventApp::Application do
    include SpecHelpers::Resources
    include SpecHelpers::Application
    let(:request_url_prefix) { 'v1.0' }

    context 'Resources' do
      resources 'events' do
        given_create_attributes :name => 'New Event', :starts_at => Time.now, :ends_at => 1.day.from.now, :account_id => 1
        given_update_attributes :name => 'Updated Event'

        expects_resource_crud
      end
  end

Which expands out to 40 spec examples testing JSON/XML, each of the CRUD functions, and proper MIME/TYPE and HTTP Status returns. All tests are done through Rack and tested against the Rack response.

What's in the github right now is *not* a retail experience (for example, I have not tried this on 1.9 or on Rails 3.1 yet). There are no installation documentation or example code. There are a lot of warts and some issues. What I want to present for Sep. is something with a reasonable install docs and how to actually use it.

The presentation includes:

- Why I wrote this
- How to get started
- Resources
  - Top-level resources
  - Nested resources
  - Linking resources
- How to test it
- Known Big Issues

If anyone has suggestions for what they want to see, please let me know.

-Hosh

Our Sponsors

  • Mandrill

    Sponsors food, meeting space, and other expenses.

  • Pardot

    Sponsors food, meeting space, and other expenses.

  • ATDC

    Provides space for meetings.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy