Permalink
Browse files

got rid of indirect object syntax. removed unnecessary test files

  • Loading branch information...
1 parent ce2f321 commit a80df8fee0ed620cb9255901ed8471cf58c7f89d @genio genio committed Apr 25, 2016
Showing with 5 additions and 98 deletions.
  1. +5 −13 lib/WWW/Shorten/Yourls.pm
  2. +0 −55 t/boilerplate.t
  3. +0 −18 t/pod-coverage.t
  4. +0 −12 t/pod.t
@@ -3,6 +3,7 @@ package WWW::Shorten::Yourls;
use warnings;
use strict;
use Carp ();
+use File::Spec;
use JSON::Any;
use XML::Simple();
@@ -21,7 +22,6 @@ sub new {
my ($class) = shift;
my %args = @_;
$args{source} ||= "teknatusyourls";
- use File::Spec;
my $yourlsrc
= $^O =~ /Win32/i
? File::Spec->catfile($ENV{HOME}, "_yourls")
@@ -55,7 +55,7 @@ sub new {
$yourls->{SIGNATURE} = $args{SIGNATURE};
$yourls->{json} = JSON::Any->new;
$yourls->{browser} = LWP::UserAgent->new(agent => $args{source});
- $yourls->{xml} = new XML::Simple(SuppressEmpty => 1);
+ $yourls->{xml} = XML::Simple(SuppressEmpty => 1)->new;
my ($self) = $yourls;
bless $self, $class;
}
@@ -75,7 +75,7 @@ sub makeashorterlink {
my $ua = __PACKAGE__->ua();
my $yourls;
$yourls->{json} = JSON::Any->new;
- $yourls->{xml} = new XML::Simple(SuppressEmpty => 1);
+ $yourls->{xml} = XML::Simple(SuppressEmpty => 1)->new;
my $yurl = $base . "/yourls-api.php";
$yourls->{response} = $ua->post(
$yurl,
@@ -110,7 +110,7 @@ sub makealongerlink {
my $yurl = $base . "/yourls-api.php";
my $yourls;
$yourls->{json} = JSON::Any->new;
- $yourls->{xml} = new XML::Simple(SuppressEmpty => 1);
+ $yourls->{xml} = XML::Simple(SuppressEmpty => 1)->new;
$yourls->{response} = $ua->post(
$yurl,
[
@@ -300,15 +300,7 @@ sub errors {
}
}
-sub version {
- my $self = shift;
- my ($version)
- = shift; # not sure why $version isn't being set. need to look at it
- warn
- "Version $version is later then $WWW::Shorten::Yourls::VERSION. It may not be supported"
- if (defined($version) && ($version > $WWW::Shorten::Yourls::VERSION));
- return $WWW::Shorten::Yourls::VERSION;
-} #version
+sub version { $WWW::Shorten::Yourls::VERSION; }
1; # End of WWW::Shorten::Yourls
View
@@ -1,55 +0,0 @@
-#!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");
- }
-}
-
-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]/,
- );
-}
-
-TODO: {
- local $TODO = "Need to replace the 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)
- );
-
- module_boilerplate_ok('lib/WWW/Shorten/Yourls.pm');
-
-
-}
-
View
@@ -1,18 +0,0 @@
-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();
View
@@ -1,12 +0,0 @@
-#!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();

0 comments on commit a80df8f

Please sign in to comment.