Sha256: 71e0e233f81af8795d65baa38c80a762a5f36f53c6f1d66a9b7f943b2ee43470

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

require 'forwardable'
require 'sinatra/base'
require 'slim'

module Kamerling class HTTPAPI < Sinatra::Base
  extend Forwardable

  configure { set repos: Repos }

  get '/' do
    slim :root
  end

  get '/clients' do
    warn_off { slim :clients, locals: { clients: repos.clients } }
  end

  get '/projects' do
    warn_off { slim :projects, locals: { projects: repos.projects } }
  end

  get '/projects/:project_uuid' do
    project = repos.project params['project_uuid']
    clients = repos.clients_for project
    tasks   = repos.tasks_for project
    warn_off { slim :project, locals: { clients: clients, tasks: tasks } }
  end

  post '/projects' do
    uuid = params.fetch('uuid') { UUID.new }
    repos << Project.new(name: params['name'], uuid: uuid)
    redirect '/projects'
  end

  private

  delegate repos: :settings
end end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kamerling-0.0.2 lib/kamerling/http_api.rb
kamerling-0.0.1 lib/kamerling/http_api.rb