{"id":19728898,"url":"https://github.com/altmetric/ip_ranger","last_synced_at":"2025-04-30T01:31:32.707Z","repository":{"id":56877969,"uuid":"64237792","full_name":"altmetric/ip_ranger","owner":"altmetric","description":"A gem for converting an IP range to CIDR subnets","archived":false,"fork":false,"pushed_at":"2024-10-21T08:05:14.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-21T11:04:22.191Z","etag":null,"topics":["cidr","cidr-notation","iprange"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/ip_ranger","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/altmetric.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2016-07-26T16:39:30.000Z","updated_at":"2024-10-21T08:05:14.000Z","dependencies_parsed_at":"2024-10-22T09:30:00.792Z","dependency_job_id":null,"html_url":"https://github.com/altmetric/ip_ranger","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.3846153846153846,"last_synced_commit":"e1e4080070cf699cd0b80c5c8d6d5dddfc19d4b8"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Fip_ranger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Fip_ranger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Fip_ranger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altmetric%2Fip_ranger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altmetric","download_url":"https://codeload.github.com/altmetric/ip_ranger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224193122,"owners_count":17271238,"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":["cidr","cidr-notation","iprange"],"created_at":"2024-11-12T00:08:32.384Z","updated_at":"2024-11-12T00:08:33.100Z","avatar_url":"https://github.com/altmetric.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IP Ranger\n\nA gem for converting an arbitrary IP range to the minimal CIDR notation required to describe it exactly.\n\n**Current version:** 0.0.2  \n**Supported Ruby versions:** 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2, 2.3\n\n## Installation\n\n```\ngem install ip_ranger -v '~\u003e 0.0.2'\n```\n\nOr, in your `Gemfile`:\n\n```ruby\ngem 'ip_ranger', '~\u003e 0.0.2'\n```\n\n## Usage\n\n```ruby\nrequire 'ip_ranger'\n\nip_range = IPRanger::IPRange.new('192.168.1.5', '192.168.1.42')\nip_range.cidrs\n# =\u003e [#\u003cIPAddr: IPv4:192.168.1.5/255.255.255.255\u003e,\n#  #\u003cIPAddr: IPv4:192.168.1.6/255.255.255.254\u003e,\n#  #\u003cIPAddr: IPv4:192.168.1.8/255.255.255.248\u003e,\n#  #\u003cIPAddr: IPv4:192.168.1.16/255.255.255.240\u003e,\n#  #\u003cIPAddr: IPv4:192.168.1.32/255.255.255.248\u003e,\n#  #\u003cIPAddr: IPv4:192.168.1.40/255.255.255.254\u003e,\n#  #\u003cIPAddr: IPv4:192.168.1.42/255.255.255.255\u003e]\n```\n\n## API Documentation\n\n### `IPRanger::IPRange.new(start, finish)`\n\n```ruby\nip_range = IPRanger::IPRange.new('192.168.1.1', '192.168.1.32')\nip_range = IPRanger::IPRange.new(IPAddr.new('10.0.0.1'), IPAddr.new('10.0.0.100'))\n```\n\nReturn a new `IPRanger::IPRange` instance representing a range between the given `start` and `finish` IP addresses. Addresses can be given as either strings or [`IPAddr`](http://ruby-doc.org/stdlib/libdoc/ipaddr/rdoc/IPAddr.html) instances.\n\n### `IPRanger::IPRange#cidrs`\n\n```ruby\nip_range = IPRanger::IPRange.new('192.168.1.0', '192.168.1.255')\nip_range.cidrs\n#=\u003e [#\u003cIPAddr: IPv4:192.168.1.0/255.255.255.0\u003e]\n\nip_range = IPRanger::IPRange.new('192.168.1.0', '192.168.8.255')\nip_range.cidrs\n#=\u003e [#\u003cIPAddr: IPv4:192.168.1.0/255.255.255.0\u003e,\n#    #\u003cIPAddr: IPv4:192.168.2.0/255.255.254.0\u003e,\n#    #\u003cIPAddr: IPv4:192.168.4.0/255.255.252.0\u003e,\n#    #\u003cIPAddr: IPv4:192.168.8.0/255.255.255.0\u003e]\n```\n\nReturn an array with a minimal number of `IPRanger::IPAddress` objects (wrappers for instances of `IPAddr`), each representing a mask that together cover the entire IP range.\n\n### `IPRanger::IPAddress.new(ip_addr)`\n\n```ruby\nip_address = IPRanger::IPAddress.new(IPAddr.new('192.168.1.1'))\n```\n\nA wrapper for instances of Ruby's `IPAddr`that can be used interchangeably with `IPAddr` but with some additional methods for working with CIDR notation.\n\nTypically, you should not need to instantiate these yourself but they will be returned by methods on `IPRanger::IPRanger` and `IPRanger::IPAddress` itself.\n\n### `IPRanger::IPAddress#width`\n\n```ruby\nip_address = IPRanger::IPAddress.new(IPAddr.new('192.168.1.0'))\nip_address.width #=\u003e 32\n\nip_address = IPRanger::IPAddress.new(IPAddr.new('::1'))\nip_address.width #=\u003e 128\n```\n\nReturn the width in bits of the IP address: either 32 for an IPv4 or 128 for an IPv6.\n\n### `IPRanger::IPAddress#succ`\n\n```ruby\nip_address = IPRanger::IPAddress.new(IPAddr.new('192.168.1.0'))\nip_address.succ #=\u003e #\u003cIPAddr: IPv4:192.168.1.1/255.255.255.0\u003e\n```\n\nReturn the successor to this IP address as an `IPRanger::IPAddress` (e.g. `192.168.0.2` succeeds `192.168.0.1`).\n\n### `IPRanger::IPAddress#pred`\n\n```ruby\nip_address = IPRanger::IPAddress.new(IPAddr.new('192.168.1.0'))\nip_address.pred #=\u003e #\u003cIPAddr: IPv4:192.168.0.255/255.255.255.255\u003e\n```\n\nReturn the predecessor to this IP address as an `IPRanger::IPAddress` (e.g. `192.168.0.1` preceeds `192.168.0.2`).\n\n### `IPRanger::IPAddress#prefixlen`\n\n```ruby\nip_address = IPRanger::IPAddress.new(IPAddr.new('192.168.1.0/24'))\nip_address.prefixlen #=\u003e 24\n```\n\nReturn the length in bits of the IP address's prefix.\n\n### `IPRanger::IPAddress#to_cidr`\n\n```ruby\nip_address = IPRanger::IPAddress.new(IPAddr.new('192.168.1.0'))\nip_address.to_cidr #=\u003e \"192.168.1.0/32\"\n```\n\nReturn the string CIDR notation for this IP address.\n\n## Acknowledgements\n\n* This began as a Ruby port of the Python [netaddr](https://pypi.python.org/pypi/netaddr) library's `iprange_to_cidrs` feature.\n\n## License\n\nCopyright © 2016-2024 Altmetric LLP\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltmetric%2Fip_ranger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltmetric%2Fip_ranger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltmetric%2Fip_ranger/lists"}