{"id":15561885,"url":"https://github.com/doodzik/defp","last_synced_at":"2026-03-13T09:31:10.042Z","repository":{"id":22398446,"uuid":"25735530","full_name":"doodzik/defp","owner":"doodzik","description":"pattern matching for ruby","archived":false,"fork":false,"pushed_at":"2015-07-27T01:40:01.000Z","size":196,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T22:53:49.002Z","etag":null,"topics":["defp","pattern-matching","ruby"],"latest_commit_sha":null,"homepage":"dudzik.co","language":"Ruby","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/doodzik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-25T15:15:28.000Z","updated_at":"2017-04-01T18:10:48.000Z","dependencies_parsed_at":"2022-08-21T05:00:19.854Z","dependency_job_id":null,"html_url":"https://github.com/doodzik/defp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fdefp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fdefp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fdefp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodzik%2Fdefp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doodzik","download_url":"https://codeload.github.com/doodzik/defp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528699,"owners_count":21445511,"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":["defp","pattern-matching","ruby"],"created_at":"2024-10-02T16:10:33.924Z","updated_at":"2026-03-13T09:31:05.010Z","avatar_url":"https://github.com/doodzik.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Defp\n\n[![Build Status](https://travis-ci.org/doodzik/defp.svg?branch=master)](https://travis-ci.org/doodzik/defp)\n\nAn pattern matching implementation in ruby inspired by haskell.\nIf you want to know about the inner workings of defp [check out this blog post](http://dudzik.co/blog/2014/10/27/i-went-on-a-journey-to-haskell-and-all-i-got-was-a-pattern-matcher-for-ruby/).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n\n```ruby\ngem 'defp'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install defp\n\n## Usage\n\n```ruby\nclass Example\n  extend Defp\n\n  # With normal params\n  def  normal_params(value1, value2)\n  defp              ('hello', _    ) == 'foo'\n  defp              (_, 'hello'    ) == -\u003e do\n    'bar'\n  end\n    'baz'\n  end\n\n  # With keyword arguments\n  def self.keyword_params(value1: ,value2:)\n  defp(value1: 'hello', value2: _) == 'foo' # you can specify blank vars\n  defp(value2: 'hello')            == -\u003e { 'bar' }     # or not specifying them at all\n    'baz'\n  end\n\n  # With mixed params\n  def self.mixed_params(value1 = {}, value2, value3)\n  defp({value2: 'hello'}, 'dud', _) == 'foo'\n    'bar'\n  end\nend\n```\n\n## Contributing\n\n1. Fork it ( https://github.com/doodzik/defp/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoodzik%2Fdefp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoodzik%2Fdefp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoodzik%2Fdefp/lists"}