{"id":21502407,"url":"https://github.com/fixrb/aw","last_synced_at":"2025-07-15T23:30:29.525Z","repository":{"id":62553817,"uuid":"44276084","full_name":"fixrb/aw","owner":"fixrb","description":"Aw, fork 😬","archived":false,"fork":false,"pushed_at":"2024-05-16T21:55:37.000Z","size":101,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-29T04:43:37.856Z","etag":null,"topics":["ruby","subprocess"],"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/fixrb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-14T20:59:33.000Z","updated_at":"2024-10-10T06:48:41.000Z","dependencies_parsed_at":"2022-11-03T04:45:29.454Z","dependency_job_id":null,"html_url":"https://github.com/fixrb/aw","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/fixrb/aw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fixrb%2Faw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fixrb%2Faw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fixrb%2Faw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fixrb%2Faw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fixrb","download_url":"https://codeload.github.com/fixrb/aw/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fixrb%2Faw/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263719163,"owners_count":23501000,"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":["ruby","subprocess"],"created_at":"2024-11-23T18:14:50.659Z","updated_at":"2025-07-15T23:30:28.663Z","avatar_url":"https://github.com/fixrb.png","language":"Ruby","readme":"# Aw\n\n[![Version](https://img.shields.io/github/v/tag/fixrb/aw?label=Version\u0026logo=github)](https://github.com/fixrb/aw/tags)\n[![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/aw/main)\n[![Ruby](https://github.com/fixrb/aw/workflows/Ruby/badge.svg?branch=main)](https://github.com/fixrb/aw/actions?query=workflow%3Aruby+branch%3Amain)\n[![RuboCop](https://github.com/fixrb/aw/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/aw/actions?query=workflow%3Arubocop+branch%3Amain)\n[![License](https://img.shields.io/github/license/fixrb/aw?label=License\u0026logo=github)](https://github.com/fixrb/aw/raw/main/LICENSE.md)\n\n\u003e Aw, fork 😬\n\n![Aw](https://github.com/fixrb/aw/raw/main/img/aw.jpg)\n\nCreates a sub-process to execute a block inside, and returns what it returns (or a boolean).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem \"aw\"\n```\n\nAnd then execute:\n\n```sh\nbundle install\n```\n\nOr install it yourself as:\n\n```sh\ngem install aw\n```\n\n## Usage\n\nTo make __Aw__ available:\n\n```ruby\nrequire \"aw\"\n```\n\nThere are two methods:\n\n- `fork!`\n- `fork?`\n\n### Method `.fork!`\n\nExecutes a block of code in a sub-process, and returns the result:\n\n```ruby\nAw.fork! { 6 * 7 } # =\u003e 42\n```\n\nWhen the execution of a block of code causes side effects, these are limited to the sub-process:\n\n```ruby\narr = [\"foo\"] # =\u003e [\"foo\"]\n\nAw.fork! { arr \u003c\u003c \"FUU\" } # =\u003e [\"foo\", \"FUU\"]\n\narr # =\u003e [\"foo\"]\n```\n\nExceptions raised in a block of code are propagated:\n\n```ruby\nAw.fork! { nil + 1 }\n```\n\nresults in the error:\n\n\u003e `NoMethodError` (undefined method `+' for nil:NilClass)\n\n### Method `.fork?`\n\nExecutes a block of code in a sub-process, and returns `true` if no exception is thrown:\n\n```ruby\nAw.fork? { 6 * 7 } # =\u003e true\n```\n\nWhen the execution of a block of code causes side effects, these are limited to the sub-process:\n\n```ruby\narr = [\"foo\"] # =\u003e [\"foo\"]\n\nAw.fork? { arr \u003c\u003c \"FUU\" } # =\u003e true\n\narr # =\u003e [\"foo\"]\n```\n\nWhen an exception is raised in a code block, `false` is returned:\n\n```ruby\nAw.fork? { nil + 1 } # =\u003e false\n```\n\n## Contact\n\n* Source code: https://github.com/fixrb/aw\n\n## Versioning\n\n__Aw__ follows [Semantic Versioning 2.0](https://semver.org/).\n\n## License\n\nThe [gem](https://rubygems.org/gems/aw) is available as open source under the terms of the [MIT License](https://github.com/fixrb/aw/raw/main/LICENSE.md).\n\n***\n\n\u003cp\u003e\n  This project is sponsored by:\u003cbr /\u003e\n  \u003ca href=\"https://sashite.com/\"\u003e\u003cimg\n    src=\"https://github.com/fixrb/aw/raw/main/img/sashite.png\"\n    alt=\"Sashité\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffixrb%2Faw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffixrb%2Faw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffixrb%2Faw/lists"}