Permalink
Browse files

Perl critic tests clear

  • Loading branch information...
1 parent 9f6b7ad commit ec0ecc97104512d042715d20429cfd7831415de9 @kentfredric kentfredric committed Nov 20, 2009
View
@@ -11,6 +11,14 @@ Revision history for {{$dist->name}}
abuse. With a bit of luck, it will produce mean
as API breakdowns for me :)
+ Fixed t/ by using Compile Tests.
+ ( You can thank JAWNSY for bugging me about this )
+
+ Moved To AutoVersion::Relative
+
+ Dropped EUMM
+
+
0.0104 2009-08-21 17:34:29 UTC
Fixed Extrac typo which lead to dual indexing.
Dist::Zilla automatic tests now included.
View
@@ -1,37 +1,44 @@
name = ELF-Extract-Sections
-version = 0.0105
author = Kent Fredric <kentnl@cpan.org>
license = Perl_5
copyright_holder = Kent Fredric
;abstract = Extract Raw Chunks of data from identifiable ELF Sections
[AllFiles]
+[AutoVersion::Relative]
+major = 0
+minor = 2
+year = 2009
+month = 05
+day = 03
+hour = 09
+time_zone = Pacific/Auckland
+
[PruneCruft]
-[MetaResources]
-repository = git://github.com/kentfredric/ELF-Extract-Sections.git
+[Repository]
[License]
[PkgVersion]
-[PodPurler]
+[PodWeaver]
[ReadmeFromPod]
-[MetaYAML]
-[MetaJSON]
-
[MetaProvides::Class]
[MetaProvides::Package]
-[MakeMaker]
+[MetaYAML]
+[MetaJSON]
+
[ModuleBuild]
[ManifestSkip]
[Manifest]
+[CompileTests]
[MetaTests]
[PodTests]
[ExtraTests]
@@ -16,12 +16,12 @@ class ELF::Extract::Sections with MooseX::Log::Log4perl {
=item 1. Beta Software
This code is relatively new. It exists only as a best attempt at present until further notice. It
-has proven practical for at least one application, and this is why the module exists. However, it can't be
+has proved as practical for at least one application, and this is why the module exists. However, it can't be
guaranteed it will work for whatever you want it to in all cases. Please report any bugs you find.
=item 2. Feature Incomplete
-This only presently has a very barebones functionality, which should however prove practical for most purposes.
+This only presently has a very bare-bones functionality, which should however prove practical for most purposes.
If you have any suggestions, please tell me via "report bugs". If you never seek, you'll never find.
=item 3. Humans
@@ -79,7 +79,7 @@ Returns a HashRef of the available sections.
=head2 -> scanner
-Returns the name of the default scanner plugin
+Returns the name of the default scanner plug-in
=cut
@@ -109,45 +109,37 @@ Creates A new Section Extractor object
Returns an ArrayRef sorted by the SORT_BY field. May be Ascending or Descending depending on requirements.
-=over 4
-
-=item DESCENDING
+=head3 DESCENDING
-Optional parameters. True for descending, False or absensent for ascending.
+Optional parameters. True for descending, False or absent for ascending.
-=item SORT_BY
+=head3 SORT_BY
A String of the field to sort by. Valid options at present are
-=over 6
-
-=item name
+=head4 name
The Section Name
-=item offset
+=head4 offset
The Sections offset relative to the start of the file.
-=item size
+=head4 size
The Size of the section.
-=back
-
-=back
-
=cut
method sorted_sections( FilterField :$field!, Bool :$descending? ) {
my $m = 1;
- $m = -1 if ($descending);
+ $m = 0 - 1 if ($descending);
return [ sort { $m * ( $a->compare( other => $b, field => $field ) ) } values %{ $self->sections } ];
};
=head1 PUBLIC ATTRIBUTE BUILDERS
-These aren't really user servicable, but they make your front end work.
+These aren't really user serviceable, but they make your front end work.
=cut
@@ -182,13 +174,13 @@ These aren't really user servicable, but they make your front end work.
=head1 PRIVATE ATTRIBUTE BUILDERS
=cut
-=head2 -> _build__scanner_package
+=head2 _build__scanner_package
=cut
method _build__scanner_package {
my $pkg = 'ELF::Extract::Sections::Scanner::' . $self->scanner;
eval "use $pkg; 1;"
- or $self->log->logconfess( "The Scanner " . $self->scanner . " could not be found as $pkg. >$! >$@ " );
+ or $self->log->logconfess( 'The Scanner ' . $self->scanner . " could not be found as $pkg. >$! >$@ " );
return $pkg;
};
@@ -240,14 +232,14 @@ These aren't really user servicable, but they make your front end work.
=cut
method _build_section_table ( HashRef $ob! ){
- my %dataStash = ();
+ my %datastash = ();
my @k = sort { $a <=> $b } keys %{$ob};
my $i = 0;
while ( $i < $#k ) {
- $dataStash{ $ob->{ $k[$i] } } = $self->_build_section_section( $ob->{ $k[$i] }, $k[$i], $k[ $i + 1 ], $self->file );
+ $datastash{ $ob->{ $k[$i] } } = $self->_build_section_section( $ob->{ $k[$i] }, $k[$i], $k[ $i + 1 ], $self->file );
$i++;
}
- return \%dataStash;
+ return \%datastash;
};
=head2 -> _scan_guess_size
@@ -268,16 +260,16 @@ These aren't really user servicable, but they make your front end work.
=cut
method _scan_with_size {
- my %dataStash = ();
+ my %datastash = ();
$self->_scanner_instance->open_file( file => $self->file );
while ( $self->_scanner_instance->next_section() ) {
my $name = $self->_scanner_instance->section_name;
my $offset = $self->_scanner_instance->section_offset;
my $size = $self->_scanner_instance->section_size;
- $dataStash{$name} = $self->_build_section_section( $name, $offset, $offset + $size, $self->file );
+ $datastash{$name} = $self->_build_section_section( $name, $offset, $offset + $size, $self->file );
}
- return \%dataStash;
+ return \%datastash;
};
#<<<
@@ -295,7 +287,7 @@ This library uses L<Log::Log4perl>. To see more verbose processing notices, do t
use Log::Log4perl qw( :easy );
Log::Log4perl->easy_init($DEBUG);
-For convenience to make sure you don't happen to miss this fact, we never initialize Log4perl ourself, so it will
+For convenience to make sure you don't happen to miss this fact, we never initialize Log4perl ourselves, so it will
spit the following message if you have not set it up:
Log4perl: Seems like no initialization happened. Forgot to call init()?
@@ -306,44 +298,6 @@ To suppress this, just do
I request however you B<don't> do that for modules intended to be consumed by others without good cause.
-=head1 BUGS
-
-Please report any bugs or feature requests to C<bug-elf-extract-sections at rt.cpan.org>, or through
-the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=ELF-Extract-Sections>. I will be notified, and then you'll
-automatically be notified of progress on your bug as I make changes.
-
-
-
-
-=head1 SUPPORT
-
-You can find documentation for this module with the perldoc command.
-
- perldoc ELF::Extract::Sections
-
-
-You can also look for information at:
-
-=over 4
-
-=item * RT: CPAN's request tracker
-
-L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ELF-Extract-Sections>
-
-=item * AnnoCPAN: Annotated CPAN documentation
-
-L<http://annocpan.org/dist/ELF-Extract-Sections>
-
-=item * CPAN Ratings
-
-L<http://cpanratings.perl.org/d/ELF-Extract-Sections>
-
-=item * Search CPAN
-
-L<http://search.cpan.org/dist/ELF-Extract-Sections/>
-
-=back
-
=head1 ACKNOWLEDGEMENTS
=cut
@@ -13,7 +13,7 @@ role ELF::Extract::Sections::Meta::Scanner with MooseX::Log::Log4perl {
requires( 'open_file', 'next_section', 'section_offset', 'section_size', 'section_name', 'can_compute_size' );
-}
+};
1;
@@ -23,7 +23,7 @@ __END__
=head2 -> open_file file => FILE
-Must take a filename and assume a state reset.
+Must take a file name and assume a state reset.
=head2 -> next_section
@@ -46,7 +46,7 @@ Returns the sections name
=head2 -> can_compute_size
-This retuns wether or not this code is capable of discerning section sizes on its own.
-return 1 if true, return undef otherwise.
+This returns whether or not this code is capable of discerning section sizes on its own.
+return 1 if true, return C<undef> otherwise.
This will make us try guessing how big sections are by sorting them.
@@ -3,10 +3,9 @@ use warnings;
package ELF::Extract::Sections::Meta::Types;
-# ABSTRACT: Generic Type Contraints for E:E:S
+# ABSTRACT: Generic Type Constraints for E:E:S
# $Id:$
-use Moose;
use MooseX::Types::Moose (':all');
use MooseX::Types -declare => [ 'FilterField', 'ElfSection' ];
@@ -26,4 +25,4 @@ ENUM: name, offset, size
=head2 ElfSection
-An object that isa ELF::Extract::Sections::Section
+An object that is a ELF::Extract::Sections::Section
@@ -10,10 +10,10 @@ use MooseX::Declare;
=head1 SYNOPSIS
-This module is a model implementaiton of a Naive and system relaint ELF Section detector.
+This module is a model implementation of a Naive and system reliant ELF Section detector.
Its currently highly inefficient due to having to run the entire ELF through a disassembly
process to determine the section positions and only I<guesses> at section lengths by
-advertisng that it cant' compute sizes.
+advertising that it can't compute sizes.
TO use this module, simply initialise L<ELF::Extract::Sections> as so
@@ -55,7 +55,7 @@ L<MooseX::Types::Moose>
=cut
- use MooseX::Types::Moose ( 'Bool', 'HashRef', 'RegexpRef', 'FileHandle', 'Undef','Str','Int');
+ use MooseX::Types::Moose (qw( Bool HashRef RegexpRef FileHandle Undef Str Int));
=head2 MooseX::Types::Path::Class
@@ -202,7 +202,7 @@ They look like this:
=head2 -> _section_header_identifier : RegexpRef
-A regular expression for exracting Headers and Offsets together
+A regular expression for extracting Headers and Offsets together
<headername> File Offset: 0xdeadbeef
@@ -274,7 +274,7 @@ Calls the system C<objdump> instance for the currently processing file.
=cut
method _objdump returns (FileHandle|Undef){
- if ( open my $fh, '-|', 'objdump', qw( -D -F ), $self->_file->cleanup->absolute ) {
+ if ( open my $fh, q{-|}, q{objdump}, qw( -D -F ), $self->_file->cleanup->absolute ) {
return $fh;
}
$self->log->logconfess(qq{An error occured requesting section data from objdump $^ $@ });
@@ -110,11 +110,11 @@ returns C<Str> description of the object
=cut
method to_string ( Any $other?, Bool $polarity? ) {
- return sprintf(
- qq{[ Section %s of size %s in %s @ %x to %x ]},
- $self->name, $self->size, $self->source, $self->offset, $self->offset + $self->size,
- );
- };
+ return sprintf
+ q{[ Section %s of size %s in %s @ %x to %x ]},
+ $self->name, $self->size, $self->source, $self->offset, $self->offset + $self->size,
+ ;
+ };
=head2 -> compare ( other => $other, field => $field )
@@ -165,13 +165,13 @@ C<Str>|C<Path::Class::File>: File target to write section contents to.
method write_to( File :$file does coerce ){
my $fh = $self->source->openr;
- seek( $fh, $self->offset, 0 );
+ seek $fh, $self->offset, 0;
my $output = $file->openw;
my $chunksize = 1024;
my $bytes_left = $self->size;
my $chunk = ( $bytes_left < $chunksize ) ? $bytes_left : $chunksize;
- while ( read( $fh, my $buffer, $chunk ) ) {
- print {$output} $buffer;
+ while ( read $fh, my $buffer, $chunk ) {
+ print {$output} $buffer or Carp::croak("Write to $file failed");
$bytes_left -= $chunksize;
$chunk = ( $bytes_left < $chunksize ) ? $bytes_left : $chunksize;
}
@@ -186,9 +186,9 @@ returns C<Str> of binary data read out of file.
method contents {
my $fh = $self->source->openr;
- seek( $fh, $self->offset, 0 );
+ seek $fh, $self->offset, 0;
my $b;
- read( $fh, $b, $self->size );
+ read $fh, $b, $self->size;
return $b;
};
};
Oops, something went wrong.

0 comments on commit ec0ecc9

Please sign in to comment.