Changeset 25992
- Timestamp:
- 12/06/08 14:07:56 (4 years ago)
- Location:
- lang/perl/Helper-Simple/trunk/lib/Helper
- Files:
-
- 2 modified
-
Simple.pm (modified) (12 diffs)
-
Simple/Const.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Helper-Simple/trunk/lib/Helper/Simple.pm
r25988 r25992 21 21 use Config; 22 22 use MIME::Base64 qw/encode_base64 decode_base64/; 23 use Tie::Trace qw/watch/;24 23 25 24 local $@; … … 33 32 _ROOT_ => 34 33 { 35 appname => '',36 34 class => '', 37 35 dir => '', … … 43 41 '.zip' => '', 44 42 '.gz' => '', 43 '.bz2' => '', 44 '.jpg' => '', 45 '.png' => '', 46 '.gif' => '', 47 '.bmp' => '', 45 48 }, 46 49 default => … … 231 234 $zip->addTree($target); 232 235 $zip->writeToFileHandle($fh); 233 $option->{ decompress} = 'zip';236 $option->{extract} = 'zip'; 234 237 ($option->{extract_to}) = ($target =~ m{([^/]+)/?$}); 235 238 $option->{content} = encode_base64($option->{content}); … … 356 359 if (defined $file and -e $dir . $file) { 357 360 _ok(exists => $dir . $file); 358 } elsif (ref $c and my $compress = $c->{ decompress}) {359 my $dir, $pkg->_ decompress($compress, $file, decode_base64($c->{content}), $path_exchanger, $c);361 } elsif (ref $c and my $compress = $c->{extract}) { 362 my $dir, $pkg->_extract($compress, $file, decode_base64($c->{content}), $path_exchanger, $c); 360 363 if (defined $c->{render_file} and $c->{render_file}) { 361 364 $pkg->_render_file_recursive($c->{extract_to}, $path_exchanger); … … 441 444 my ($self) = _here(@_); 442 445 return { 443 appname => $self->appname,444 appclass => $self->appclass,445 446 root_class => $self->root_class, 446 447 startperl => $Config{startperl}, … … 471 472 my $data = {}; 472 473 if (defined $vars) { 473 while (my ($k, $v) = each %$vars) { 474 $self->{vars}->{$k} = $v; 475 } 476 $self->var; 474 if (ref $vars eq 'HASH') { 475 while (my ($k, $v) = each %$vars) { 476 $self->{vars}->{$k} = $v; 477 } 478 return $self->var; 479 } else { 480 return $self->var->{$vars} 481 } 477 482 } else { 478 483 $self->_inherit_resolver … … 528 533 } 529 534 530 sub appname {531 my ($self, $name) = @_;532 if (@_ == 2) {533 $self->root->{appname} = $name;534 } else {535 unless (my $name = $self->root->{appname}) {536 my $base = $self->appclass || ref $self;537 $base =~ m{^(\w+)};538 return lc($1 || $base);539 } else {540 return $name;541 }542 }543 }544 545 sub appclass {546 my ($self, $name) = @_;547 if (@_ == 2) {548 $self->root->{appclass} = $name;549 } else {550 unless (my $name = $self->root->{appclass}) {551 return $self->root_class;552 } else {553 return $name;554 }555 }556 }557 558 535 sub pkg { 559 536 my ($class, $pkg) = @_; … … 577 554 } 578 555 if ($success) { 579 if (my $compress = $option->{ decompress}) {580 $pkg->_ decompress($compress, $target, $content, undef, $option);556 if (my $compress = $option->{extract}) { 557 $pkg->_extract($compress, $target, $content, undef, $option); 581 558 } else { 582 559 my $name = $option->{filename}; … … 589 566 } 590 567 591 sub _ decompress{568 sub _extract { 592 569 my ($pkg, $compress, $target, $content, $path_exchanger, $option) = @_; 593 570 Carp::croak "cannot use $compress as compress option." unless $pkg->can("_extract_" . $compress); 594 571 595 my $ decompress= '_extract_' . $compress;596 $pkg->$ decompress($target, $content, $path_exchanger, $option);572 my $extract = '_extract_' . $compress; 573 $pkg->$extract($target, $content, $path_exchanger, $option); 597 574 } 598 575 … … 892 869 893 870 This copy file/directory from local. 894 For $option, you can use C< decompress>, c<omit> and C<render_file> of C<download>.871 For $option, you can use C<extract>, c<omit> and C<render_file> of C<download>. 895 872 896 873 =head2 download / dl … … 906 883 default values is 0. 907 884 908 =head3 decompress=> zip885 =head3 extract => zip 909 886 910 887 If target is compressed file and you want to extract it, -
lang/perl/Helper-Simple/trunk/lib/Helper/Simple/Const.pm
r25952 r25992 2 2 3 3 use constant { 4 JQUERY_UI => ['http://jquery-ui.googlecode.com/files/jquery.ui-1.5.2.zip', { decompress=> 'zip'} ],4 JQUERY_UI => ['http://jquery-ui.googlecode.com/files/jquery.ui-1.5.2.zip', {extract => 'zip'} ], 5 5 JQUERY_SUGGEST => ['http://www.vulgarisoip.com/files/jquery.suggest.js'], 6 6 JQUERY_MULTI_FILE_UPLOAD => ['http://www.fyneworks.com/jquery/multiple-file-upload/multiple-file-upload.zip' ], 7 JQUERY_FILE_TREE => ['http://abeautifulsite.net/notebook_files/58/jqueryFileTree.zip', { decompress=> 'zip'} ],8 TINYMCE => ['http://nchc.dl.sourceforge.net/sourceforge/tinymce/tinymce_3_1_1.zip', { decompress=> 'zip'}],7 JQUERY_FILE_TREE => ['http://abeautifulsite.net/notebook_files/58/jqueryFileTree.zip', {extract => 'zip'} ], 8 TINYMCE => ['http://nchc.dl.sourceforge.net/sourceforge/tinymce/tinymce_3_1_1.zip', {extract => 'zip'}], 9 9 TINYMCE_LANG => 10 10 [ 11 11 'http://services.moxiecode.com/i18n/download.aspx', 12 12 { 13 decompress=> 'zip',13 extract => 'zip', 14 14 method => 'post', 15 15 form => { … … 35 35 =head1 NAME 36 36 37 Helper::Simple::Const - constants for copy/copies37 Helper::Simple::Const - constants for download 38 38 39 39 =head1 VERSION … … 49 49 use this for copy/copies 50 50 51 copies(JQUERY_UI);52 copies(TINY_MCE);51 dl JQUERY_UI; 52 dl TINY_MCE; 53 53 54 54 =head1 ACKNOWLEDGEMENTS
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)