| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Egg::Model::FsaveDate; | 
| 2 |  |  |  |  |  |  | # | 
| 3 |  |  |  |  |  |  | # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # $Id: FsaveDate.pm 316 2008-04-17 11:54:05Z lushe $ | 
| 6 |  |  |  |  |  |  | # | 
| 7 | 2 |  |  | 2 |  | 597 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 86 |  | 
| 8 | 2 |  |  | 2 |  | 13 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 124 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our $VERSION= '0.02'; | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | package Egg::Model::FsaveDate::handler; | 
| 13 | 2 |  |  | 2 |  | 10 | use strict; | 
|  | 2 |  |  |  |  | 15 |  | 
|  | 2 |  |  |  |  | 62 |  | 
| 14 | 2 |  |  | 2 |  | 9 | use base qw/ Egg::Model::FsaveDate::Base /; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 1581 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | 1; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | __END__ | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head1 NAME | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | Egg::Model::FsaveDate - Model to preserve arbitrary text data according to date. | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | my $fs= $e->model('fsavedate'); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | my $output_path= $fs->save( <<END_TEXT ); | 
| 29 |  |  |  |  |  |  | save data. | 
| 30 |  |  |  |  |  |  | END_TEXT | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | The data that wants to be preserved in the file is preserved separately for the | 
| 35 |  |  |  |  |  |  | directory of every the date. | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | To use it, 'FsaveDate' is added to the MODEL setting of the configuration of the | 
| 38 |  |  |  |  |  |  | project. | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | % vi /path/to/MyApp/lib/MyApp/config.pm | 
| 41 |  |  |  |  |  |  | .......... | 
| 42 |  |  |  |  |  |  | MODEL=> [ | 
| 43 |  |  |  |  |  |  | [ FsaveDate => { | 
| 44 |  |  |  |  |  |  | base_path => ........... | 
| 45 |  |  |  |  |  |  | .... | 
| 46 |  |  |  |  |  |  | } ], | 
| 47 |  |  |  |  |  |  | ], | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | Please generate the controller module with L<Egg::Helper::Model::FsaveDate> when | 
| 50 |  |  |  |  |  |  | you want to customize processing. | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | % cd /path/to/MyApp/lib/bin | 
| 53 |  |  |  |  |  |  | % ./myapp_helper.pl M::FsaveDate | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | The antecedent of this module is 'Egg::Plugin::BackUP::Easy'. | 
| 56 |  |  |  |  |  |  | This was added, and it operated as a model and some hands were added. | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head1 CONFIGURATION | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =head3 base_path | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | Directory PATH of file output destination. | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | Default is 'PROJECT_ROOT/etc/FsaveDate'. | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =head3 amount_save | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | When the number of preservation directories under the control of 'base_path' | 
| 69 |  |  |  |  |  |  | exceeds this set value, it deletes it in old the order. | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | Default is '90'. | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head3 extention | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Extension in saved file. | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | Default is 'txt'. | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | =head1 CONTROLLER MODULE | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | It is a method of customizing the controller module generated in the helper script. | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | First of all, because the name space is a road as shown in model manager's @ISA, | 
| 84 |  |  |  |  |  |  | it customizes it in the subordinate's MyApp::Model::FsaveDate::handler though | 
| 85 |  |  |  |  |  |  | controller's package name is MyApp::Model::FsaveDate. | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | The configuration is set in this handler, and an existing if necessary method is | 
| 88 |  |  |  |  |  |  | Obarraided. | 
| 89 |  |  |  |  |  |  |  | 
| 90 |  |  |  |  |  |  | package MyApp::Model::FsaveDate::handler; | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | __PACKAGE__->config( .......... ); | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  | For instance, to convert the character-code of the preserved text into the | 
| 95 |  |  |  |  |  |  | arbitrary one, 'create_body' method is Orbaraided. | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | sub create_body { | 
| 98 |  |  |  |  |  |  | my($self, $text)= @_; | 
| 99 |  |  |  |  |  |  | $$text=~tr/\n/\r\n/; | 
| 100 |  |  |  |  |  |  | return Jcode->new($text)->sjis; | 
| 101 |  |  |  |  |  |  | } | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | Passed $text is passed by the SCALAR reference. After this is processed, it | 
| 104 |  |  |  |  |  |  | returns it with usual SCALAR. | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | Additionally, there are 'create_dir_name' and 'create_file_name' in the method | 
| 107 |  |  |  |  |  |  | of possible override. Please refer to the source code for details for the | 
| 108 |  |  |  |  |  |  | processing method etc. | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | L<Egg::Release>, | 
| 113 |  |  |  |  |  |  | L<Egg::Model::FsaveDate::Base>, | 
| 114 |  |  |  |  |  |  | L<Egg::Helper::Model::FsaveDate>, | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | =head1 AUTHOR | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt> | 
| 119 |  |  |  |  |  |  |  | 
| 120 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | Copyright (C) 2008 by Bee Flag, Corp. E<lt>http://egg.bomcity.com/E<gt>, All Rights Reserved. | 
| 123 |  |  |  |  |  |  |  | 
| 124 |  |  |  |  |  |  | This library is free software; you can redistribute it and/or modify | 
| 125 |  |  |  |  |  |  | it under the same terms as Perl itself, either Perl version 5.8.6 or, | 
| 126 |  |  |  |  |  |  | at your option, any later version of Perl 5 you may have available. | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | =cut | 
| 129 |  |  |  |  |  |  |  |