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:

 = Interfaces::UserProfile.new
.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 = User.find(logged_user_id)
.data.as_json
{
  "interface_data": [
    {
      "identifier": "component$0",
      "content": {
        "name": "Israel Trindade",
        "details": {
          "age": 29,
          "email": "[email protected]",
        }
      }
    }
  ]
}

Supported Ruby versions

This library officially supports the following Ruby versions:

  • MRI >= 2.7