Lacerda Circle CI Coverage Status Code Climate Dependency Status Gem Version

«No, no -- we have to go on. We need total coverage.»1

This gem can:

  • convert MSON to JSON Schema files
  • read a directory which contains one directory per service
  • read a publish.mson and a consume.mson from each service
  • build a model of your infrastructure knowing
    • which services publishes what to which other service
    • which service consumes what from which other service
    • if all services consume and publish conforming to their contracts.

You likely don't want to use it on its own but integrate your infrastructure via

Zeta

. Click the link, it will explains things in more detail. If you're just looking for one way to transform MSON files into JSON Schema, read on:

MSON to JSON schema

Lacerda offers a rake task that converts MSON files into JSON schemas. To convert all *.mson files in contracts/ into *.schema.json files,

put this in your Rakefile:

require "lacerda/tasks"

and smoke it:

/home/dev/lacerda$ DATA_DIR=contracts/ rake lacerda:mson_to_json_schema
Converting 4 files:
OK /home/dev/lacerda/specifications/consumer/consume.mson
OK /home/dev/lacerda/specifications/invalid_property/consume.mson
OK /home/dev/lacerda/specifications/missing_required/consume.mson
OK /home/dev/lacerda/specifications/publisher/publish.mson
/home/dev/lacerda$

Structure

By loading all files in a directory this gem will build up the following relationships:

  • Infrastructure
    • Service
    • Contracts
      • Publish specification
      • PublishedObjects
      • Consume specification
      • ConsumedObjects

Compatibility

Until there is a native MSON to JSON schema parser available, we do the conversion ourselves. These features from the MSON specification are currently supported:

  • [x] primitive properties: string, number, boolean, null
  • [x] object properties
  • [x] array properties with items of one type
  • [x] array properties of mixed types
  • [ ] array properties of arrays
  • [x] enum properties
  • [x] One of properties mutually exclusive properties
  • [x] Referencing
  • [ ] Mixins
  • [ ] Variable property names

Tests and development

  • run bundle once
  • run guard in a spare terminal which will run the tests, install gems, and so forth
  • run rspec spec to run all the tests
  • check out open coverage/index.html or open coverage/rcov/index.html
  • run bundle console to play around with a console

References

[1] This quote in French quotation marks is from "Fear and Loathing in Las Vegas". Since I can't link to the book, a link to the movie script shall suffice.