Permalink
Browse files

Net-Whois-RIPE-2.00010

  • Loading branch information...
1 parent c2c479b commit ae63e01db8fd4efcb0ec8c6ab9bea6c34072430b @arhuman committed Apr 27, 2012
Showing with 7,112 additions and 11 deletions.
  1. +22 −2 Changes
  2. +47 −4 MANIFEST
  3. +1 −1 META.yml
  4. +204 −0 lib/Net/Whois/Object.pm
  5. +202 −0 lib/Net/Whois/Object/AsBlock.pm
  6. +203 −0 lib/Net/Whois/Object/AsSet.pm
  7. +357 −0 lib/Net/Whois/Object/AutNum.pm
  8. +260 −0 lib/Net/Whois/Object/Domain.pm
  9. +188 −0 lib/Net/Whois/Object/FilterSet.pm
  10. +277 −0 lib/Net/Whois/Object/Inet6Num.pm
  11. +286 −0 lib/Net/Whois/Object/InetNum.pm
  12. +290 −0 lib/Net/Whois/Object/InetRtr.pm
  13. +56 −0 lib/Net/Whois/Object/Information.pm
  14. +184 −0 lib/Net/Whois/Object/KeyCert.pm
  15. +185 −0 lib/Net/Whois/Object/Limerick.pm
  16. +280 −0 lib/Net/Whois/Object/Mntner.pm
  17. +308 −0 lib/Net/Whois/Object/Organisation.pm
  18. +222 −0 lib/Net/Whois/Object/PeeringSet.pm
  19. +201 −0 lib/Net/Whois/Object/Person.pm
  20. +201 −0 lib/Net/Whois/Object/Poem.pm
  21. +54 −0 lib/Net/Whois/Object/Response.pm
  22. +250 −0 lib/Net/Whois/Object/Role.pm
  23. +343 −0 lib/Net/Whois/Object/Route.pm
  24. +238 −0 lib/Net/Whois/Object/RouteSet.pm
  25. +231 −0 lib/Net/Whois/Object/RtrSet.pm
  26. +5 −4 lib/Net/Whois/RIPE.pm
  27. +108 −0 t/03-objects.t
  28. +96 −0 t/105-AsBlock.t
  29. +82 −0 t/110-AutNum.t
  30. +87 −0 t/115-Person.t
  31. +89 −0 t/120-Role.t
  32. +113 −0 t/125-AsSet.t
  33. +108 −0 t/130-Domain.t
  34. +111 −0 t/135-InetNum.t
  35. +107 −0 t/140-Inet6Num.t
  36. +106 −0 t/145-InetRtr.t
  37. +102 −0 t/150-RtrSet.t
  38. +105 −0 t/155-Mntner.t
  39. +115 −0 t/160-KeyCert.t
  40. +135 −0 t/165-Route.t
  41. +101 −0 t/170-RouteSet.t
  42. +95 −0 t/175-PeeringSet.t
  43. +89 −0 t/180-Limerick.t
  44. +82 −0 t/185-Poem.t
  45. +112 −0 t/190-Organisation.t
  46. +36 −0 t/195-Response.t
  47. +38 −0 t/200-Information.t
View
24 Changes
@@ -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
View
@@ -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)
View
@@ -22,4 +22,4 @@ requires:
Iterator::Util: 0
Test::More: 0
perl: 5.006
-version: 2.00009
+version: 2.00_010
View
@@ -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.

0 comments on commit ae63e01

Please sign in to comment.