Skip to content

Instantly share code, notes, and snippets.

@gardejo
Created November 25, 2009 18:00
Show Gist options
  • Save gardejo/242907 to your computer and use it in GitHub Desktop.
Save gardejo/242907 to your computer and use it in GitHub Desktop.
#! /usr/local/bin/perl
# ****************************************************************
# pragma(s)
# ****************************************************************
use strict;
use warnings;
# ****************************************************************
# general dependency(-ies)
# ****************************************************************
use FindBin;
use Orochi;
use Readonly;
# ****************************************************************
# package grobal constant(s)
# ****************************************************************
Readonly my $Base_Registory => '/DBICx/Modeler/Generator/';
Readonly my %Literal => (
'dsn' => 'dbi:mysql:dbname=amikeco:host=localhost',
'username' => 'mysql_user',
'password' => 'foobar',
'Class/application' => 'Amikeco',
'Path/root' => $FindBin::Bin . '/../../',
# using default values...
# 'components' => [qw(UTF8Columns)],
# 'is_debug' => 1,
# 'Class/model_part' => 'Model',
# 'Class/schema_part' => 'Schema',
# 'Tree/source' => [qw(source lib)],
# 'Tree/target' => [qw(lib)],
# 'Path/extension' => '.pm',
);
# CAVEAT: order of classes is sensitive
Readonly my @Classes => qw(
DBICx::Modeler::Generator::Class
DBICx::Modeler::Generator::Tree
DBICx::Modeler::Generator::Path
DBICx::Modeler::Generator
);
# ****************************************************************
# mainroutine
# ****************************************************************
_update();
# ****************************************************************
# subroutine(s)
# ****************************************************************
sub _update {
my $container = Orochi->new;
_initialize($container);
my $generator = $container->get('/DBICx/Modeler/Generator');
$generator->update_schemata;
$generator->update_models;
return;
}
sub _initialize {
my $container = shift;
while (my ($registory, $literal) = each %Literal) {
$container->inject_literal($Base_Registory . $registory => $literal);
}
foreach my $class (@Classes) {
$container->inject_class($class);
}
# $container->inject_namespace('DBICx::Modeler::Generator');
return;
}
# ****************************************************************
# return true
# ****************************************************************
1;
__END__
# ****************************************************************
# POD
# ****************************************************************
=pod
=head1 NAME
maintal_models -
=head1 SYNOPSIS
$ perl source\sbin\maintain_models.pl
=head1 DESCRIPTION
blah blah blah
path
to
base
lib
MyApp
Model
*.pm
Schema
*.pm
rc
myapp.sql
source
lib
MyApp
Model
*.pm
Schema
*.pm
sbin
maintain_models.pl
=head1 TO DO
=over 4
=item * L<MooseX::GetOpt>
=back
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment