{"id":16800535,"url":"https://github.com/derailed/ex_cut","last_synced_at":"2025-04-11T00:31:53.275Z","repository":{"id":57500291,"uuid":"107609115","full_name":"derailed/ex_cut","owner":"derailed","description":"Elixir Cross Cutting function annotations","archived":false,"fork":false,"pushed_at":"2017-10-30T23:22:32.000Z","size":59,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T21:13:38.984Z","etag":null,"topics":["annotation","cross-cut","elixir"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derailed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-19T23:26:54.000Z","updated_at":"2023-05-14T14:45:18.000Z","dependencies_parsed_at":"2022-08-30T20:42:18.136Z","dependency_job_id":null,"html_url":"https://github.com/derailed/ex_cut","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derailed%2Fex_cut","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derailed%2Fex_cut/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derailed%2Fex_cut/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derailed%2Fex_cut/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derailed","download_url":"https://codeload.github.com/derailed/ex_cut/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247882162,"owners_count":21012007,"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":["annotation","cross-cut","elixir"],"created_at":"2024-10-13T09:33:47.696Z","updated_at":"2025-04-11T00:31:53.244Z","avatar_url":"https://github.com/derailed.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExCut [cross-cut]\n\n\u003cdiv align=\"center\" style=\"margin-top:10px;\"\u003e\n  \u003cimg src=\"assets/ex_cut.png\"/\u003e\n\u003c/div\u003e\n\n[![Hex version](https://img.shields.io/hexpm/v/ex_cut.svg \"Hex version\")](https://hex.pm/packages/ex_cut)\n[![Build Status](https://semaphoreci.com/api/v1/projects/2873a400-892d-47db-826b-79e15a263818/1595691/shields_badge.svg)](https://semaphoreci.com/imhotep/ex_cut)\n\n## Motivation\n\n  ExCut defines an annotation construct that wraps a regular function and enable\n  it to be decorated with a cross-cutting concern. This provide a clean mechanism\n  to inject reusable behavior without cluttering your code base.\n\n## Documentation\n\n[ExCut](https://hexdocs.pm/ex_cut)\n\n## Examples\n\n[ExCut Examples](https://github.com/derailed/ex_cut/tree/master/examples)\n\n## Installation\n\n  Add the following dependencies to your Elixir project\n\n  ```elixir\n  def deps do\n    [\n      {:ex_cut , \"~\u003e 0.1.0\"}\n    ]\n  end\n  ```\n\n## Using\n\n  Let's take a look at ExCut in action to add logging behavior to a set of\n  functions.\n\n  ```elixir\n  defmodule Logging do\n    use ExCut, marker: :log, pre: :pre, post: :post\n\n    require Logger\n\n    @log level: :warn\n    def elvis(a, b) when is_boolean(a), do: b\n\n    @log level: :debug\n    def elvis(a, b) when is_atom(a), do: \"#{a}--#{b}\"\n\n    @log level: :info\n    def elvis(a, b), do: a + b\n\n    defp pre(c)       , do: \"\u003e #{c.target}(#{c.args |\u003e inspect})\" |\u003e log(c)\n    defp post(c, _, r), do: \"\u003c #{c.target} -\u003e #{r}\"               |\u003e log(c)\n\n    defp log(m, ctx) do\n      ctx.meta[:level]\n      |\u003e case do\n        :warn  -\u003e m |\u003e Logger.warn\n        :debug -\u003e m |\u003e Logger.debug\n        _      -\u003e m |\u003e Logger.info\n      end\n    end\n  end\n  ```\n\n  ExCut provisions an `ExCut.Context` with call details and metadata\n  that comes from the annotation. You can leverage this information in\n  your cross-cutting functions.\n\n---\n\u003cimg src=\"assets/imhoteplogo.png\" width=\"32\" height=\"auto\"/\u003e © 2017 Imhotep Software LLC.\nAll materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderailed%2Fex_cut","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderailed%2Fex_cut","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderailed%2Fex_cut/lists"}