Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moo

  • Loading branch information...
commit 3e825954a559f56188f9909336b480f8bd34ccf4 0 parents
@bingos bingos authored
0  Changes
No changes.
21 MANIFEST
@@ -0,0 +1,21 @@
+Changes
+inc/Module/Install.pm
+inc/Module/Install/AutoLicense.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/GithubMeta.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/ReadmeFromPod.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/Test/Reporter/Transport/Socket.pm
+LICENSE
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/00_compile.t
+t/99_pod.t
+t/99_pod_coverage.t
20 Makefile.PL
@@ -0,0 +1,20 @@
+use strict;
+use inc::Module::Install;
+name 'Test-Reporter-Transport-Socket';
+author 'Chris Williams <chris@bingosnet.co.uk>';
+my $from = 'lib/Test/Reporter/Transport/Socket.pm';
+version_from $from;
+abstract_from $from;
+readme_from $from;
+license 'perl';
+auto_license holder => 'Chris Williams, Richard Dawe and David A. Golden';
+perl_version '5.006';
+build_requires 'Test::More' => 0.47;
+requires 'Config::Perl::V' => '0.11';
+requires 'IO::Socket::INET' => 0;
+requires 'Storable' => 0;
+requires 'Test::Reporter' => '1.56';
+requires 'Test::Reporter::Transport' => '1.56';
+auto_provides;
+githubmeta;
+WriteAll();
82 README
@@ -0,0 +1,82 @@
+NAME
+ Test::Reporter::Transport::Socket - Simple socket transport for
+ Test::Reporter
+
+SYNOPSIS
+ my $report = Test::Reporter->new(
+ transport => 'Socket',
+ transport_args => [
+ host => 'metabase.relay.example.com',
+ port => 58008,
+ ],
+ );
+
+ # use space-separated in a CPAN::Reporter config.ini
+ transport = Socket host metabase.relay.example.com ...
+
+DESCRIPTION
+ This is a Test::Reporter::Transport that sends test report data
+ serialised over a TCP socket.
+
+ The idea is to keep dependencies in the tester perl to a bear minimum
+ and offload the bulk of submission to a Metabase instance to a relay.
+
+USAGE
+ See Test::Reporter and Test::Reporter::Transport for general usage
+ information.
+
+ Transport arguments
+ Unlike most other Transport classes, this class requires transport
+ arguments to be provided as key-value pairs:
+
+ my $report = Test::Reporter->new(
+ transport => 'Socket',
+ transport_args => [
+ host => 'metabase.relay.example.com',
+ port => 58008,
+ ],
+ );
+
+ Arguments include:
+
+ "host" (required)
+ The name or IP address of a host where we want to send our
+ serialised data.
+
+ "port"
+ The TCP port on the above "host" to send our serialised data.
+
+METHODS
+ These methods are only for internal use by Test::Reporter.
+
+ new
+ my $sender = Test::Reporter::Transport::Socket->new( %params );
+
+ The "new" method is the object constructor.
+
+ send
+ $sender->send( $report );
+
+ The "send" method transmits the report.
+
+AUTHORS
+ David A. Golden (DAGOLDEN)
+ Richard Dawe (RICHDAWE)
+ Chris Williams (BINGOS)
+
+COPYRIGHT AND LICENSE
+ Portions Copyright (c) 2009 by Richard Dawe
+ Portions Copyright (c) 2009-2010 by David A. Golden
+ Portions Copyright (c) 2010 by Chris Williams
+
+ Licensed under the same terms as Perl itself (the "License"). You may
+ not use this file except in compliance with the License. A copy of the
+ License was distributed with this file or you may obtain a copy of the
+ License from http://dev.perl.org/licenses/
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
181 lib/Test/Reporter/Transport/Socket.pm
@@ -0,0 +1,181 @@
+package Test::Reporter::Transport::Socket;
+
+use strict;
+use warnings;
+use Carp ();
+use Config::Perl::V ();
+use IO::Socket::INET;
+use Storable qw[nfreeze];
+use base qw[Test::Reporter::Transport];
+use vars qw[$VERSION];
+
+$VERSION ='0.02';
+
+my @required_args = qw/host port/;
+
+sub new {
+ my $class = shift;
+ Carp::confess __PACKAGE__ . " requires transport args in key/value pairs\n"
+ if @_ % 2;
+ my %args = @_;
+ $args{lc $_} = delete $args{$_} for keys %args;
+
+ for my $k ( @required_args ) {
+ Carp::confess __PACKAGE__ . " requires $k argument\n"
+ unless exists $args{$k};
+ }
+
+ return bless \%args => $class;
+}
+
+sub send {
+ my ($self, $report) = @_;
+
+ unless ( eval { $report->distfile } ) {
+ Carp::confess __PACKAGE__ . ": requires the 'distfile' parameter to be set\n"
+ . "Please update your CPAN testing software to a version that provides \n"
+ . "this information to Test::Reporter. Report will not be sent.\n";
+ }
+
+ # Open the socket to the given host:port
+ # confess on failure.
+
+ my $sock = IO::Socket::INET->new(
+ PeerAddr => $self->{host},
+ PeerPort => $self->{port},
+ Proto => 'tcp'
+ );
+
+ unless ( $sock ) {
+ Carp::confess __PACKAGE__ . ": could not connect to '$self->{host}' '$!'\n";
+ }
+
+ # Get facts about Perl config that Test::Reporter doesn't capture
+ # Unfortunately we can't do this from the current perl in case this
+ # is a report regenerated from a file and isn't the perl that the report
+ # was run on
+ my $perlv = $report->{_perl_version}->{_myconfig};
+ my $config = Config::Perl::V::summary(Config::Perl::V::plv2hash($perlv));
+
+ my $data = {
+ grade => $report->grade,
+ osname => $config->{osname},
+ osversion => $report->{_perl_version}{_osvers},
+ archname => $report->{_perl_version}{_archname},
+ perl_version => $config->{version},
+ textreport => $report->report
+ };
+
+ my $froze;
+ eval { $froze = nfreeze( $data ); };
+
+ Carp::confess __PACKAGE__ . ": Could not freeze data '$@'\n"
+ unless $froze;
+
+ my $foo = $sock->send( $froze );
+
+ close $sock;
+ return 1;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::Reporter::Transport::Socket - Simple socket transport for Test::Reporter
+
+=head1 SYNOPSIS
+
+ my $report = Test::Reporter->new(
+ transport => 'Socket',
+ transport_args => [
+ host => 'metabase.relay.example.com',
+ port => 58008,
+ ],
+ );
+
+ # use space-separated in a CPAN::Reporter config.ini
+ transport = Socket host metabase.relay.example.com ...
+
+=head1 DESCRIPTION
+
+This is a L<Test::Reporter::Transport> that sends test report data serialised
+over a TCP socket.
+
+The idea is to keep dependencies in the tester perl to a bear minimum and offload
+the bulk of submission to a Metabase instance to a relay.
+
+=head1 USAGE
+
+See L<Test::Reporter> and L<Test::Reporter::Transport> for general usage
+information.
+
+=head2 Transport arguments
+
+Unlike most other Transport classes, this class requires transport arguments
+to be provided as key-value pairs:
+
+ my $report = Test::Reporter->new(
+ transport => 'Socket',
+ transport_args => [
+ host => 'metabase.relay.example.com',
+ port => 58008,
+ ],
+ );
+
+Arguments include:
+
+=over
+
+=item C<host> (required)
+
+The name or IP address of a host where we want to send our serialised data.
+
+=item C<port>
+
+The TCP port on the above C<host> to send our serialised data.
+
+=back
+
+=head1 METHODS
+
+These methods are only for internal use by Test::Reporter.
+
+=head2 new
+
+ my $sender = Test::Reporter::Transport::Socket->new( %params );
+
+The C<new> method is the object constructor.
+
+=head2 send
+
+ $sender->send( $report );
+
+The C<send> method transmits the report.
+
+=head1 AUTHORS
+
+ David A. Golden (DAGOLDEN)
+ Richard Dawe (RICHDAWE)
+ Chris Williams (BINGOS)
+
+=head1 COPYRIGHT AND LICENSE
+
+ Portions Copyright (c) 2009 by Richard Dawe
+ Portions Copyright (c) 2009-2010 by David A. Golden
+ Portions Copyright (c) 2010 by Chris Williams
+
+Licensed under the same terms as Perl itself (the "License").
+You may not use this file except in compliance with the License.
+A copy of the License was distributed with this file or you may obtain a
+copy of the License from http://dev.perl.org/licenses/
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+=cut
2  t/00_compile.t
@@ -0,0 +1,2 @@
+use Test::More tests => 1;
+use_ok('Test::Reporter::Transport::Socket');
12 t/99_pod.t
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();
18 t/99_pod_coverage.t
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+ if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+ if $@;
+
+all_pod_coverage_ok();
Please sign in to comment.
Something went wrong with that request. Please try again.