Project

phenotype

0.0
No commit activity in last 3 years
No release in over 3 years
versioning gem that works with rails and rack
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.10
>= 10.5
>= 3.4

Runtime

>= 1
 Project Readme

Phenotype

ruby gem for versioning routes. Current supports Sinatra and other lightweight rack frameworks.

Versioning an Application

Currently, versioning only supports blocks so you'll have to wrap your application like so.

  • Version must be numeric
  • Only one strategy is supported
  app = Phenotype::VersionedApp.new(strategies: [Phenotype::HeaderStrategy.new])
  app.add_version(version: 1) do |env|
    MyApp::V1::App.call(env)
  end

  run app

Note for Sinatra apps you can create a cascading API using use in a Sinatra base

class V2 < Sinatra::Base
  use V2Routes
  use V1Routes
end

app.add_version(version: 2) do |env|
  V2.call(env)
end

Creating a Versioning Strategy

A strategy is a class that has two methods.

  1. get_version(env) which takes a rack environment variable and returns a string of the version.

  2. version which returns the version string. This is called after get_version

See the current provided examples in lib/strategies.