Changeset 25992

Show
Ignore:
Timestamp:
12/06/08 14:07:56 (4 years ago)
Author:
ktat
Message:

decompress -> extract; remove appname and appclass"

Location:
lang/perl/Helper-Simple/trunk/lib/Helper
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Helper-Simple/trunk/lib/Helper/Simple.pm

    r25988 r25992  
    2121use Config; 
    2222use MIME::Base64 qw/encode_base64 decode_base64/; 
    23 use Tie::Trace qw/watch/; 
    2423 
    2524local $@; 
     
    3332   _ROOT_ => 
    3433   { 
    35     appname => '', 
    3634    class   => '', 
    3735    dir     => '', 
     
    4341     '.zip'    => '', 
    4442     '.gz'     => '', 
     43     '.bz2'    => '', 
     44     '.jpg'    => '', 
     45     '.png'    => '', 
     46     '.gif'    => '', 
     47     '.bmp'    => '', 
    4548    }, 
    4649    default => 
     
    231234      $zip->addTree($target); 
    232235      $zip->writeToFileHandle($fh); 
    233       $option->{decompress}  = 'zip'; 
     236      $option->{extract}  = 'zip'; 
    234237      ($option->{extract_to}) = ($target =~ m{([^/]+)/?$}); 
    235238      $option->{content} = encode_base64($option->{content}); 
     
    356359    if (defined $file and -e $dir . $file) { 
    357360      _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); 
    360363      if (defined $c->{render_file} and $c->{render_file}) { 
    361364        $pkg->_render_file_recursive($c->{extract_to}, $path_exchanger); 
     
    441444  my ($self) = _here(@_); 
    442445  return { 
    443           appname    => $self->appname, 
    444           appclass   => $self->appclass, 
    445446          root_class => $self->root_class, 
    446447          startperl  => $Config{startperl}, 
     
    471472  my $data = {}; 
    472473  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    } 
    477482  } else { 
    478483    $self->_inherit_resolver 
     
    528533} 
    529534 
    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  
    558535sub pkg { 
    559536  my ($class, $pkg) = @_; 
     
    577554    } 
    578555    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); 
    581558      } else { 
    582559        my $name = $option->{filename}; 
     
    589566} 
    590567 
    591 sub _decompress { 
     568sub _extract { 
    592569  my ($pkg, $compress, $target, $content, $path_exchanger, $option) = @_; 
    593570  Carp::croak "cannot use $compress as compress option." unless $pkg->can("_extract_" . $compress); 
    594571 
    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); 
    597574} 
    598575 
     
    892869 
    893870This copy file/directory from local. 
    894 For $option, you can use C<decompress>, c<omit> and C<render_file> of C<download>. 
     871For $option, you can use C<extract>, c<omit> and C<render_file> of C<download>. 
    895872 
    896873=head2 download / dl 
     
    906883default values is 0. 
    907884 
    908 =head3 decompress => zip 
     885=head3 extract => zip 
    909886 
    910887If target is compressed file and you want to extract it, 
  • lang/perl/Helper-Simple/trunk/lib/Helper/Simple/Const.pm

    r25952 r25992  
    22 
    33use 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'} ], 
    55    JQUERY_SUGGEST           => ['http://www.vulgarisoip.com/files/jquery.suggest.js'], 
    66    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'}], 
    99    TINYMCE_LANG             => 
    1010      [ 
    1111       'http://services.moxiecode.com/i18n/download.aspx', 
    1212       { 
    13         decompress => 'zip', 
     13        extract => 'zip', 
    1414        method => 'post', 
    1515        form    => { 
     
    3535=head1 NAME 
    3636 
    37 Helper::Simple::Const - constants for copy/copies 
     37Helper::Simple::Const - constants for download 
    3838 
    3939=head1 VERSION 
     
    4949use this for copy/copies 
    5050 
    51  copies(JQUERY_UI); 
    52  copies(TINY_MCE); 
     51 dl JQUERY_UI; 
     52 dl TINY_MCE; 
    5353 
    5454=head1 ACKNOWLEDGEMENTS