b0VIM 7.4      á¿)U)!õ  dinis                                   dl-gubuntu                              ~dinis/Workspace/File-Assets-Precompile/lib/File/Assets/Precompile.pm                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        utf-8 3210    #"! U                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 tp           º                            D       »                     C       ý                     �       <                    W       Ë                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ad  "   &     º       Þ  Ý  Ò  Æ  ¸  ¶  „  ‚  �  n  I  H  <  ;  ø  ÷  è  ç  Ú  Ù  Ô  Ó  Ã  Â  ›  š  {  z  X  W  *  ø  ¿  ¾  z  I  (  !      
  	  Â  w  v  [  V  U  J  0  /      î  Þ  Ì  »  ¥  Ž  �  �  c  L  K  6  #        ô
  á
  Í
  Ê
  É
  °
  ™
  �
  i
  f
  e
  N
  4
  
  
  
  
  è	  É	  ®	  —	  y	  c	  9	  	  è  á  Þ  Ý  É  ±  ˜  ƒ  €    c  L  3        ù  ß  À  ©  ¦  ¥  “  |  c  O  L  K  '      ï  Ú  Ó  Ñ  Ð  ¶  µ  °  ¯  –  ~  H  4  2  1          ÷  à  »  ¨  ¦  ¥  —  ’  ‘  u  _  L  K  +    Õ  Ô  Ã  ž    k  e  d  S  6  0  /        û  ä  ¾  «  ©  ¨  Ž  s  X  <  ,  &  %                                        }         return;     if ( !-f $full_path ) {     my $full_path = shift;     my $self      = shift; sub _metadata_from_file {  }     return $mtime;     my $mtime = [ stat($file) ]->[9];     my $file  = shift; sub _file_mtime {  }     return $digest->hexdigest;      }         $digest->add($data);     if ($data) {      }         close($fh);         $digest->addfile($fh);         open my $fh, '<:raw', $file;     if ($file) {      my $digest = Digest->new( $self->digest_method );     my $data   = $args{'data'};     my $file   = $args{'file'};      my %args = @_;     my $self = shift; sub calculate_fingerprint {  =cut =head2 md5sum  }     return $files;     my $files = $self->find_files();     my $self  = shift; sub _build_asset_cache {  =cut  =head2 _build_asset_cache  }     return $digest;     my $digest = Digest->new( $self->digest_method );     my $self   = shift; sub _build_full_digest {  =cut  =head2 _build_full_digest  }     };         '.js'  => 1,         '.css' => 1,     return {     my $self = shift; sub _build_versionized_extensions {  );     'default' => 0,     'isa'     => 'Bool',     'is'      => 'ro', has 'minify' => (  );     'lazy_build' => 1,     'isa'        => 'HashRef',     'is'         => 'ro', has 'versionized_extensions' => (  );     'default' => 0,     'isa'     => 'Bool',     'is'      => 'ro', has 'development_mode' => (  );     'required' => 1,     'isa'      => 'Str',     'is'       => 'rw', has 'base_url' => (  );     },         'asset_cache_keys'   => 'keys',         'asset_cache_count'  => 'count',         'asset_cache_values' => 'values',     'handles'    => {     'traits'     => ['Hash'],     'lazy_build' => 1,     'init_arg'   => undef,     'isa'        => 'HashRef',     'is'         => 'ro', has 'asset_cache' => (  );     'lazy_build' => 1,     'is'         => 'ro', has 'full_digest' => (  );     'default' => 'MD5',     'isa'     => 'Str',     'is'      => 'ro', has 'digest_method' => (  );     'isa' => 'Str',     'is'  => 'ro', has 'output_path' => (  );     'isa' => 'Str',     'is'  => 'rw', has 'base_path' => (  use CSS::Minifier::XS; use JavaScript::Minifier::XS; use Digest;  use Path::Class::File; use Path::Class::Dir; use Path::Class; use File::MMagic; use File::Find; use File::Basename qw(); use Data::Dumper; use Carp qw( croak );  use namespace::autoclean; use Moose;  =cut =head1 SUBROUTINES/METHODS  if you don't export anything, such as for a purely object-oriented module. A list of functions that can be exported.  You can delete this section  =head1 EXPORT      ...     );         'development_mode' => 1,         'base_url'         => '/public/assets/',         #'base_url'    => 'https://cdn.example.com/public/assets/',          'output_path' => "$FindBin::Bin/public/assets/",         'base_path'   => "$FindBin::Bin/assets/",     my $foo = File::Assets::Precompile->new(      use File::Assets::Precompile;  Perhaps a little code snippet.  Quick summary of what the module does.  =head1 SYNOPSIS  =cut  Version 0.01  =head1 VERSION  File::Assets::Precompile - The great new File::Assets::Precompile!  =head1 NAME  my $l = Log::Log4perl::get_logger(); use Log::Log4perl;  }     $File::Assets::Precompile::VERSION = '0.0.1'; { use warnings; use strict; use 5.006;  package File::Assets::Precompile; ad  è  `     W       ô  ó  Œ    Ã  Â  Á  À  ¿  °  ¯  j  i  D  C  B          Ü  Û  ˜  —  h  g  4  3      å  ä  Ð  Ï  ˜  —  ‘  �  �  w  v  u  X  W  <  ;  ó  ¯  ’  ‘  [  Z    Ð
  ‰
  K
  J
  
  »	  u	  t	  ,	  ú  ù  ¶  n  -  ä  œ  V    Í  Ì  „  <  ø  ±  r  .  æ  ³  ²  ±  ¬  «  ˆ  `  _                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          1;    # End of File::Assets::Precompile __PACKAGE__->meta->make_immutable;  =cut   EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER  to you shall terminate on the date that such litigation is filed. direct or contributory patent infringement, then this Artistic License counterclaim) against any party alleging that the Package constitutes Package. If you institute patent litigation (including a cross-claim or licensable by the Copyright Holder that are necessarily infringed by the otherwise transfer the Package with respect to any patent claims patent license to make, have made, use, offer to sell, sell, import and This license includes the non-exclusive, worldwide, free-of-charge  mark, tradename, or logo of the Copyright Holder. This license does not grant you the right to use any trademark, service  your Modified Version complies with the requirements of this license. by someone other than you, you are nevertheless required to ensure that If your Modified Version has been derived from a Modified Version made  or distribute the Package, if you do not accept this license. distributing the Package, you accept this license. Do not use, modify, Versions is governed by this Artistic License. By using, modifying or Any use, modification, and distribution of the Standard or Modified  L<http://www.perlfoundation.org/artistic_license_2_0>  copy of the full license at: under the terms of the the Artistic License (2.0). You may obtain a This program is free software; you can redistribute it and/or modify it  Copyright 2015 Dinis Lage.  =head1 LICENSE AND COPYRIGHT   =head1 ACKNOWLEDGEMENTS   =back  L<http://search.cpan.org/dist/File-Assets-Precompile/>  =item * Search CPAN  L<http://cpanratings.perl.org/d/File-Assets-Precompile>  =item * CPAN Ratings  L<http://annocpan.org/dist/File-Assets-Precompile>  =item * AnnoCPAN: Annotated CPAN documentation  L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Assets-Precompile>  =item * RT: CPAN's request tracker (report bugs here)  =over 4  You can also look for information at:       perldoc File::Assets::Precompile  You can find documentation for this module with the perldoc command.  =head1 SUPPORT     automatically be notified of progress on your bug as I make changes. the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Assets-Precompile>.  I will be notified, and then you'll Please report any bugs or feature requests to C<bug-file-assets-precompile at rt.cpan.org>, or through  =head1 BUGS ad  ó  	     C       þ  ý  é  Ï  µ  Œ  ‹  b  =    Î  Í     Ÿ  ]  9  8      ü  û  Û  Ú  ‰  b  ?        â  ­  Œ  i  ^  X  W  ,  
  Ë  Å  Ä  •  ”  ]          ¼
  »
  j
  8
  
   
  à	  ß	  Ó	  Ñ	  Ð	  °	  š	  ‡	  †	  d	  @	  ?	  	  	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         my $base_path = my $full_path =      my $content = $args{'content'};     my $asset   = $args{'asset'};      my %args = @_;     my $self = shift; sub _replace_asset_references {  }     return;      $dest_file->spew($content);      $asset->{'dest_path'}     = $dest_file->stringify;     $asset->{'dest_rel_path'} = $target_rel_path;     my $target_rel_path = File::Spec->abs2rel( $dest_file, $self->output_path );      my $dest_file = Path::Class::File->new( $dest_dir, $dest_filename, );      #}      $dest_filename = sprintf( '%s-%s%s', $filename, $fingerprint, $suffix, );     #if ( $self->versionized_extensions->{$suffix} ) {      my $fingerprint = $asset->{'fingerprint'};      }           $self->calculate_fingerprint( 'data' => $content, );         $asset->{'fingerprint'} =     if ( $asset->{'dirty_fingerprint'} ) {      }         );             'content' => $content,             'asset'   => $asset,         $content = $self->_replace_asset_references(     if ( $asset->{'mime_type'} eq 'text/plain' ) {      );         'original_file' => $file,         'asset'         => $asset,     my $content = $self->_get_content(    #$l->debug( 'Getting file: ', { 'filter' => \&Dumper, 'value' => $file, }, );      $asset->{'mtime'} = $mtime;      }         $dest_dir->mkpath;     if ( !-d $dest_dir ) {      my $mtime = _file_mtime($file);     my $file  = Path::Class::File->new( $asset->{'full_path'}, );      my $dest_filename = $filename . $suffix;      my $dest_dir = Path::Class::Dir->new( $self->output_path, $dirs, );     my $suffix   = $asset->{'suffix'};     my $dirs     = $asset->{'dirs'};     my $filename = $asset->{'filename'};      my $rel_path = $asset->{'rel_path'};     my $asset    = shift;     my $self     = shift; sub _process_file {  } ad  «  ×     D       Í  Š  ‰  A    Ô  Ó  ¬  i  h  C           Ç  º  •  q  J  .  	  ç  Ã  £  œ  š  ™  ˆ  r  _  ^  J  3    È  ±  �  “  a  Z  2          ï
  Ü
  Û
  ›
  q
  p
  6
  5
  
  
  Ø	  ¦	  €	  z	  n	  l	  k	  X	  B	  ÿ  ã  ×  ã  É     Ÿ  v  Q  *  â  á  ´  ³  q  M  L  1        ï  î  �  v  S  1  *  )  ö  Á     }  r  l  k  @    ß  Ù  Ø  ©  ¨  q  #  "      Ð  Ï  ~  L      ô  ó  ç  å  ä  Ä  ®  ›  š  x  T  S  /             my $base_path = my $full_path =      my $content = $args{'content'};     my $asset   = $args{'asset'};      my %args = @_;     my $self = shift; sub _replace_asset_references {  }     return;      $dest_file->spew($content);      $asset->{'dest_path'}     = $dest_file->stringify;     $asset->{'dest_rel_path'} = $target_rel_path;     my $target_rel_path = File::Spec->abs2rel( $dest_file, $self->output_path );      my $dest_file = Path::Class::File->new( $dest_dir, $dest_filename, );      #}      $dest_filename = sprintf( '%s-%s%s', $filename, $fingerprint, $suffix, );     #if ( $self->versionized_extensions->{$suffix} ) {      my $fingerprint = $asset->{'fingerprint'};      }           $self->calculate_fingerprint( 'data' => $content, );         $asset->{'fingerprint'} =     if ( $asset->{'dirty_fingerprint'} ) {      }         );             'content' => $content,             'asset'   => $asset,         $content = $self->_replace_asset_references(     if ( $asset->{'mime_type'} eq 'text/plain' ) {      );         'original_file' => $file,         'asset'         => $asset,     my $content = $self->_get_content(    #$l->debug( 'Getting file: ', { 'filter' => \&Dumper, 'value' => $file, }, );      $asset->{'mtime'} = $mtime;      }         $dest_dir->mkpath;     if ( !-d $dest_dir ) {      my $mtime = _file_mtime($file);     my $file  = Path::Class::File->new( $asset->{'full_path'}, );      my $dest_filename = $filename . $suffix;      my $dest_dir = Path::Class::Dir->new( $self->output_path, $dirs, );     my $suffix   = $asset->{'suffix'};     my $dirs     = $asset->{'dirs'};     my $filename = $asset->{'filename'};      my $rel_path = $asset->{'rel_path'};     my $asset     return;     $output_path->rmtree();     my $output_path = Path::Class::Dir->new( $self->output_path );     my $self = shift; sub clean_output {  }     return;     }         $self->_process_file($value);     for my $value ( $self->asset_cache_values ) {     $l->info( 'Copying ', $self->asset_cache_count, ' files', );      $self->clean_output();      my $aggregate_digest = $self->full_digest->hexdigest;      my $asset_cache = $self->asset_cache;     # Make sure cache is initialized before full_digest request      my %args = @_;     my $self = shift; sub copy_files {  }     return \%file_cache;     find( $wanted, $self->base_path, );     };         $file_cache{ $res->{'rel_path'} } = $res;         }             return;         if ( !$res ) {         my $res       = $self->_metadata_from_file($full_path);         my $full_path = $File::Find::name;     my $wanted = sub {     my %file_cache;      my %args = @_;     my $self = shift; sub find_files {  }     };         'dirs'        => $dirs,         'filename'    => $filename,         'suffix'      => $suffix,         'mime_type'   => $mime_type,         'mtime'       => 0,         'fingerprint' => $fingerprint,         'rel_path'    => $rel_path,         'full_path'   => $full_path,     return {     $self->full_digest->add( $rel_path, $fingerprint, );      }         return;     if ( $suffix =~ /$ignored_suffixes/ ) {     my $ignored_suffixes = '\.map$';        File::Basename::fileparse( $rel_path, qr/(\.[^.]*?){1,2}/ );     my ( $filename, $dirs, $suffix ) =      my $mime_type   = $ft->checktype_filename( $file->absolute );     my $ft          = File::MMagic->new();     my $fingerprint = $self->calculate_fingerprint( 'file' => $file, );      my $rel_path = File::Spec->abs2rel( $file, $self->base_path );     my $file = Path::Class::File->new($full_path); ad     [     �       È  Ç  ¯  ™  c  E  ü  û  É  ’  ‘  f  (  '  ö  õ  Ê  ¸  ®  ­  �  N  C  =  <            Ý  ¾  n  m  P  
    Ñ  �  k  ,  +    À
  –
  �
  �
  x
  M
  
  ç	  á	  à	  Ë	  É	  È	  µ	  Ÿ	  Œ	  ‹	  c	  3	  2	  	  	  é  Ï  É  È  ¶  µ  ‰  ^  $      ò  Ç  †  €    \  Z  Y  B  ,      ð  î  í  Ó  ¼  ¥  £  ¢  ‘  p  O  N    ð  Ù  Ó  Ò  œ  d  c  E  -  ä  «  ’  ‘  t  `  V  U  /  ð  ê  é  Ö  Ô  Ó  Ã  ¢  �  €  K  6  5  	  è  â  á  ¦  •  “  ’  „  ƒ  \  [          Dinis Lage, C<< <dlage at cpan.org> >>  =head1 AUTHOR  }     return $uri;     my $uri = $self->base_url . $asset->{'dest_rel_path'};      }         return $asset_requested;         # TODO Asset not found... log error      if ( !$asset ) {     my $asset = $self->_get_asset($asset_requested);      my $asset_requested = shift;     my $self            = shift; sub asset_url {  }     return $asset;      }         $self->asset_cache->{ $asset->{'rel_path'} } = $asset;         $self->_process_file($asset);          }             return;             # File not found          if ( !$asset ) {         $asset = $self->_metadata_from_file($full_path);           Path::Class::File->new( $self->base_path, $asset_requested, );         my $full_path =         # Treat as a new file      if ( !$asset or ( $mtime != $asset->{'mtime'} ) ) {     my $mtime = _file_mtime( $asset->{'full_path'} );      }         return $asset;     if ( !$self->development_mode ) {     my $asset = $self->asset_cache->{$asset_requested};      my $asset_requested = shift;     my $self            = shift; sub _get_asset {  }     my $asset = shift;     my $self  = shift; sub _check_refresh_file {  }     my $asset         = $args{'asset'};      my %args = @_;     my $self = shift; sub _run_precompiler {  }     return $minified || $original;      }         $minified = JavaScript::Minifier::XS::minify($original);         $asset->{'dirty_fingerprint'} = 1;     if ( $asset->{'suffix'} =~ /\.js$/ ) {      }         $minified = CSS::Minifier::XS::minify($original);         $asset->{'dirty_fingerprint'} = 1;     if ( $asset->{'suffix'} =~ /\.css$/ ) {      my $minified;      }         return $original;     if ( !$self->minify ) {      my $original = $original_file->slurp();      my $original_file = $args{'original_file'};     my $asset         = $args{'asset'};      my %args = @_;     my $self = shift; sub _get_content {  }     return $content;      }             $asset->{'full_path'}, );         $l->debug( 'Made ', $total_subs, ' changes in asset: ',         $asset->{'dirty_fingerprint'} = 1;     if ($total_subs) {      }             $count_changes, ' times.', );         $l->debug( 'Changed "', $from_str, '" to "', $to_str, '" ',         $total_subs += $count_changes;          my $count_changes = $content =~ s/$from_str/$to_str/g;         my $to_str        = $replacement->{'to'};         my $from_str      = $replacement->{'from'};     for my $replacement (@ordered_replacements) {     );         { 'filter' => \&Dumper, 'value' => \@ordered_replacements, },     $l->debug( 'Dump var: ',        sort { length( $b->{'from'} ) <=> length( $a->{'from'} ) } @replacements;     my @ordered_replacements =     # Replace bigger matches first      }         return $content;     if ( !@replacements ) {      }         );             { 'from' => $rel_path_to_ref, 'to' => $target_ref, },         push( @replacements,          }             next;             # No replacements to make here          if ( $content !~ m/$rel_path_to_ref/ ) {          $target_ref =~ s/$suffix$/-${fingerprint}${suffix}/g;         my $target_ref = $rel_path_to_ref;          my $fingerprint = $asset_ref->{'fingerprint'};         my $suffix      = $asset_ref->{'suffix'};            File::Spec->abs2rel( $asset_ref->{'full_path'}, $base_path, );         my $rel_path_to_ref =     for my $asset_ref ( $self->asset_cache_values ) {     my @replacements;     my $total_subs = 0;        File::Basename::dirname( $asset->{'full_path'} ); 