Guest User

Untitled

a guest
Apr 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. #! /usr/local/bin/perl
  2.  
  3.  
  4. # ****************************************************************
  5. # pragma(s)
  6. # ****************************************************************
  7.  
  8. use strict;
  9. use warnings;
  10.  
  11.  
  12. # ****************************************************************
  13. # general dependency(-ies)
  14. # ****************************************************************
  15.  
  16. use FindBin;
  17. use Orochi;
  18. use Readonly;
  19.  
  20.  
  21. # ****************************************************************
  22. # package grobal constant(s)
  23. # ****************************************************************
  24.  
  25. Readonly my $Base_Registory => '/DBICx/Modeler/Generator/';
  26. Readonly my %Literal => (
  27. 'dsn' => 'dbi:mysql:dbname=amikeco:host=localhost',
  28. 'username' => 'mysql_user',
  29. 'password' => 'foobar',
  30. 'Class/application' => 'Amikeco',
  31. 'Path/root' => $FindBin::Bin . '/../../',
  32. # using default values...
  33. # 'components' => [qw(UTF8Columns)],
  34. # 'is_debug' => 1,
  35. # 'Class/model_part' => 'Model',
  36. # 'Class/schema_part' => 'Schema',
  37. # 'Tree/source' => [qw(source lib)],
  38. # 'Tree/target' => [qw(lib)],
  39. # 'Path/extension' => '.pm',
  40. );
  41.  
  42. # CAVEAT: order of classes is sensitive
  43. Readonly my @Classes => qw(
  44. DBICx::Modeler::Generator::Class
  45. DBICx::Modeler::Generator::Tree
  46. DBICx::Modeler::Generator::Path
  47. DBICx::Modeler::Generator
  48. );
  49.  
  50.  
  51. # ****************************************************************
  52. # mainroutine
  53. # ****************************************************************
  54.  
  55. _update();
  56.  
  57.  
  58. # ****************************************************************
  59. # subroutine(s)
  60. # ****************************************************************
  61.  
  62. sub _update {
  63. my $container = Orochi->new;
  64.  
  65. _initialize($container);
  66.  
  67. my $generator = $container->get('/DBICx/Modeler/Generator');
  68.  
  69. $generator->update_schemata;
  70. $generator->update_models;
  71.  
  72. return;
  73. }
  74.  
  75. sub _initialize {
  76. my $container = shift;
  77.  
  78. while (my ($registory, $literal) = each %Literal) {
  79. $container->inject_literal($Base_Registory . $registory => $literal);
  80. }
  81.  
  82. foreach my $class (@Classes) {
  83. $container->inject_class($class);
  84. }
  85. # $container->inject_namespace('DBICx::Modeler::Generator');
  86.  
  87. return;
  88. }
  89.  
  90.  
  91. # ****************************************************************
  92. # return true
  93. # ****************************************************************
  94.  
  95. 1;
  96. __END__
  97.  
  98.  
  99. # ****************************************************************
  100. # POD
  101. # ****************************************************************
  102.  
  103. =pod
  104.  
  105. =head1 NAME
  106.  
  107. maintal_models -
  108.  
  109. =head1 SYNOPSIS
  110.  
  111. $ perl source\sbin\maintain_models.pl
  112.  
  113. =head1 DESCRIPTION
  114.  
  115. blah blah blah
  116.  
  117. path
  118. to
  119. base
  120. lib
  121. MyApp
  122. Model
  123. *.pm
  124. Schema
  125. *.pm
  126. rc
  127. myapp.sql
  128. source
  129. lib
  130. MyApp
  131. Model
  132. *.pm
  133. Schema
  134. *.pm
  135. sbin
  136. maintain_models.pl
  137.  
  138. =head1 TO DO
  139.  
  140. =over 4
  141.  
  142. =item * L<MooseX::GetOpt>
  143.  
  144. =back
  145.  
  146. =cut
Add Comment
Please, Sign In to add comment