hosts.cr

hosts for Crystal

hosts.cr Build Status

hosts for Crystal.

  • crystal: 0.20.4

Installation

Add this to your application's shard.yml:

dependencies:
  hosts:
    github: maiha/hosts.cr
    version: 0.2.0

API

Hosts.new
Hosts#[](key)    : Hosts::Host
Hosts#[]?(key)   : Hosts::Host?
Hosts#addr?(key) : String?
Hosts#name?(key) : String?

Usage

require "hosts"

hosts = Hosts.new
hosts["192.168.0.1"]       # => Hosts::Host
hosts["192.168.0.1"].names # => Set{"host1", "ubuntu"}
hosts["192.168.1.1"]?      # => nil

hosts["host1"]             # => Hosts::Host
hosts["host1"].addr        # => "192.168.0.1"
hosts["host_xxx"]?         # => nil

hosts.name?("192.168.0.1") # => "host1"
hosts.name?("192.168.1.1") # => nil

hosts.addr?("host1")       # => "192.168.0.1"
hosts.addr?("host_xxx")    # => nil

Contributing

  1. Fork it ( https://github.com/maiha/hosts.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer
Repository

hosts.cr

Owner
Statistic
  • 1
  • 0
  • 0
  • 0
  • 0
  • over 7 years ago
  • January 8, 2017
License

MIT License

Links
Synced at

Sat, 04 May 2024 09:24:22 GMT

Languages