Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
7,112 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
Revision history for net-whois-ripe | ||
|
||
0.01 Fri, 22 Jan 2010 23:33:55 +0100 | ||
Initial release | ||
2.00010 20 Apr 2012 | ||
Net::Whois::Object addition (By Arnaud "Arhuman" Assad) | ||
|
||
2.00009 23 Nov 2011 | ||
|
||
2.00008 26 Oct 2011 | ||
|
||
2.00003 13 Feb 2011 | ||
|
||
2.00002 28 Jan 2010 | ||
|
||
1.31 23 Aug 2009 | ||
|
||
1.30 10 Jul 2009 | ||
|
||
1.23 17 Apr 2006 | ||
|
||
1.22 09 May 2005 | ||
|
||
1.20 07 Nov 2004 | ||
|
||
1.19 23 Jul 2002 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
Changes | ||
MANIFEST | ||
lib/Net/Whois/Object.pm | ||
lib/Net/Whois/Object/AsBlock.pm | ||
lib/Net/Whois/Object/AsSet.pm | ||
lib/Net/Whois/Object/AutNum.pm | ||
lib/Net/Whois/Object/Domain.pm | ||
lib/Net/Whois/Object/FilterSet.pm | ||
lib/Net/Whois/Object/Inet6Num.pm | ||
lib/Net/Whois/Object/InetNum.pm | ||
lib/Net/Whois/Object/InetRtr.pm | ||
lib/Net/Whois/Object/Information.pm | ||
lib/Net/Whois/Object/KeyCert.pm | ||
lib/Net/Whois/Object/Limerick.pm | ||
lib/Net/Whois/Object/Mntner.pm | ||
lib/Net/Whois/Object/Organisation.pm | ||
lib/Net/Whois/Object/PeeringSet.pm | ||
lib/Net/Whois/Object/Person.pm | ||
lib/Net/Whois/Object/Poem.pm | ||
lib/Net/Whois/Object/Response.pm | ||
lib/Net/Whois/Object/Role.pm | ||
lib/Net/Whois/Object/Route.pm | ||
lib/Net/Whois/Object/RouteSet.pm | ||
lib/Net/Whois/Object/RtrSet.pm | ||
lib/Net/Whois/RIPE.pm | ||
Makefile.PL | ||
MANIFEST | ||
META.json Module JSON meta-data (added by MakeMaker) | ||
META.yml Module meta-data (added by MakeMaker) | ||
README | ||
lib/Net/Whois/RIPE.pm | ||
t/00-load.t | ||
t/01-instantiation.t | ||
t/02-methods.t | ||
t/03-objects.t | ||
t/105-AsBlock.t | ||
t/110-AutNum.t | ||
t/115-Person.t | ||
t/120-Role.t | ||
t/125-AsSet.t | ||
t/130-Domain.t | ||
t/135-InetNum.t | ||
t/140-Inet6Num.t | ||
t/145-InetRtr.t | ||
t/150-RtrSet.t | ||
t/155-Mntner.t | ||
t/160-KeyCert.t | ||
t/165-Route.t | ||
t/170-RouteSet.t | ||
t/175-PeeringSet.t | ||
t/180-Limerick.t | ||
t/185-Poem.t | ||
t/190-Organisation.t | ||
t/195-Response.t | ||
t/200-Information.t | ||
t/boilerplate.t | ||
t/pod-coverage.t | ||
t/pod.t | ||
META.yml Module meta-data (added by MakeMaker) | ||
META.json Module JSON meta-data (added by MakeMaker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ requires: | |
Iterator::Util: 0 | ||
Test::More: 0 | ||
perl: 5.006 | ||
version: 2.00009 | ||
version: 2.00_010 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
package Net::Whois::Object; | ||
|
||
=head1 NAME | ||
Net/Whois/Object - Object encapsulating RPSL data returned by Whois queries | ||
=head1 SYNOPSIS | ||
use Net::Whois::RIPE; | ||
use Net::Whois::Object; | ||
my $whois = Net::Whois::RIPE->new( %options ); | ||
$iterator = $whois->query( 'AS30781' ); | ||
while (my $value = $iterator->value()) { | ||
my @lines = split '\n', $value; | ||
push @projects, Net::Whois::Object(@lines); | ||
} | ||
for my $object (@objects) { | ||
# process the Net::Whois::Object::xxx objects... | ||
} | ||
... | ||
=head1 SUBROUTINES/METHODS | ||
=head2 B<new( @lines )> | ||
The constructor is a factory returning the appropriate Net/Whois/Object | ||
based on the first attribute of the block. | ||
=cut | ||
|
||
sub new { | ||
my $class = shift; | ||
my @lines = @_; | ||
|
||
my ( $object, $block, @results ); | ||
|
||
my ( $attribute, $value ); | ||
for my $line (@lines) { | ||
|
||
|
||
if ( $line =~ /^(\S+):\s+(.*)/ ) { | ||
|
||
# Attribute line | ||
$attribute = $1; | ||
$value = $2; | ||
|
||
} | ||
elsif ( $line =~ /^%(\S.*)/ ) { | ||
|
||
# Response line | ||
$block = 'response'; | ||
$value = $1; | ||
|
||
} | ||
elsif ( $line =~ /^%\s(.*)/ ) { | ||
|
||
$block = 'comment' unless $block; | ||
|
||
# Comment line | ||
$attribute = "comment"; | ||
$value = $1; | ||
|
||
} | ||
elsif ( $line =~ /^[^%]\s*(.+)/ ) { | ||
|
||
# Continuation line | ||
$value = $1; | ||
|
||
} | ||
elsif ( $line =~ /^$/ ) { | ||
|
||
# Blank line | ||
push @results, $object; | ||
$attribute = undef; | ||
$block = undef; | ||
$object = undef; | ||
next; | ||
|
||
} | ||
|
||
# Normalize attribute to Perl's sub name standards | ||
$attribute =~ s/-/_/g if $attribute; | ||
|
||
# First attribute determine the block | ||
$block = $attribute unless $block; | ||
|
||
$object = _object_factory( $block, $value ) unless $object; | ||
|
||
if ($attribute) { | ||
$object->$attribute($value); | ||
} | ||
|
||
} | ||
return @results; | ||
} | ||
|
||
=head2 B<filter( $filter )> | ||
Accessor to the filter attribute used to filter out objects. | ||
Accepts an optional filter to be added to the filter array, | ||
always return the current filter array. | ||
=cut | ||
|
||
sub filter { | ||
my ( $self, $filter ) = @_; | ||
push @{ $self->{filter} }, $filter if defined $filter; | ||
return @{ $self->{filter} }; | ||
} | ||
|
||
=head2 B<hidden_attributes( $attribute )> | ||
Accessor to the filtered_attributes attribute (attributes to be hidden) | ||
Accepts an optional attribute to be added to the filtered_attributes array, | ||
always return the current filtered_attributes array. | ||
=cut | ||
|
||
sub filtered_attributes { | ||
my ( $self, $filtered_attributes ) = @_; | ||
push @{ $self->{filtered_attributes} }, $filtered_attributes if defined $filtered_attributes; | ||
return @{ $self->{filtered_attributes} }; | ||
} | ||
|
||
=head2 B<displayed_attributes( $attribute )> | ||
Accessor to the displayed_attributes attribute which should be displayed. | ||
Accepts an optional attribute to be added to the displayed_attributes array, | ||
always return the current displayed_attributes array. | ||
=cut | ||
|
||
sub displayed_attributes { | ||
my ( $self, $displayed_attributes ) = @_; | ||
push @{ $self->{displayed_attributes} }, $displayed_attributes if defined $displayed_attributes; | ||
return @{ $self->{displayed_attributes} }; | ||
} | ||
|
||
=begin UNDOCUMENTED | ||
=head2 B<_object_factory( $type => $value )> | ||
Private method. Shouldn't be used from other modules. | ||
Simple factory, creating Net::Whois::Objet::XXXX from | ||
the type passed as parameter. | ||
=end UNDOCUMENTED | ||
=cut | ||
|
||
sub _object_factory { | ||
my $type = shift; | ||
my $value = shift; | ||
|
||
my %class = ( aut_num => 'AutNum', | ||
as_block => 'AsBlock', | ||
as_set => 'AsSet', | ||
comment => 'Information', | ||
person => 'Person', | ||
role => 'Role', | ||
domain => 'Domain', | ||
inetnum => 'InetNum', | ||
inet6num => 'Inet6Num', | ||
inet_rtr => 'InetRtr', | ||
rtr_set => 'RtrSet', | ||
mntner => 'Mntner', | ||
key_cert => 'KeyCert', | ||
route => 'Route', | ||
route_set => 'RouteSet', | ||
peering_set => 'PeeringSet', | ||
limerick => 'Limerick', | ||
poem => 'Poem', | ||
organisation => 'Organisation', | ||
response => 'Response' | ||
); | ||
|
||
die "Unrecognized Object ($type first attribute)" unless $class{$type}; | ||
|
||
my $class = "Net::Whois::Object::" . $class{$type}; | ||
|
||
eval "require $class"; | ||
return $class->new( $type => $value ); | ||
|
||
} | ||
|
||
=head1 AUTHOR | ||
Arnaud "Arhuman" Assad, C<< <arhuman at gmail.com> >> | ||
=head1 ACKNOWLEDGEMENTS | ||
Thanks to Jaguar Network for allowing me to work on this during some of my office | ||
hours. | ||
Thanks to Luis Motta Campos for his trust when allowing me to publish this | ||
release. | ||
=cut | ||
1; |
Oops, something went wrong.