{"id":22200697,"url":"https://github.com/amrrbakry/resultt","last_synced_at":"2025-08-13T18:09:29.058Z","repository":{"id":56892068,"uuid":"212607457","full_name":"amrrbakry/resultt","owner":"amrrbakry","description":"A simple library to wrap execution result in smart success or error objects.","archived":false,"fork":false,"pushed_at":"2020-03-02T16:24:19.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T21:05:01.451Z","etag":null,"topics":["error","result","resultt","ruby","success"],"latest_commit_sha":null,"homepage":"","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/amrrbakry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-03T14:58:49.000Z","updated_at":"2020-03-02T16:24:19.000Z","dependencies_parsed_at":"2022-08-21T00:20:52.869Z","dependency_job_id":null,"html_url":"https://github.com/amrrbakry/resultt","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/amrrbakry/resultt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fresultt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fresultt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fresultt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fresultt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amrrbakry","download_url":"https://codeload.github.com/amrrbakry/resultt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fresultt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270287088,"owners_count":24558616,"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-08-13T02:00:09.904Z","response_time":66,"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":["error","result","resultt","ruby","success"],"created_at":"2024-12-02T15:36:21.248Z","updated_at":"2025-08-13T18:09:29.032Z","avatar_url":"https://github.com/amrrbakry.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Resultt\nA simple library to wrap execution result in smart success or error objects.\n```ruby\nsuccess_result = Result do\n  1 + 1\nend\n# =\u003e #\u003cResultt::Success:0x0000000098c718 @value=2\u003e\n\nsuccess_result.success? # true\nsuccess_result.value # 2\nsuccess_result.error? # false\n\nerror_result = Result do\n  raise StandardError, 'error result'\nend\n# =\u003e #\u003cResultt::Error:0x000000007c5498 @error=#\u003cStandardError: error result\u003e\u003e\n\nerror_result.error? # true\nerror_result.error # #\u003cStandardError: error result\u003e\n```\n```ruby\nresult = Result do\n  # do something\nend\n\ncase result\nwhen Resultt::Success then 'it is a success!'\nwhen Resultt::Error then 'oh no! error!'\nend\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'resultt'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install resultt\n\n## Usage\n\nextend `Resultt` in your class and you're good to go!\n```ruby\nclass MyClass\n  extend Resultt\n\n  def foo\n    Result do\n      # do something\n    end\n  end\nend\n```\n#### `map` and `map_error`\nit is possible to map on values and errors in `Resultt` objects using `map` and `map_error` respectively:\n```ruby\nresult = Result { 1 + 1 }\n# =\u003e #\u003cResultt::Success:0x000000007502d8 @value=2\u003e\nmapped_result = result.map { |value| value + 1 }\n# =\u003e #\u003cResultt::Success:0x000000007502d8 @value=3\u003e\n\nresult = Result { raise StandardError, 'error' }\n# =\u003e #\u003cResultt::Error:0x00000000bc8d88 @error=#\u003cStandardError: error\u003e\u003e\nmapped_result = result.map_error { |error| error.class.to_s }\n# =\u003e #\u003cResultt::Error:0x00000000be6568 @error=\"StandardError\"\u003e\n```\n#### `Success` and `Error`\nit is also possible to wrap values or errors in `Resultt::Success` or `Resultt::Error` objects directly:\n```ruby\nSuccess('ok')\n# =\u003e #\u003cResultt::Success:0x0000000076b718 @value=\"ok\"\u003e\nError('err')\n# =\u003e #\u003cResultt::Error:0x00000000764a08 @error=\"err\"\u003e\n```\n\n### Nil values\n`Result` will return `Resultt::NilValueError` if the block passed to it evaluates to `nil`. This is to avoid having success results with `nil` values.\n```ruby\nResult do\n  nil\nend\n# =\u003e #\u003cResultt::Error:0x00000000afa000 @error=#\u003cResultt::NilValueError: Result returned a nil value\u003e\u003e\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\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/amrrbakry/resultt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Resultt project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/amrrbakry/resultt/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famrrbakry%2Fresultt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famrrbakry%2Fresultt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famrrbakry%2Fresultt/lists"}