{"id":18026815,"url":"https://github.com/yegor256/random-port","last_synced_at":"2025-07-17T03:04:09.766Z","repository":{"id":56890920,"uuid":"151526256","full_name":"yegor256/random-port","owner":"yegor256","description":"A Ruby gem to reserve a random TCP port, with a guarantee that it's not busy at the moment","archived":false,"fork":false,"pushed_at":"2025-06-24T08:32:54.000Z","size":233,"stargazers_count":16,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-24T09:42:15.402Z","etag":null,"topics":["pool","random-generation","ruby","ruby-gem","rubygems","tcp"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/random-port","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/yegor256.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-04T06:09:25.000Z","updated_at":"2025-06-24T08:32:57.000Z","dependencies_parsed_at":"2024-04-28T07:22:43.538Z","dependency_job_id":"9ccfe19b-a05b-4005-ae7a-30f74cce72bb","html_url":"https://github.com/yegor256/random-port","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"b9deeee6656fcd50e48cc25983d830253d32b9c2"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/yegor256/random-port","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Frandom-port","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Frandom-port/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Frandom-port/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Frandom-port/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/random-port/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Frandom-port/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265561848,"owners_count":23788419,"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":["pool","random-generation","ruby","ruby-gem","rubygems","tcp"],"created_at":"2024-10-30T08:08:08.954Z","updated_at":"2025-07-17T03:04:09.762Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","readme":"# Random TCP Port Generator for Ruby\n\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/random-port)](https://www.rultor.com/p/yegor256/random-port)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/random-port/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/random-port/actions/workflows/rake.yml)\n[![Gem Version](https://badge.fury.io/rb/random-port.svg)](https://badge.fury.io/rb/random-port)\n[![Maintainability](https://api.codeclimate.com/v1/badges/349b8c31884d3b34d926/maintainability)](https://codeclimate.com/github/yegor256/random-port/maintainability)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/random-port/master/frames)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/random-port/blob/master/LICENSE.txt)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/random-port.svg)](https://codecov.io/github/yegor256/random-port?branch=master)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/random-port)](https://hitsofcode.com/view/github/random-port/mailanes)\n\nIt's a simple Ruby gem to get a random TCP port.\n\nFirst, install it:\n\n```bash\ngem install random-port\n```\n\nThen, use it like this, to reserve a random TCP port:\n\n```ruby\nrequire 'random-port'\nport = RandomPort::Pool.new.acquire\n```\n\nThe `Pool` guarantees that the port won't be used again. You can put\nthe port back to the pool after usage:\n\n```ruby\nRandomPort::Pool.new.acquire do |port|\n  # Use the TCP port. It will be returned back\n  # to the pool afterwards.\nend\n```\n\nYou can do it without the block:\n\n```ruby\npool = RandomPort::Pool.new\nport = pool.acquire\npool.release(port)\n```\n\nYou can also use a pre-defined `Pool::SINGLETON` singleton:\n\n```ruby\nRandomPort::Pool::SINGLETON.acquire do |port|\n  # Use it here...\nend\n```\n\nThe pool is thread-safe by default.\nYou can configure it to be\nnot-thread-safe, using optional `sync` argument of the constructor.\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 2.3+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Frandom-port","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Frandom-port","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Frandom-port/lists"}