r36350 - in /branches/upstream/libnet-twitter-diff-perl: ./ current/ current/lib/ current/lib/Net/ current/lib/Net/Twitter/ current/t/
efaistos-guest at users.alioth.debian.org
efaistos-guest at users.alioth.debian.org
Mon May 25 01:14:34 UTC 2009
Author: efaistos-guest
Date: Mon May 25 01:14:30 2009
New Revision: 36350
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36350
Log:
[svn-inject] Installing original source of libnet-twitter-diff-perl
Added:
branches/upstream/libnet-twitter-diff-perl/
branches/upstream/libnet-twitter-diff-perl/current/
branches/upstream/libnet-twitter-diff-perl/current/Changes
branches/upstream/libnet-twitter-diff-perl/current/MANIFEST
branches/upstream/libnet-twitter-diff-perl/current/META.yml
branches/upstream/libnet-twitter-diff-perl/current/Makefile.PL
branches/upstream/libnet-twitter-diff-perl/current/README
branches/upstream/libnet-twitter-diff-perl/current/lib/
branches/upstream/libnet-twitter-diff-perl/current/lib/Net/
branches/upstream/libnet-twitter-diff-perl/current/lib/Net/Twitter/
branches/upstream/libnet-twitter-diff-perl/current/lib/Net/Twitter/Diff.pm
branches/upstream/libnet-twitter-diff-perl/current/t/
branches/upstream/libnet-twitter-diff-perl/current/t/00-load.t
branches/upstream/libnet-twitter-diff-perl/current/t/boilerplate.t
branches/upstream/libnet-twitter-diff-perl/current/t/pod-coverage.t
branches/upstream/libnet-twitter-diff-perl/current/t/pod.t
Added: branches/upstream/libnet-twitter-diff-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/Changes?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/Changes (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/Changes Mon May 25 01:14:30 2009
@@ -1,0 +1,15 @@
+Revision history for Net-Twitter-Diff
+
+0.04 2007-11-15/16:25
+ - Fix POD
+
+0.03 2007-11-14/11:04
+ - Relase on CPAN
+
+0.02 2007-11-14/00:05
+ - Change Interface.
+ - Support comp_following ,xfollowing , xfollowers
+
+0.01 2007-11-08/21:27
+ First version, released on an unsuspecting world.
+
Added: branches/upstream/libnet-twitter-diff-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/MANIFEST?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/MANIFEST (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/MANIFEST Mon May 25 01:14:30 2009
@@ -1,0 +1,10 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/Net/Twitter/Diff.pm
+t/00-load.t
+t/boilerplate.t
+t/pod-coverage.t
+t/pod.t
Added: branches/upstream/libnet-twitter-diff-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/META.yml?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/META.yml (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/META.yml Mon May 25 01:14:30 2009
@@ -1,0 +1,13 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Net-Twitter-Diff
+version: 0.04
+version_from: lib/Net/Twitter/Diff.pm
+installdirs: site
+requires:
+ Array::Diff: 0
+ Net::Twitter: 0
+ Test::More: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30
Added: branches/upstream/libnet-twitter-diff-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/Makefile.PL?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/Makefile.PL (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/Makefile.PL Mon May 25 01:14:30 2009
@@ -1,0 +1,18 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'Net::Twitter::Diff',
+ AUTHOR => 'Tomohiro Teranishi <tomohiro.terranishi at gmail.com>',
+ VERSION_FROM => 'lib/Net/Twitter/Diff.pm',
+ ABSTRACT_FROM => 'lib/Net/Twitter/Diff.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'Net::Twitter' => 0,
+ 'Array::Diff' => 0,
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'Net-Twitter-Diff-*' },
+);
Added: branches/upstream/libnet-twitter-diff-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/README?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/README (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/README Mon May 25 01:14:30 2009
@@ -1,0 +1,12 @@
+Net-Twitter-Diff
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+
Added: branches/upstream/libnet-twitter-diff-perl/current/lib/Net/Twitter/Diff.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/lib/Net/Twitter/Diff.pm?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/lib/Net/Twitter/Diff.pm (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/lib/Net/Twitter/Diff.pm Mon May 25 01:14:30 2009
@@ -1,0 +1,247 @@
+package Net::Twitter::Diff;
+
+use warnings;
+use strict;
+use base qw/Net::Twitter/;
+use Array::Diff;
+
+our $VERSION = '0.04';
+
+sub xfollowing {
+ my $self = shift;
+ my $id = shift;
+
+ my $url = $self->{apiurl} . "/statuses/friends" ;
+ $url .= (defined $id) ? "/$id.json" : ".json";
+ $url .= '?page=';
+
+ my $page = 1;
+ my @data = ();
+ while(1){
+ my $page_url = $url . $page ;
+ my $req = $self->{ua}->get($page_url);
+
+ die 'fail to connect to twitter. maybe over Rate limit exceeded or auth error' unless $req->is_success;
+ return [] if $req->content eq 'null';
+
+ my $res = JSON::Any->jsonToObj($req->content) ;
+
+ last unless scalar @{ $res } ;
+ push @data , @{ $res } ;
+
+
+ $page++;
+ }
+
+ return \@data;
+}
+
+sub xfollowers {
+ my $self = shift;
+
+ my $page = 1;
+ my @data = ();
+ while(1){
+ my $url = $self->{apiurl} . "/statuses/followers.json?page=$page" ;
+ my $req = $self->{ua}->get($url);
+
+ die 'fail to connect to twitter. maybe over Rate limit exceeded or auth error' unless $req->is_success;
+ return [] if $req->content eq 'null';
+
+ my $res = JSON::Any->jsonToObj($req->content) ;
+
+ last unless scalar @{ $res } ;
+ push @data , @{ $res } ;
+
+
+ $page++;
+ }
+
+ return \@data;
+}
+
+sub diff {
+ my $self = shift;
+ my $args = shift;
+
+ my $res = {};
+ my $followings_hash = $self->xfollowing();
+ my $followers_hash = $self->xfollowers();
+ my $followers = [];
+ my $followings = [];
+
+ for my $item ( @{ $followings_hash } ) {
+ push @{ $followings } , $item->{screen_name};
+ }
+
+ for my $item ( @{ $followers_hash } ) {
+ push @{ $followers } , $item->{screen_name};
+ }
+
+ my $diff = Array::Diff->diff( $followers , $followings );
+
+ $res->{not_following} = $diff->deleted;
+ $res->{not_followed} = $diff->added;
+ my @communicated = ();
+ my $not_followed_ref = {};
+ for my $user ( @{ $res->{not_followed} } ) {
+ $not_followed_ref->{ $user } = 1;
+ }
+
+ for my $screen_name ( @{ $followings } ) {
+ if ( !defined $not_followed_ref->{ $screen_name } ) {
+ push @communicated , $screen_name
+ }
+ }
+
+ $res->{communicated} = \@communicated;
+
+ return $res;
+}
+
+
+sub comp_following {
+ my $self = shift;
+ my $id = shift;
+
+ my $res = {};
+ my $me_ref = $self->xfollowing();
+ my $him_ref = $self->xfollowing( $id );
+
+
+ my $me = [];
+ my $him = [];
+ my $me_hash = {};
+ for my $item ( @{ $me_ref } ) {
+ push @{ $me } , $item->{screen_name};
+ $me_hash->{ $item->{screen_name} } = 1;
+ }
+
+ for my $item ( @{ $him_ref } ) {
+ push @{ $him } , $item->{screen_name};
+ }
+
+ my $diff = Array::Diff->diff( $me , $him );
+
+ $res->{only_me} = $diff->deleted;
+ $res->{not_me} = $diff->added;
+ my @communicated = ();
+
+ for my $screen_name ( @{ $him } ) {
+ if ( defined $me_hash->{ $screen_name } ) {
+ push @communicated , $screen_name
+ }
+ }
+
+ $res->{share} = \@communicated;
+
+ return $res;
+}
+
+1;
+
+=head1 NAME
+
+Net::Twitter::Diff - Twitter Diff
+
+=head1 SYNOPSYS
+
+ use Net::Twitter::Diff;
+
+ my $diff = Net::Twitter::Diff->new( username => '******' , password => '******');
+
+ my $res = $diff->diff();
+
+ # get screen_names who you are not following but they are.
+ print Dumper $res->{not_following};
+
+ # get screen_names who they are not following but you are.
+ print Dumper $res->{not_followed};
+
+ # get screen_names who you are following them and also they follow you.
+ print Dumper $res->{communicated};
+
+
+ my $res2 = $diff->comp_following( 'somebody_twitter_name' );
+
+ # only you are following
+ print Dumper $res2->{only_me} ;
+
+ # you are not following but somebody_twitter_name are following
+ print Dumper $res2->{not_me} ;
+
+ # both you and somebody_twitter_name are following
+ print Dumper $res2->{share} ;
+
+
+ # If you want , this module use Net::Twitter as base so you can use methods Net::Twitter has.
+ $diff->update('My current Status');
+
+=head1 DESCRIPTION
+
+Handy when you want to know relationshop between your followers and follwoings
+and when you wnat to compare your following and somebody's.
+
+=head1 METHOD
+
+=head2 diff
+
+run diff
+
+response hash
+
+=over 4
+
+=item B<not_following>
+
+get screen_names who you are not following but they are.
+
+=item B<not_followed>
+
+get screen_names who they are not following but you are.
+
+=item B<communicated>
+
+get screen_names who you are following them and also they follow you.
+
+=back
+
+=head2 comp_following( $twitter_id )
+
+compaire your following and somebody's
+
+response hash
+
+=over 4
+
+=item B<only_me>
+
+only you are following
+
+=item B<not_me>
+
+you are not following but somebody is following
+
+=item B<share>
+
+both you and somebody are following.
+
+=back
+
+=head2 xfollowing
+
+can get more that 100 followings.
+
+=head2 xfollowers
+
+can get more that 100 followers.
+
+=head1 SEE ALSO
+
+L<Net::Twitter>
+
+=head1 AUTHOR
+
+Tomohiro Teranishi<tomohiro.teranishi at gmail.com>
+
+=cut
Added: branches/upstream/libnet-twitter-diff-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/t/00-load.t?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/t/00-load.t (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/t/00-load.t Mon May 25 01:14:30 2009
@@ -1,0 +1,9 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'Net::Twitter::Diff' );
+}
+
+diag( "Testing Net::Twitter::Diff $Net::Twitter::Diff::VERSION, Perl $], $^X" );
Added: branches/upstream/libnet-twitter-diff-perl/current/t/boilerplate.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/t/boilerplate.t?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/t/boilerplate.t (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/t/boilerplate.t Mon May 25 01:14:30 2009
@@ -1,0 +1,48 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+sub not_in_file_ok {
+ my ($filename, %regex) = @_;
+ open my $fh, "<", $filename
+ or die "couldn't open $filename for reading: $!";
+
+ my %violated;
+
+ while (my $line = <$fh>) {
+ while (my ($desc, $regex) = each %regex) {
+ if ($line =~ $regex) {
+ push @{$violated{$desc}||=[]}, $.;
+ }
+ }
+ }
+
+ if (%violated) {
+ fail("$filename contains boilerplate text");
+ diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+ } else {
+ pass("$filename contains no boilerplate text");
+ }
+}
+
+not_in_file_ok(README =>
+ "The README is used..." => qr/The README is used/,
+ "'version information here'" => qr/to provide version information/,
+);
+
+not_in_file_ok(Changes =>
+ "placeholder date/time" => qr(Date/time)
+);
+
+sub module_boilerplate_ok {
+ my ($module) = @_;
+ not_in_file_ok($module =>
+ 'the great new $MODULENAME' => qr/ - The great new /,
+ 'boilerplate description' => qr/Quick summary of what the module/,
+ 'stub function definition' => qr/function[12]/,
+ );
+}
+
+module_boilerplate_ok('lib/Net/Twitter/Diff.pm');
Added: branches/upstream/libnet-twitter-diff-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/t/pod-coverage.t?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/t/pod-coverage.t Mon May 25 01:14:30 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: branches/upstream/libnet-twitter-diff-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libnet-twitter-diff-perl/current/t/pod.t?rev=36350&op=file
==============================================================================
--- branches/upstream/libnet-twitter-diff-perl/current/t/pod.t (added)
+++ branches/upstream/libnet-twitter-diff-perl/current/t/pod.t Mon May 25 01:14:30 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Pkg-perl-cvs-commits
mailing list