<commit_before># $Id$
package Distribution::Cooker;
use strict;

use warnings;
no warnings;

use subs qw();
use vars qw($VERSION);

$VERSION = '0.10_01';

=head1 NAME

Distribution::Cooker - This is the description

=head1 SYNOPSIS

	use Distribution::Cooker;

=head1 DESCRIPTION

=over 4

=cut

use Cwd;
use Config::IniFiles;
use File::Spec::Functions qw(catfile);

__PACKAGE__->run( $ARGV[0] ) unless caller;

=item run( MODULE_NAME )

Calls pre-run, collects information about 

=cut

sub run
	{
	$_[0]->pre_run;
	
	my $module = shift || prompt( "Module name> " );

	my $dist   = $_[0]->module_to_distname( $module )
	
	my $cwd    = catfile( cwd(), $dist );
	
	$self->cook;

	$_[0]->post_run;
	
	1;
	}	

=item pre_run

Method to call before run() starts its work. run() will
call this for you. By default this is a no-op, but you
can redefine it or override it in a subclass.

=cut

sub pre_run  { 1 }

=item pre_run

Method to call before run() starts its work. run() will
call this for you. By default this is a no-op, but you
can redefine it or override it in a subclass.

=cut

sub post_run { 1 }

=item cook

Take the templates and cook them. This version uses Template
Toolkit, but you can make a subclass to override it.

=cut

sub cook
	{
	my $self = shift;
	
	system 
		join " ",
		"/usr/local/bin/ttree"        ,
		"-s ~/.templates/modules"     ,
		qq|-d "$cwd"|                 ,
		"-define module='$module'"    ,
		"-define module_file='$file'" ,
		"-define module_dist='$dist'"
		;
	
	( my $base = $module ) =~ s/.*:://;
	
	rename 
		catfile( $dist, 'lib', 'Foo.pm' ),
		catfile( $dist, 'lib', $file );
	}

=item

=cut

sub module_to_distname
	{
	my( $self, $module ) = @_;
	
	my $dist   = $module; $dist =~ s/::/-/g;<commit_msg>* a first pass at making my module_cooker script a module. Now let's move on to testing it.<commit_after># $Id$
package Distribution::Cooker;
use strict;

use warnings;
no warnings;

use subs qw();
use vars qw($VERSION);

$VERSION = '0.10_01';

=head1 NAME

Distribution::Cooker - This is the description

=head1 SYNOPSIS

	use Distribution::Cooker;

=head1 DESCRIPTION

=over 4

=cut

use Cwd;
use Config::IniFiles;
use File::Spec::Functions qw(catfile);

__PACKAGE__->run( $ARGV[0] ) unless caller;

=item run( MODULE_NAME )

Calls pre-run, collects information about 

=cut

sub run
	{
	my $self = $_[0]->new;
	$self->init;
	
	$self->pre_run;
	
	$self->module( 
		shift || prompt( "Module name> " ) 
		);

	$self->dist(
		$self->module_to_distname( $module )
		);
		
	$self->cook;

	$self->post_run;
	
	1;
	}	

=item new

Create the bare object.

=cut

sub new { bless {}, $_[0] }
	
=item init

Initialize the object. 

=cut

sub init
	{
	}
	
=item pre_run

Method to call before run() starts its work. run() will
call this for you. By default this is a no-op, but you
can redefine it or override it in a subclass.

run() calls this method immediately after it creates
the object but before it initializes it.

=cut

sub pre_run  { 1 }

=item pre_run

Method to call before run() starts its work. run() will
call this for you. By default this is a no-op, but you
can redefine it or override it in a subclass.

=cut

sub post_run { 1 }

=item cook

Take the templates and cook them. This version uses Template
Toolkit, but you can make a subclass to override it.

=cut

sub cook
	{
	my( $module, $dist ) = map { $_[0]->$_() } qw( module dist );

	( my $file = $module . ".pm" ) =~ s/.*:://; 
	
	system 
		join " ",
		"/usr/local/bin/ttree"        ,
		"-s ~/.templates/modules"     ,
		qq|-d "$cwd"|                 ,
		"-define module='$module'"    ,
		"-define module_file='$file'" ,
		"-define module_dist='$dist'"
		;
	
	( my $base = $module ) =~ s/.*:://;
	
	rename 
		catfile( $dist, 'lib', 'Foo.pm' ),
		catfile( $dist, 'lib', $file );
	}

=item module( [ MODULE_NAME ] )

Return the module name. With an argument, set the module name.

=cut

sub module
	{
	$_[0]->{module} = $_[1] if defined $_[1];
	$_[0]->{module};
	}

=item dist( [ DIST_NAME ] )

Return the module name. With an argument, set the module name.

=cut

sub dist
	{
	$_[0]->{dist} = $_[1] if defined $_[1];
	$_[0]->{dist};
	}

=item module_to_distname( MODULE_NAME )

Take a module name, such as C<Foo::Bar>, and turn it into
a distribution name, such as C<Foo-Bar>.

=cut

sub module_to_distname
	{
	my( $self, $module ) = @_;
	
	my $dist   = $module; $dist =~ s/::/-/g;
{'fraction_non_alphanumeric': 0.1482578000455477, 'fraction_numerical': 0.009109542245502164, 'mean_word_length': 3.123943661971831, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3251283', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1631, 'n_words': 552}