Skip to content

Commit

Permalink
Changed ModuleInfo to use Module::Metadata
Browse files Browse the repository at this point in the history
  (New name for Module::Build::ModuleInfo after it was split from
   the Module::Build distribution)
  Bump version of TemplateCJM to 3.04 (updated docs to match)
  • Loading branch information
madsen committed Dec 17, 2010
1 parent 52f1ef5 commit 6d55e7e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -2,6 +2,7 @@ Revision history for Dist-Zilla-Plugins-CJM

3.04 NOT
Dist::Zilla::Role::ModuleInfo
- Use Module::Metadata instead of Module::Build::ModuleInfo.
- Locally reset $/ $, $\ to default values (just in case)

3.03 December 7, 2010
Expand Down
2 changes: 1 addition & 1 deletion dist.ini
Expand Up @@ -23,7 +23,7 @@ File::Copy = 0
File::HomeDir = 0.81
File::Temp = 0.19 ; newdir
List::Util = 0
Module::Build::ModuleInfo = 0.28
Module::Metadata = 0
Moose = 0.65 ; attr fulfills requires
Moose::Autobox = 0.09 ; flattten
Path::Class = 0
Expand Down
4 changes: 2 additions & 2 deletions lib/Dist/Zilla/Plugin/TemplateCJM.pm
Expand Up @@ -17,7 +17,7 @@ package Dist::Zilla::Plugin::TemplateCJM;
# ABSTRACT: Process templates, including version numbers & changes
#---------------------------------------------------------------------

our $VERSION = '3.03';
our $VERSION = '3.04';
# This file is part of {{$dist}} {{$dist_version}} ({{$date}})

=head1 SYNOPSIS
Expand Down Expand Up @@ -550,7 +550,7 @@ The name of the module being processed (i.e., its package).
=item C<$pm_info>
A Module::Build::ModuleInfo object containing information about the
A Module::Metadata object containing information about the
module. (Note that the filename in C<$pm_info> will not be correct.)
=item C<$version>
Expand Down
26 changes: 16 additions & 10 deletions lib/Dist/Zilla/Role/ModuleInfo.pm
@@ -1,7 +1,7 @@
#---------------------------------------------------------------------
package Dist::Zilla::Role::ModuleInfo;
#
# Copyright 2009 Christopher J. Madsen
# Copyright 2010 Christopher J. Madsen
#
# Author: Christopher J. Madsen <perl@cjmweb.net>
# Created: 25 Sep 2009
Expand All @@ -14,7 +14,7 @@ package Dist::Zilla::Role::ModuleInfo;
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the
# GNU General Public License or the Artistic License for more details.
#
# ABSTRACT: Create Module::Build::ModuleInfo object from Dist::Zilla::File
# ABSTRACT: Create Module::Metadata object from Dist::Zilla::File
#---------------------------------------------------------------------

our $VERSION = '3.04';
Expand All @@ -24,48 +24,54 @@ use Moose::Role;

use autodie ':io';
use File::Temp ();
use Module::Build::ModuleInfo ();
use Module::Metadata ();
use Path::Class qw(dir file);

=head1 DEPENDENCIES
{{$t->dependency_link('Module::Metadata')}}.
=head1 DESCRIPTION
Plugins implementing ModuleInfo may call their own C<get_module_info>
method to construct a L<Module::Build::ModuleInfo> object.
method to construct a L<Module::Metadata> object. (Module::Metadata
is the new name for Module::Build::ModuleInfo, now that it's been
split from the Module-Build distribution.)
=method get_module_info
my $info = $plugin->get_module_info($file);
This constructs a Module::Build::ModuleInfo object from the contents
This constructs a Module::Metadata object from the contents
of a C<$file> object that does Dist::Zilla::Role::File. Any additional
arguments are passed along to C<< Module::Build::ModuleInfo->new_from_file >>.
arguments are passed along to C<< Module::Metadata->new_from_file >>.
=cut

sub get_module_info
{
my $self = shift;
my $file = shift;
# Any additional parameters get passed to M::B::ModuleInfo->new_from_file
# Any additional parameters get passed to M::Metadata->new_from_file

# To be safe, reset the global variables controlling IO to their defaults:
local ($/, $,, $\) = "\n";

# Module::Build::ModuleInfo doesn't have a new_from_string method,
# Module::Metadata doesn't have a new_from_string method,
# so we'll write the current contents to a temporary file:

my $tempdirObject = File::Temp->newdir();
my $dir = dir("$tempdirObject");
my $modPath = file($file->name);

# Module::Build::ModuleInfo only cares about the basename of the file:
# Module::Metadata only cares about the basename of the file:
my $tempname = $dir->file($modPath->basename);

open(my $temp, '>', $tempname);
print $temp $file->content;
close $temp;

return Module::Build::ModuleInfo->new_from_file("$tempname", @_)
return Module::Metadata->new_from_file("$tempname", @_)
or die "Unable to get module info from " . $file->name . "\n";
} # end get_module_info

Expand Down

0 comments on commit 6d55e7e

Please sign in to comment.