Gris
Gris is a framework for building opinionated Rack-based hypermedia APIs. Gris aims to provide useful generators, helpers and middleware common to API microservices. Note that Gris is in development and that the ground may shift.
It makes use of Grape, Roar, RSpec, Hyperclient, and Active Record with PostgreSQL among other excellent projects. Gris is derived from/inspired by the stellar and more sophisticated Napa framework by Bellycard Inc.. We stand on the shoulders of tall people.
Installation
Gris is available as a gem on rubygems, to install it run:
gem install gris
Otherwise, if your project uses Bundler, add gris to your Gemfile:
gem 'gris'
And run:
$ bundle install
Quickstart Demo(s)
You can find example pull requests providing walkthroughs of new app set up here: https://github.com/artsy/gris-demo/pulls
Usage
CLI & Generators
Run the gris
terminal prompt to see available features:
Commands:
gris console [environment] # Start the Gris console
gris generate api <api_name> # Generate a Grape API, Model and Representer
gris generate migration <migration_name> [field[:type][:index] field[:type][:index]] # Generate a Database Migration
gris help [COMMAND] # Describe available commands or one specific command
gris new <app_name> [app_path] # Generates a scaffold for a new Gris service
gris version # Shows the Gris version number
Caching
You can use caching by including this module in your ActiveRecord models,
class OfferEvent < ActiveRecord::Base
include Gris::Caching
end
and then cache inside GET requests like this
offer_event = OfferEvent.cached_find(id)
To expire the cache for an object, call
OfferEvent.expire_cache_for(id)
or, if you have an instance, use
offer_event.expire_cache
The name
Gris is named for the Cubist painter Juan Gris.