{"id":13878703,"url":"https://github.com/fnordfish/teckel","last_synced_at":"2025-03-24T14:32:41.762Z","repository":{"id":46720910,"uuid":"228683838","full_name":"fnordfish/teckel","owner":"fnordfish","description":"Ruby operations with enforced contracts for input/output/error data structures","archived":false,"fork":false,"pushed_at":"2021-12-25T16:08:30.000Z","size":2215,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-19T03:54:15.740Z","etag":null,"topics":["interactors","ruby","service-objects"],"latest_commit_sha":null,"homepage":"https://fnordfish.github.io/teckel/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fnordfish.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-17T19:06:56.000Z","updated_at":"2024-05-04T15:54:35.000Z","dependencies_parsed_at":"2022-08-30T01:30:46.819Z","dependency_job_id":null,"html_url":"https://github.com/fnordfish/teckel","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fteckel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fteckel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fteckel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fnordfish%2Fteckel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fnordfish","download_url":"https://codeload.github.com/fnordfish/teckel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245289771,"owners_count":20591130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interactors","ruby","service-objects"],"created_at":"2024-08-06T08:01:57.200Z","updated_at":"2025-03-24T14:32:41.382Z","avatar_url":"https://github.com/fnordfish.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Teckel\n\nRuby service classes with enforced\u003csup name=\"footnote-1-source\"\u003e[1](#footnote-1)\u003c/sup\u003e input, output and error data structure definition.\n\n[![Gem Version](https://img.shields.io/gem/v/teckel.svg)][gem]\n[![Build Status](https://github.com/fnordfish/teckel/actions/workflows/specs.yml/badge.svg)][ci]\n[![Maintainability](https://api.codeclimate.com/v1/badges/b3939aaec6271a567a57/maintainability)](https://codeclimate.com/github/fnordfish/teckel/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/b3939aaec6271a567a57/test_coverage)](https://codeclimate.com/github/fnordfish/teckel/test_coverage)\n[![API Documentation Coverage](https://inch-ci.org/github/fnordfish/teckel.svg?branch=main)][inch]\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'teckel'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install teckel\n\n## Motivation\n\nWorking with [Interactor](https://github.com/collectiveidea/interactor), [Trailblazer's Operation](http://trailblazer.to/gems/operation) and [Dry-rb's Transaction](https://dry-rb.org/gems/dry-transaction) and probably a hand full of inconsistent \"service objects\", I missed a system that:\n\n1. provides and enforces well defined input, output and error structures\n2. makes chaining multiple operation easy and reliable\n3. is easy to debug\n\n## Usage\n\nFor a full overview please see the Docs:\n\n* [Operations](https://fnordfish.github.io/teckel/operations/basics/)\n* [Result Objects](https://fnordfish.github.io/teckel/operations/result_objects/)\n* [Chains](https://fnordfish.github.io/teckel/chains/basics/)\n\n\n```ruby\nclass CreateUser\n  include Teckel::Operation\n\n  # DSL style declaration\n  input Struct.new(:name, :age, keyword_init: true)\n\n  # Constant style declaration\n  Output = ::User\n\n  # Well, also Constant style, but using classic `class` notation\n  class Error\n    def initialize(message:, status_code:, meta:)\n      @message, @status_code, @meta = message, status_code, meta\n    end\n    attr_reader :message, :status_code, :meta\n  end\n  error_constructor :new\n\n  def call(input)\n    user = User.new(name: input.name, age: input.age)\n    if user.save\n      success!(user)\n    else\n      fail!(\n        message: \"Could not create User\",\n        status_code: 400,\n        meta: { validation: user.errors }\n      )\n    end\n  end\nend\n\nCreateUser.call(name: \"Bob\", age: 23) #=\u003e #\u003cUser @age=23, @name=\"Bob\"\u003e\n\nCreateUser.call(name: \"Bob\", age: 5)  #=\u003e #\u003cCreateUser::Error @message=\"Could not create User\", @meta={:validation=\u003e[{:age=\u003e\"underage\"}]}, @status_code=400\u003e\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/fnordfish/teckel.\nFeature requests should provide a detailed explanation of the missing or changed behavior, if possible including some sample code.\n\nPlease also see [DEVELOPMENT.md](DEVELOPMENT.md) for planned features and general guidelines.\n\n## Footnotes\n\n- \u003ca name=\"footnote-1\"\u003e1\u003c/a\u003e: Obviously, it's still Ruby and you can cheat. Don’t! [↩](#footnote-1-source)\n\n[gem]: https://rubygems.org/gems/teckel\n[ci]: https://github.com/fnordfish/teckel/actions/workflows/specs.yml\n[inch]: http://inch-ci.org/github/fnordfish/teckel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnordfish%2Fteckel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffnordfish%2Fteckel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffnordfish%2Fteckel/lists"}