{"id":15546052,"url":"https://github.com/vasuadari/constant","last_synced_at":"2025-04-23T17:42:53.102Z","repository":{"id":57485532,"uuid":"210414912","full_name":"vasuadari/constant","owner":"vasuadari","description":"A package to create constants in elixir modules.","archived":false,"fork":false,"pushed_at":"2024-06-25T13:51:57.000Z","size":24,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-09T13:02:45.859Z","etag":null,"topics":["constants","elixir","elixir-library"],"latest_commit_sha":null,"homepage":null,"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/vasuadari.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-23T17:35:17.000Z","updated_at":"2024-06-25T13:52:00.000Z","dependencies_parsed_at":"2024-06-25T15:29:14.463Z","dependency_job_id":null,"html_url":"https://github.com/vasuadari/constant","commit_stats":{"total_commits":17,"total_committers":5,"mean_commits":3.4,"dds":0.3529411764705882,"last_synced_commit":"03fb398c321991d54b3c5949ffa531210f129504"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasuadari%2Fconstant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasuadari%2Fconstant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasuadari%2Fconstant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasuadari%2Fconstant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasuadari","download_url":"https://codeload.github.com/vasuadari/constant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250482953,"owners_count":21437970,"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":["constants","elixir","elixir-library"],"created_at":"2024-10-02T13:00:33.882Z","updated_at":"2025-04-23T17:42:53.084Z","avatar_url":"https://github.com/vasuadari.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Constant\n[![Build Status](https://travis-ci.org/vasuadari/constant.svg?branch=master)](https://travis-ci.org/vasuadari/constant)\n[![Hex.pm version](https://img.shields.io/hexpm/v/constant.svg)](https://hex.pm/packages/constant)\n\nA package to define constants in your module.\n\n## Installation\n\nThe package can be installed by adding `constant` to your list of dependencies\nin `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:constant, \"~\u003e 0.0.1\"}\n  ]\nend\n```\n\n## Usage\n\n```elixir\ndefmodule HTTPStatusCode do\n  import Constant\n\n  defconst ok: 200, created: 201\nend\n\niex\u003e HTTPStatusCode.ok()\n200\niex\u003e HTTPStatusCode.created()\n201\n\ndefmodule ColorCode do\n  import Constant\n\n  defconst [black: \"FFFFFF\", white: \"000000\"], atomize: true\nend\n\niex\u003e ColorCode.black()\n\"FFFFFF\"\niex\u003e ColorCode.black_atom()\n:FFFFFF\n```\n\nThe constant can be used in the format `const_\u003ckey\u003e` after requiring the module, and which enables the constant to be directly used in argument pattern matches and guards.\n\n```elixir\ndefmodule ColorCodeMatcher do\n  require ColorCode\n\n  def is_black(_color = ColorCode.const_black()), do: true\n  def is_black(_), do: false\nend\n```\n\n## License\n\nConstant source code is licensed under the [MIT License](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasuadari%2Fconstant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasuadari%2Fconstant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasuadari%2Fconstant/lists"}