rpatricia.git  about / heads / tags
see http://www.goto.info.waseda.ac.jp/~tatsuya/rpatricia/
$ git log --pretty=format:'%h %s (%cs)%d'
0d6d0a5 rpatricia 1.0.1 (2014-01-28)
	(HEAD -> master, tag: v1.0.1)
45984ec rpatricia.gemspec: add missing files (2014-01-28)
820d316 rpatricia license to LGPLv2.1+ (2014-01-28)
019289c gemspec: update path for credits.txt (2014-01-25)
92cebfe Update libpatricia license (2014-01-25)
9c11ae6 patricia.c: include limits.h for CHAR_BIT macro (2013-02-26)
d2b6e41 rpatricia 1.0 (2012-10-04)
	(tag: v1.0)
7924ac4 README: documentation for Patricia#nodes method (2012-10-04)
523c6a4 Added a method 'nodes' to return all nodes in ruby's Hash. (2012-10-04)
a5be0f7 rpatricia 0.09 (2012-07-31)
	(tag: v0.09)
...

$ git cat-file blob HEAD:README
README for Ruby wrapper of Net::Patricia
---------------------------------------

rPatricia - A ruby wrapper of Net::Patricia

DESCRIPTION
-----------

  This is a ruby wrapper of Net::Patricia, which has been developed by 
  Dave Plonka. The original Net::Patricia and its C API are available
  from:
  http://net.doit.wisc.edu/~plonka/Net-Patricia/

  Net::Patricia is a module for fast IP address/prefix lookups.
  I have modified some interfaces for the Ruby wrapper version. 

NO WARANTY
----------    
    THE PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
    WITHOUT ANY WARRANTY. IT IS PROVIDED "AS IS" WITHOUT WARRANTY OF
    ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED
    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
    PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
    PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
    DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR
    OR CORRECTION. 

INSTALLATION
------------

   This package extracts, builds, installs in the usual fashion, i.e.:

      $ tar xvfz rpatricia.tar.gz
      $ cd rpatricia
      $ ruby extconf.rb
      $ make
      $ ruby test.rb
      # make install

SYNOPSIS
--------

  require 'rpatricia'
  pt = Patricia.new
  pt.add("192.168.1.0/24")
  pt.add("127.0.0.0/8", "user_data")
  node = pt.search_best("127.0.0.1")
  puts node.data
  puts node.prefix
  puts node.network
  puts node.prefixlen
  pt.remove("127.0.0.0/8")
  puts pt.num_nodes
  pt.show_nodes
  pt.clear

METHODS
-------
new:

      pt = Patricia.new

    This is the class' constructor - it returns a Patricia object for
    handling IPv4 addresses.  To handle IPv6 addresses (only),
    Patricia.new may be called with an additional argument:

      pt = Patricia.new(:AF_INET6)

    The Patricia object will be destroyed automatically when there are
    no longer any references to it.

add:
      pt.add(key_string[,user_data])

    The first argument, key_string, is a network or subnet
    specification in canonical form, e.g. ``10.0.0.0/8'', where the
    number after the slash represents the number of bits in the
    netmask. If no mask width is specified, the longest possible mask
    is assumed, i.e. 32 bits for AF_INET addresses and 128 bits for
    AF_INET6 addresses.

    The second argument, user_data, is optional. If supplied, it
    should be a STRING object specifying the user data that will be 
    stored in the Patricia Trie node. Subsequently, this value will
    be returned by the match methods described below to indicate a 
    successful search. 

    If no second argument is passed, the key_string will be stored as
    the user data and therfore will likewise be returned by the match
    functions.

    On success, this method returns the object of the Patricia Trie 
    node.

family:

    Returns either :AF_INET or :AF_INET6 symbol depending on how the
    object was initialized.  A Patricia object may only handle IPv4 or
    IPv6 addresses.

add_node:    An alias of add.

search_best:

      pt.search_best(key_string);

    This method searches the Patricia Trie to find a matching node,
    according to normal subnetting rules for the address and mask
    specified.

    The key_string argument is a network or subnet specification in
    canonical form, e.g. ``10.0.0.0/8'', where the number after the
    slash represents the number of bits in the netmask. If no mask
    width value is specified, the longest mask is assumed, i.e. 32
    bits for AF_INET addresses and 128 bits for AF_INET6 addresses.

    If a matching node is found in the Patricia Trie, this method
    returns the object of the node. This method returns nil on
    failure.

match_best:    An alias of search_best.

search_exact:

      pt.search_exact(key_string);

    This method searches the Patricia Trie to find a matching
    node. Its semantics are exactly the same as those described for
    search_best except that the key must match a node exactly. I.e.,
    it is not sufficient that the address and mask specified merely
    falls within the subnet specified by a particular node.

match_exact:	An alias of search_exact.

include?:

      pt.include?(key_string);

    This method behaves like match_best, but returns true on success
    and false on failure.  This method is more efficient than match_best
    as it does not allocate a new object.

remove:

      pt.remove(key_string);

    This method removes the node which exactly matches the the address
    and mask specified from the Patricia Trie.

    If the matching node is found in the Patricia Trie, it is removed,
    and this method returns the true. This method returns false on
    failure. 

remove_node:	 An alias of remove

num_nodes:
       
       pt.num_nodes

     This method returns the number of nodes in the Patricia Trie.

show_nodes:

       pt.print_nodes

     This method prints all the nodes in the Patricia Trie.

nodes:

       pt.nodes

     This method returns all the nodes and values in the Patricia Trie
     as a Ruby Hash object.

data:

       node.data
   
     This method returns the user data of the Patricia Trie node.

network:

       node.network
   
     This method returns the network of the Patricia Trie node.

prefix:

       node.prefix
   
     This method returns the prefix of the Patricia Trie node.

prefixlen:

       node.prefixlen
   
     This method returns the prefix length of the Patricia Trie 
     node.

AUTHORS
-------
Tatsuya Mori <mori.tatsuya@gmail.com>
Eric Wong <normalperson@yhbt.net>

# heads (aka `branches'):
$ git for-each-ref --sort=-creatordate refs/heads \
	--format='%(HEAD) %(refname:short) %(subject) (%(creatordate:short))'
* master       rpatricia 1.0.1 (2014-01-28)
  0.09-proposed rpatricia 0.09pre1 (2012-07-18)
  for-tatsuya  patricia: fix bounds error in ascii2prefix (2012-07-13)
  ipv6         rpatricia: add missing prototypes for functions (2011-06-16)
  reorg        move extension code into ext/ (2010-03-12)

# tags:
$ git for-each-ref --sort=-creatordate refs/tags \
	--format='%(refname:short) %(subject) (%(creatordate:short))'
v1.0.1       rpatricia 1.0.1 (2014-01-28) tar.gz
v1.0         rpatricia 1.0 (2012-10-04) tar.gz
v0.09        rpatricia 0.09 (2012-07-31) tar.gz
v0.08        rpatricia 0.08 - IPv6 support (2011-08-12) tar.gz
v0.07        rpatricia 0.07 (2010-09-23) tar.gz
v0.06        rpatricia 0.06 (2010-09-14) tar.gz
v0.05        rpatricia 0.05 gem (2010-03-14) tar.gz
v0.04        rpatrica 0.04 (2010-03-12) tar.gz

git clone https://yhbt.net/rpatricia.git