Git Product home page Git Product logo

service_contract's Introduction

ServiceContract Build Status Code Climate Code Coverage

The gem tries to abstract the definition of a service's interface contract

Installation

Add this line to your application's Gemfile:

gem 'service_contract'

And then execute:

$ bundle

Or install it yourself as:

$ gem install service_contract

Providers

Avro

We can read an Avro protocol file to determine a set of service definitions.

Example:

class Gnomon::Contract::Service < ServiceContract::Avro::Service
  def self.data_dir
  	return "/path/to/avro_files"
  end
end

Usage

We define a service as having many versions with each version having several Protocols. A Protocol has many Endpoints.

Example:

# a Gnomon::Contract::Service instance (subclass of ServiceContract::AbstractService)
version = Gnomon::Contract::Service.find(1)
=> <#Gnomon::Contract::Service>

protocol = version.protocol("location")
=> <#ServiceContract::Avro::Protocol>

protocol.endpoints
=> [<#ServiceContract::Avro::Endpoint>,...]

Documentation

service_contract also provides a nice documentation layer packaged in the form of a sinatra rack application.

module Gnomon
  module Contract
    class Documentation < ServiceContract::Avro::Documentation
      helpers do
        def service
          Gnomon::Contract::Service
        end
      end
    end
  end
end

# in your rackup config
run Gnomon::Contract::Documentation

# or mount in rails routes
MyApplication.routes.draw do
  mount Gnomon::Contract::Documentation, at: "docs/"
end

Note: You will have to add sinatra and slim (templating engine) to your gem dependencies yourself because it's not a core dependency.

service_contract's People

Contributors

alexanderross avatar charlie-white avatar chingor13 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

service_contract's Issues

README should mention sinatra-contrib gem

I needed to add
gem "sinatra-contrib",require: false

for the project to work when using documentation. Consider calling attention to the optional gem dependencies and/or adding an example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.