Project

taksi

0.0
No release in over a year
Useful toolset to build a backend over the concept of backend-driven UI (aka. backend for frontend).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
 Project Readme

Taksi Gem Version CI Codacy Badge

Application framework to build a backend driven UI in ruby.

Considerations

This repository are in its very early days and not ready for production yet. If you want to help or understand what it is, get a look over our inspirations on the links below:

Also, we're working in create a protocol documentation to explain the comunication details between frontend and backend.

Usage

In Taksi, every interface are composed by 1 to many components, those components are feed by data provided from the interface definition.

Defining a new component:

class Components::Users::ProfileResume
  include Taksi::Component.new('users/profile_resume')

  content do
    static :profile_kind, 'resume' # same as `field :profile_kind, Taksi::Static`

    dynamic :name

    field :details do
      field :age Taksi::Dynamic # same as `dynamic :age`
      field :email Taksi::Dynamic
    end
  end
end

Defining a new interface (in this example a interface interface):

class Interfaces::UserProfile
  include Taksi::Interface.new('user_profile')

  add Components::Users::ProfileResume, with: :profile_data

  attr_accessor :user

  def profile_data
    {
      name: user.name,
      details: {
        age: user.age,
        email: user.email,
      }
    }
  end
end

From those definitions you can set up the skeleton or strip the data:

user_profile = Interfaces::UserProfile.new
user_profile.skeleton.as_json

Which provide us:

{
  "components": [
    {
      "name": "users/profile_resume",
      "identifier": "component$0",
      "requires_data": true,
      "content": {
        "name": null,
        "profile_kind": "resume",
        "details": {
          "age": null,
          "email": null
        }
      }
    }
  ]
}

Then, you can strip the data off:

user_profile.user = User.find(logged_user_id)
user_profile.data.as_json
{
  "interface_data": [
    {
      "identifier": "component$0",
      "content": {
        "name": "Israel Trindade",
        "details": {
          "age": 29,
          "email": "irto@outlook.com",
        }
      }
    }
  ]
}

Supported Ruby versions

This library officially supports the following Ruby versions:

  • MRI >= 2.7