Permalink
Browse files

refactor, move to Dist::Zilla

  • Loading branch information...
1 parent bdb1026 commit 6e533f140cc3ecad880336ad8e4a85ac0644f089 @kentfredric kentfredric committed Jul 19, 2009
View
@@ -1,6 +1,8 @@
-Revision history for ELF-Extract-Sections
+Revision history for {{$dist->name}}
-0.0103 Updated to MooseX::Has::Sugar 0.0300
+{{$NEXT}}
+ Moved to Dist::Zilla instead of MI
+ Updated to MooseX::Has::Sugar 0.0300
0.0102 Dependancy Fixups, yes, more of them.
View
@@ -3,21 +3,59 @@ version = 0.0103
author = Kent Fredric <kentnl@cpan.org>
license = Perl_5
copyright_holder = Kent Fredric
-abstract = Extract Raw Chunks of data from identifiable ELF Sections
-root = ../ELF/
+;abstract = Extract Raw Chunks of data from identifiable ELF Sections
[AllFiles]
+[PruneCruft]
-[Manifest]
+[MetaResources]
+repository = git://github.com/kentfredric/ELF-Extract-Sections.git
-[ManifestSkip]
+[License]
+
+[PkgVersion]
+
+[PodPurler]
[ReadmeFromPod]
-[PruneCruft]
+[MetaYAML]
+[MetaJSON]
-[MetaResources]
+[MetaProvides::Class]
+[MetaProvides::Package]
-[MetaTests]
+[MakeMaker]
+[ModuleBuild]
-[License]
+[ManifestSkip]
+
+[Manifest]
+
+[MetaTests]
+[PodTests]
+[ExtraTests]
+
+[NextRelease]
+
+[UploadToCPAN]
+
+[Prereq]
+Log::Log4perl = 1.21
+Moose = 0.76
+Moose::Role = 0
+MooseX::Declare = 0.20
+MooseX::Has::Sugar = 0.0300
+MooseX::Log::Log4perl = 0.31
+MooseX::Types = 0
+MooseX::Types::Moose = 0.10
+MooseX::Types::Path::Class = 0.05
+overload = 0
+;[PkgSuggests]
+lib = 0
+;[TestRequires]
+FindBin = 0
+Test::More = 0
+Path::Class = 0
+YAML::XS = 0
+File::Find::Rule = 0
View
@@ -1,155 +1,140 @@
+package ELF::Extract::Sections;
+
+# ABSTRACT: Extract Raw Chunks of data from identifiable ELF Sections
+
use strict;
use warnings;
use MooseX::Declare;
-#<<<
class ELF::Extract::Sections with MooseX::Log::Log4perl {
-#>>>
- our $VERSION = '0.0103';
- use MooseX::Has::Sugar 0.0300;
- use MooseX::Types::Moose ( ':all', );
- use MooseX::Types::Path::Class ( 'File', );
- use ELF::Extract::Sections::Meta::Types ( ':all', );
-
- require ELF::Extract::Sections::Section;
-
- has file => ( isa => File, ro, required, coerce, );
- has scanner => ( isa => Str, default => 'Objdump', ro, );
- has sections => ( isa => HashRef [ElfSection], ro, lazy_build, );
- has _scanner_package => ( isa => ClassName, ro, lazy_build, );
- has _scanner_instance => ( isa => Object, ro, lazy_build, );
-
- #
- # Public Interfaces
- #
-
- #<<<
- method sorted_sections( FilterField :$field!, Bool :$descending? ) {
- #>>>
- my $m = 1;
- $m = -1 if ($descending);
- return [ sort { $m * ( $a->compare( other => $b, field => $field ) ) } values %{ $self->sections } ];
- };
-
- #
- # Moose Builders
- #
-
- 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. >$! >$@ " );
- return $pkg;
- };
-
- method _build__scanner_instance {
- my $instance = $self->_scanner_package->new();
- return $instance;
- };
-
- method _build_sections {
- $self->log->debug('Building Section List');
- if ( $self->_scanner_instance->can_compute_size ) {
- return $self->_scan_with_size;
- }
- else {
- return $self->_scan_guess_size;
- }
- };
-
- #<<<
- method BUILD( $args ) {
- #>>>
- if ( not $self->file->stat ) {
- $self->log->logconfess(q{File Specifed could not be found.});
- }
- };
-
- #
- # Internals
- #
- #<<<
- method _stash_record ( HashRef $stash! , Str $header!, Str $offset! ){
- #>>>
- if ( exists $stash->{$offset} ) {
- $self->log->logcluck(
-
- q{Warning, duplicate file offset reported by scanner. }
- . $stash->{$offset}
- . qq( and $header collide at $offset )
- . q( Assuming )
- . $stash->{$offset}
- . q( is empty and replacing it )
-
- );
- }
- $stash->{$offset} = $header;
- };
-
- #<<<
- method _build_section_section( Str $stashName, Int $start, Int $stop , File $file ){
- #>>>
- $self->log->info(" Section ${stashName} , ${start} -> ${stop} ");
- return ELF::Extract::Sections::Section->new(
- offset => $start,
- size => $stop - $start,
- name => $stashName,
- source => $file,
- );
- };
-
- #<<<
- method _build_section_table ( HashRef $ob! ){
- #>>>
- 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 );
- $i++;
- }
- return \%dataStash;
- };
-
- method _scan_guess_size {
- $self->_scanner_instance->open_file( file => $self->file );
- my %offsets = ();
- while ( $self->_scanner_instance->next_section() ) {
- my $name = $self->_scanner_instance->section_name;
- my $offset = $self->_scanner_instance->section_offset;
- $self->_stash_record( \%offsets, $name, $offset );
- }
- return $self->_build_section_table( \%offsets );
- };
-
- method _scan_with_size {
- 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 );
- }
- return \%dataStash;
- };
+
+ use MooseX::Has::Sugar 0.0300;
+ use MooseX::Types::Moose ( ':all', );
+ use MooseX::Types::Path::Class ( 'File', );
+ use ELF::Extract::Sections::Meta::Types ( ':all', );
+
+ require ELF::Extract::Sections::Section;
+
+ has '_scanner_package' => ( isa => ClassName, ro, lazy_build, );
+ has '_scanner_instance' => ( isa => Object, ro, lazy_build, );
+
+ has 'scanner' => ( isa => Str, ro, default => 'Objdump', );
+ has 'sections' => ( isa => HashRef [ElfSection], ro, lazy_build, );
+ has 'file' => ( isa => File, ro, required, coerce, );
+
+ #
+ # Public Interfaces
+ #
+
+ method sorted_sections( FilterField :$field!, Bool :$descending? ) {
+ my $m = 1;
+ $m = -1 if ($descending);
+ return [ sort { $m * ( $a->compare( other => $b, field => $field ) ) } values %{ $self->sections } ];
+ };
+
+ #
+ # Moose Builders
+ #
+
+ 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. >$! >$@ " );
+ return $pkg;
+ };
+
+ method _build__scanner_instance {
+ my $instance = $self->_scanner_package->new();
+ return $instance;
+ };
+
+ method _build_sections {
+ $self->log->debug('Building Section List');
+ if ( $self->_scanner_instance->can_compute_size ) {
+ return $self->_scan_with_size;
+ }
+ else {
+ return $self->_scan_guess_size;
+ }
+ };
+
+ method BUILD( $args ) {
+ if ( not $self->file->stat ) {
+ $self->log->logconfess(q{File Specifed could not be found.});
+ }
+ };
+
+ #
+ # Internals
+ #
+ method _stash_record ( HashRef $stash! , Str $header!, Str $offset! ){
+ if ( exists $stash->{$offset} ) {
+ $self->log->logcluck(
+
+ q{Warning, duplicate file offset reported by scanner. }
+ . $stash->{$offset}
+ . qq( and $header collide at $offset )
+ . q( Assuming )
+ . $stash->{$offset}
+ . q( is empty and replacing it )
+
+ );
+ }
+ $stash->{$offset} = $header;
+ };
+
+ method _build_section_section( Str $stashName, Int $start, Int $stop , File $file ){
+ $self->log->info(" Section ${stashName} , ${start} -> ${stop} ");
+ return ELF::Extract::Sections::Section->new(
+ offset => $start,
+ size => $stop - $start,
+ name => $stashName,
+ source => $file,
+ );
+ };
+
+ method _build_section_table ( HashRef $ob! ){
+ 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 );
+ $i++;
+ }
+ return \%dataStash;
+ };
+
+ method _scan_guess_size {
+ $self->_scanner_instance->open_file( file => $self->file );
+ my %offsets = ();
+ while ( $self->_scanner_instance->next_section() ) {
+ my $name = $self->_scanner_instance->section_name;
+ my $offset = $self->_scanner_instance->section_offset;
+ $self->_stash_record( \%offsets, $name, $offset );
+ }
+ return $self->_build_section_table( \%offsets );
+ };
+
+ method _scan_with_size {
+ 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 );
+ }
+ return \%dataStash;
+ };
#<<<
-}
+};
#>>>
1;
__END__
-=head1 NAME
-
-ELF::Extract::Sections - Extract Raw Chunks of data from identifiable ELF Sections
-
-=head1 VERSION
-
-version 0.0103
-
=head1 Caveats
=over 4
@@ -256,10 +241,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 Author
-
-Kent Fredric, C<< <kentnl@cpan.org> >>
-
=head1 Bugs
Please report any bugs or feature requests to C<bug-elf-extract-sections at rt.cpan.org>, or through
@@ -301,13 +282,5 @@ L<http://search.cpan.org/dist/ELF-Extract-Sections/>
=head1 Acknowledgements
-=head1 Copyright & License
-
-Copyright 2009 Kent Fredric, all rights reserved.
-
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-
=cut
Oops, something went wrong.

0 comments on commit 6e533f1

Please sign in to comment.