# JSONiCal [![Code Climate](https://codeclimate.com/repos/58493319815f2e272a000001/badges/b5a8c4a49ed59a669e9b/gpa.svg)](https://codeclimate.com/repos/58493319815f2e272a000001/feed) [![Test Coverage](https://codeclimate.com/repos/58493319815f2e272a000001/badges/b5a8c4a49ed59a669e9b/coverage.svg)](https://codeclimate.com/repos/58493319815f2e272a000001/coverage) [![CircleCI](https://circleci.com/gh/jobteaser/jsonical.svg?style=shield&circle-token=65192822c3403a624fb9935f30ea24f27eb28b74)](https://circleci.com/gh/jobteaser/jsonical) This micro service provides an interface between your main application and calendar clients (e.g. outlook, lotus note, icalendar, etc.). # Requirements This application needs: - ruby 2.3.3 - docker - docker-compose # Be careful - This service use puma web server. The code in deps must be thread safe ! - This repo use auto deployment when commit is push on master ! # How does it work ? ![schema](docs/schema.png) An actor (e.g. your main application) pushes messages into AMQP. Listen queues are `jsonical.vevent.create`, `jsonical.vevent.update`, `jsonical.vevent.delete`. Messages must be a stringified JSON, and must respect a strict [schema](https://github.com/jobteaser/jsonical/tree/master/schemas). Example: ```json { "version": "v1", "data": { "orn": "orn:cockpit:pilotage:U3241834:action/A93489010", "calendar_orn": "orn:cockpit:pilotage:U3241834:company/C823510948", "summary": "My awesome event", "description": "No idea", "begin_date": "2016-12-15 14:30:00 +0100", "end_date": "2016-12-15 15:00:00 +0100", "uri": "https://cockpit.jobteaser.com/actions/orn:cockpit:pilotage:U3241834:action%2FA93489010", "uid": "https://cockpit.jobteaser.com/actions/orn:cockpit:pilotage:U3241834:action%2FA93489010", "klass": "PUBLIC", "created": "2016-10-10 08:32:52 +0100", "updated": "2016-10-10 08:32:52 +0100" } } ``` When an event is available in queue, the listener stores the event and acknowledges the message in AMQP. # Links - [monitoring](https://app.datadoghq.com/dash/224297/jsonical-health?live=true&page=0&is_auto=false&from_ts=1481187563852&to_ts=1481792363852&tile_size=l&utc_override=true&tv_mode=true) - [heroku](https://dashboard.heroku.com/apps/jsonical) - [issues](https://github.com/jobteaser/jsonical/issues) # Install - Up Postgres and AMQP server with docker ```shell $> docker-compose up ``` - Create .env ```shell $> cp .env.sample .env ``` - Source enviroment ```shell $> source .env ``` - Run setup script ```shell $> bin/setup ``` This will run bundler, create the database, run the migrations and seed it with `db/seed.rb` - Start application ```shell $> bundle exec foreman start ``` # Seed You can seed the database like that: `ruby db/seed.rb`. The seed generates a calendar with many event between today ± 30 days. You can run the seed again when you need more calendars. The seed script uses the [faker gem](https://rubygems.org/gems/faker) to generate fake data. You can't run seed in production mode. # Test ```shell $> bin/rspec ``` # TODO - [ ] Bump to ruby 2.4.0 - [ ] Write yard documentation