Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

cidr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cidr

bundlerRubyGems.org
Version
0.0.1
Version published
Maintainers
1
Created
Source

Cidr

CIDR aggregator for IPv4 addresses

Installation

Add this line to your application's Gemfile:

gem 'cidr', :git => "https://github.com/izawa/cidr.git"

And then execute:

$ bundle install

Or install it yourself as:

$ gem install cidr

Usage

require 'cidr'

aggregator = Cidr::Aggregator.new

aggregator.add('192.168.0.1')
aggregator.add('192.168.0.2')
aggregator.add('192.168.0.3')
aggregator.add('192.168.0.4')
aggregator.add('192.168.0.5')
aggregator.add('192.168.0.6')
aggregator.add('192.168.0.7')

aggregator.list
  #=> [{:addr=>"192.168.0.1", :prefix=>32},
       {:addr=>"192.168.0.2", :prefix=>31},
       {:addr=>"192.168.0.4", :prefix=>30}]

aggregator.add will be able to recognize the input string in the following format.

  • 192.168.0.1 (without prefix)
  • 192.168.0.0/24 (with prefix)

'xxx.xxx.xxx.xxx' and 'xxx.xxx.xxx.xxx/32' are assumed to be identical.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 17 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts