{"id":18206732,"url":"https://github.com/millionintegrals/stone","last_synced_at":"2025-09-02T12:36:51.936Z","repository":{"id":57553524,"uuid":"68955980","full_name":"MillionIntegrals/stone","owner":"MillionIntegrals","description":"Metaprogramming utilities for the Elixir language.","archived":false,"fork":false,"pushed_at":"2017-07-28T20:26:16.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-07T19:43:21.839Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MillionIntegrals.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2016-09-22T19:39:25.000Z","updated_at":"2016-12-19T19:35:57.000Z","dependencies_parsed_at":"2022-09-19T07:51:00.261Z","dependency_job_id":null,"html_url":"https://github.com/MillionIntegrals/stone","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/MillionIntegrals/stone","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MillionIntegrals%2Fstone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MillionIntegrals%2Fstone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MillionIntegrals%2Fstone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MillionIntegrals%2Fstone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MillionIntegrals","download_url":"https://codeload.github.com/MillionIntegrals/stone/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MillionIntegrals%2Fstone/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273286548,"owners_count":25078559,"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","status":"online","status_checked_at":"2025-09-02T02:00:09.530Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-03T12:06:08.624Z","updated_at":"2025-09-02T12:36:51.868Z","avatar_url":"https://github.com/MillionIntegrals.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stone\n\n[![Build Status](https://travis-ci.org/MillionIntegrals/stone.svg?branch=master)](https://travis-ci.org/MillionIntegrals/stone)\n[![Build Status](https://img.shields.io/hexpm/v/stone.svg)](https://hex.pm/packages/stone)\n\n\nI have started this project while learning elixir macros by\ntrying to replicate functionality from\n[sasa1977/exactor](https://github.com/sasa1977/exactor).\nThe source code wasn't very clear to me, so I went on and tried to reimplement\nmyself the same features,\nwhile at the same time trying to maintain code simpliciy and clarity.\n\nThis project tries to reduce boilerplate when writing Elixir `GenServer`s by making use of\nlanguage metaprogramming capabilities.\n\nOnline documentation can be found [here](https://hexdocs.pm/stone/).\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed as:\n\n  1. Add `stone` to your list of dependencies in `mix.exs`:\n\n    ```elixir\n    def deps do\n      [{:stone, \"~\u003e 0.2.0\"}]\n    end\n    ```\n\n  2. Ensure `stone` is started before your application:\n\n    ```elixir\n    def application do\n      [applications: [:stone]]\n    end\n    ```\n\n## Functionality\n\nThis project helps remove boilerplate common when implementing `GenServer` behaviour in Elixir. In particular, it can be useful in following situations:\n\n* `start` function just packs all arguments into a tuple which it forwards to `init/1` via `GenServer.start`\n* Calls and casts interface functions just forward all arguments to the server process via `GenServer.call` and `GenServer.cast`.\n\nFor other cases, you may need to use plain `GenServer` functions (which can be used together with `Stone` macros).\n`Stone` is not meant to fully replace `GenServer`. It just tries to reduce boilerplate in most common cases.\n\n## Usage Examples\n\nLet's take a look at the following server definition:\n\n```elixir\ndefmodule CounterAgent do\n  use Stone.GenServer\n\n  defstart start_link(val \\\\ 0) do\n    initial_state(val)\n  end\n\n  defcall get(), state: state do\n    reply(state)\n  end\n\n  defcall inc(), state: state do\n    reply_and_set(state, state+1)\n  end\n\n  defcall add(x), state: state do\n    reply_and_set(state + x, state + x)\n  end\n\n  defcast set(value) do\n    noreply_and_set(value)\n  end\nend\n```\n\nAbove code defines a simple `GenServer` that maintains a counter, and exposes a convenient\ninterface to be used by other processes. Without using a library, this code would look like\nthat:\n\n```elixir\ndefmodule CounterAgent do\n  use GenServer\n  \n  def start_link(val \\\\ 0, opts \\\\ []) do\n    GenServer.start_link(CounterAgent, {val}, opts)\n  end\n  \n  def init({val}) do\n    {:ok, val}\n  end\n  \n  def get(pid) do\n    GenServer.call(pid, {:get})\n  end\n  \n  def handle_call({:get}, _from, state) do\n    {:reply, state, state}\n  end\n  \n  def inc(pid) do\n    GenServer.call(pid, {:inc})\n  end\n  \n  def handle_call({:inc}, _from, state) do\n    {:reply, state, state+1}\n  end\n  \n  def set(pid, value \\\\ 0) do\n    GenServer.cast(pid, {:set, value})\n  end\n  \n  def handle_cast({:set, value}, _from, _state) do\n    {:noreply, value}\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmillionintegrals%2Fstone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmillionintegrals%2Fstone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmillionintegrals%2Fstone/lists"}