Hello community, here is the log from the commit of package perl-Mojolicious-Plugin-AssetPack for openSUSE:Factory checked in at 2017-01-16 11:14:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Mojolicious-Plugin-AssetPack (Old) and /work/SRC/openSUSE:Factory/.perl-Mojolicious-Plugin-AssetPack.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-Mojolicious-Plugin-AssetPack" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Mojolicious-Plugin-AssetPack/perl-Mojolicious-Plugin-AssetPack.changes 2017-01-11 12:05:08.029764526 +0100 +++ /work/SRC/openSUSE:Factory/.perl-Mojolicious-Plugin-AssetPack.new/perl-Mojolicious-Plugin-AssetPack.changes 2017-01-16 11:14:53.621105841 +0100 @@ -1,0 +2,23 @@ +Wed Jan 11 11:32:58 UTC 2017 - coolo@suse.com + +- updated to 1.36 + see /usr/share/doc/packages/perl-Mojolicious-Plugin-AssetPack/Changes + + 1.36 2017-01-11T11:18:45+0100 + - Fix bug in Fetch pipe, fixing t/font-awesome.t + - Change Mojolicious::Plugin::AssetPack::Asset::path() to return a Mojo::File object + + 1.35 2017-01-11T10:30:09+0100 + - Forgot to remove Carp::Always from t/recreate.t after debugging + + 1.34 2017-01-10T23:22:16+0100 + - Compatible with Mojolicious 7.15 + + 1.33 2017-01-08T14:20:03+0100 + - Fix t/reloader.t when CSS::Minifier::XS is missing #113 + + 1.32 2017-01-08T11:50:36+0100 + - Fix Mojo::Home::rel_dir is DEPRECATED in favor of Mojo::Hom::rel_file #112 + - Disable "Reloader" pipe, unless in development + +------------------------------------------------------------------- Old: ---- Mojolicious-Plugin-AssetPack-1.31.tar.gz New: ---- Mojolicious-Plugin-AssetPack-1.36.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Mojolicious-Plugin-AssetPack.spec ++++++ --- /var/tmp/diff_new_pack.fX0DRr/_old 2017-01-16 11:14:54.380998107 +0100 +++ /var/tmp/diff_new_pack.fX0DRr/_new 2017-01-16 11:14:54.384997540 +0100 @@ -17,7 +17,7 @@ Name: perl-Mojolicious-Plugin-AssetPack -Version: 1.31 +Version: 1.36 Release: 0 %define cpan_name Mojolicious-Plugin-AssetPack Summary: Compress and convert css, less, sass, javascript and coffeescript files @@ -32,11 +32,11 @@ BuildRequires: perl-macros BuildRequires: perl(File::Which) >= 1.21 BuildRequires: perl(IPC::Run3) >= 0.048 -BuildRequires: perl(Mojolicious) >= 6.50 +BuildRequires: perl(Mojolicious) >= 7.17 BuildRequires: perl(Test::More) >= 0.88 Requires: perl(File::Which) >= 1.21 Requires: perl(IPC::Run3) >= 0.048 -Requires: perl(Mojolicious) >= 6.50 +Requires: perl(Mojolicious) >= 7.17 %{perl_requires} %description ++++++ Mojolicious-Plugin-AssetPack-1.31.tar.gz -> Mojolicious-Plugin-AssetPack-1.36.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/.travis.yml new/Mojolicious-Plugin-AssetPack-1.36/.travis.yml --- old/Mojolicious-Plugin-AssetPack-1.31/.travis.yml 2016-09-11 16:27:11.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/.travis.yml 2017-01-10 23:20:45.000000000 +0100 @@ -8,7 +8,7 @@ packages: - libpng12-dev env: - - 'HARNESS_OPTIONS=j1 TEST_ONLINE=1' + - 'HARNESS_OPTIONS=j1 TEST_ONLINE=1 TEST_RELOADER=1' install: - 'cpanm -n Test::Pod Test::Pod::Coverage IO::Socket::SSL' - 'cpanm -n CSS::Minifier::XS Imager::File::PNG JavaScript::Minifier::XS' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/Changes new/Mojolicious-Plugin-AssetPack-1.36/Changes --- old/Mojolicious-Plugin-AssetPack-1.31/Changes 2017-01-04 14:19:34.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/Changes 2017-01-11 11:18:45.000000000 +0100 @@ -1,5 +1,22 @@ Revision history for perl distribution Mojolicious-Plugin-AssetPack +1.36 2017-01-11T11:18:45+0100 + - Fix bug in Fetch pipe, fixing t/font-awesome.t + - Change Mojolicious::Plugin::AssetPack::Asset::path() to return a Mojo::File object + +1.35 2017-01-11T10:30:09+0100 + - Forgot to remove Carp::Always from t/recreate.t after debugging + +1.34 2017-01-10T23:22:16+0100 + - Compatible with Mojolicious 7.15 + +1.33 2017-01-08T14:20:03+0100 + - Fix t/reloader.t when CSS::Minifier::XS is missing #113 + +1.32 2017-01-08T11:50:36+0100 + - Fix Mojo::Home::rel_dir is DEPRECATED in favor of Mojo::Hom::rel_file #112 + - Disable "Reloader" pipe, unless in development + 1.31 2017-01-04T14:19:34+0100 - Fix generating favicons once with MOJO_ASSETPACK_LAZY - Made Reloader call process() later diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/META.json new/Mojolicious-Plugin-AssetPack-1.36/META.json --- old/Mojolicious-Plugin-AssetPack-1.31/META.json 2017-01-04 14:19:35.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/META.json 2017-01-11 11:18:46.000000000 +0100 @@ -34,7 +34,7 @@ "requires" : { "File::Which" : "1.21", "IPC::Run3" : "0.048", - "Mojolicious" : "6.50" + "Mojolicious" : "7.17" } } }, @@ -48,6 +48,6 @@ "url" : "https://github.com/jhthorsen/mojolicious-plugin-assetpack.git" } }, - "version" : "1.31", + "version" : "1.36", "x_serialization_backend" : "JSON::PP version 2.27300" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/META.yml new/Mojolicious-Plugin-AssetPack-1.36/META.yml --- old/Mojolicious-Plugin-AssetPack-1.31/META.yml 2017-01-04 14:19:35.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/META.yml 2017-01-11 11:18:46.000000000 +0100 @@ -20,10 +20,10 @@ requires: File::Which: '1.21' IPC::Run3: '0.048' - Mojolicious: '6.50' + Mojolicious: '7.17' resources: bugtracker: https://github.com/jhthorsen/mojolicious-plugin-assetpack/issues homepage: https://github.com/jhthorsen/mojolicious-plugin-assetpack repository: https://github.com/jhthorsen/mojolicious-plugin-assetpack.git -version: '1.31' +version: '1.36' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/Makefile.PL new/Mojolicious-Plugin-AssetPack-1.36/Makefile.PL --- old/Mojolicious-Plugin-AssetPack-1.31/Makefile.PL 2017-01-04 14:19:34.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/Makefile.PL 2017-01-11 11:18:45.000000000 +0100 @@ -21,7 +21,7 @@ PREREQ_PM => { 'File::Which' => '1.21', 'IPC::Run3' => '0.048', - 'Mojolicious' => '6.50' + 'Mojolicious' => '7.17' } , test => {TESTS => (-e 'META.yml' ? 't/*.t' : 't/*.t xt/*.t')}, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/README new/Mojolicious-Plugin-AssetPack-1.36/README --- old/Mojolicious-Plugin-AssetPack-1.31/README 2017-01-04 14:19:34.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/README 2017-01-11 11:18:45.000000000 +0100 @@ -3,7 +3,7 @@ javascript and coffeescript files VERSION - 1.31 + 1.36 SYNOPSIS Application @@ -81,7 +81,7 @@ Set this environment variable if you want to delay processing the assets until they are requested. This can be very useful while - developing, and the assets are changed frequently. + developing when the assets are changed frequently. OPTIONAL MODULES There are some optional modules you might want to install: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/cpanfile new/Mojolicious-Plugin-AssetPack-1.36/cpanfile --- old/Mojolicious-Plugin-AssetPack-1.31/cpanfile 2016-08-10 19:06:48.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/cpanfile 2017-01-11 11:16:59.000000000 +0100 @@ -1,5 +1,5 @@ # You can install this projct with curl -L http://cpanmin.us | perl - https://github.com/jhthorsen/mojolicious-plugin-assetpack/archive/master.tar... -requires "Mojolicious" => "6.50"; +requires "Mojolicious" => "7.17"; requires "IPC::Run3" => "0.048"; # required in old code diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Asset.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Asset.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Asset.pm 2016-12-23 02:10:42.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Asset.pm 2017-01-11 11:16:59.000000000 +0100 @@ -3,6 +3,7 @@ use Mojo::Asset::Memory; use Mojo::URL; +use Mojo::File; use Mojo::Util 'deprecated'; use Mojolicious::Plugin::AssetPack::Util qw(diag has_ro DEBUG); @@ -55,7 +56,7 @@ my $orig = $self->_asset; my $clone = $orig->new; - if ($orig->can('path')) { + if ($orig->is_file) { $clone->cleanup(0)->path($orig->path); } else { @@ -84,7 +85,10 @@ sub get_chunk { deprecated 'get_chunk() is deprecated'; shift->_asset->get_chunk(@_) } sub is_range { deprecated 'is_range() is deprecated'; shift->_asset->is_range } sub mtime { deprecated 'mtime() is deprecated'; shift->_asset->mtime } -sub path { $_[0]->_asset->isa('Mojo::Asset::File') ? $_[0]->_asset->path : '' } + +sub path { + $_[0]->_asset->isa('Mojo::Asset::File') ? Mojo::File->new($_[0]->_asset->path) : undef; +} sub size { $_[0]->_asset->size } sub start_range { @@ -189,7 +193,8 @@ $str = $self->path; -Returns the path to the asset, if it exists on disk. +Returns a L<Mojo::File> object that holds the location to the asset on disk or +C<undef> if this asset is in memory. =head2 size diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Less.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Less.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Less.pm 2016-06-21 20:09:34.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Less.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,7 +1,6 @@ package Mojolicious::Plugin::AssetPack::Pipe::Less; use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; use Mojolicious::Plugin::AssetPack::Util qw(diag $CWD DEBUG); -use File::Basename 'dirname'; sub process { my ($self, $assets) = @_; @@ -19,7 +18,7 @@ my @args = qw(lessc --no-color); my $file = $asset->path ? $asset : Mojo::Asset::File->new->add_chunk($asset->content); - push @args, '--include-path='.dirname($asset->path) if $asset->path; + push @args, '--include-path=' . $asset->path->dirname if $asset->path; push @args, $file->path; $self->run(\@args, undef, \my $css); $asset->content($store->save(\$css, $attrs))->FROM_JSON($attrs); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Reloader.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Reloader.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Reloader.pm 2017-01-04 14:18:24.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Reloader.pm 2017-01-11 11:17:51.000000000 +0100 @@ -2,16 +2,27 @@ use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; use Mojo::Loader (); +has enabled => sub { + return $ENV{MOJO_ASSETPACK_LAZY} || shift->app->mode eq 'development'; +}; + has _files => sub { +{} }; +sub after_process { + my ($self, $assets) = @_; + $self->_files->{$_} = 1 + for grep {$_} map { ($_->path, @{$_->{dependencies} || []}) } @$assets; +} + sub before_process { my ($self, $assets) = @_; - $self->_files->{$_} = 1 for map { ($_->path, @{$_->{dependencies} || []}) } @$assets; + $self->_files->{$_} = 1 + for grep {$_} map { ($_->path, @{$_->{dependencies} || []}) } @$assets; } sub new { my $self = shift->SUPER::new(@_); - + return $self unless $self->enabled; push @{$self->assetpack->store->classes}, __PACKAGE__; $self->assetpack->{lazy} = 1; $self->_add_route; @@ -20,6 +31,7 @@ sub process { my $self = shift; + return unless $self->enabled; return if $self->{processed}++; # Cannot call assetpack->process() in new(), since it will initialize and start building @@ -89,14 +101,33 @@ the browser when one of the assets change on disk. This is done without the need of L<morbo|Mojo::Server::Morbo>. +This pipe should be loaded last to enable it to watch all input assets. + This feature is EXPERIMENTAL, UNSTABLE and only meant to be used while developing. +=head1 ATTRIBUTES + +=head2 enabled + + $bool = $self->enabled; + +This pipe is only enabled if either +L<Mojolicious::Plugin::AssetPack/MOJO_ASSETPACK_LAZY> is +set or L<Mojolicious/mode> is "development". + =head1 METHODS +=head2 after_process + +This method will look for all the input assets and dependencies and add them to +a list of watched files. + +See L<Mojolicious::Plugin::AssetPack::Pipe/after_process>. + =head2 before_process -See L<Mojolicious::Plugin::AssetPack::Pipe/before_process>. +See L</after_process> and L<Mojolicious::Plugin::AssetPack::Pipe/before_process>. =head2 new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Riotjs.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Riotjs.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Riotjs.pm 2016-08-19 14:57:56.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Riotjs.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,15 +1,14 @@ package Mojolicious::Plugin::AssetPack::Pipe::Riotjs; use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; + +use Mojo::File 'path'; use Mojolicious::Plugin::AssetPack::Util qw(diag $CWD DEBUG); -use File::Basename 'dirname'; use Cwd (); has _riotjs => sub { my $self = shift; - return [ - $self->_find_app([qw(nodejs node)]), - Cwd::abs_path(File::Spec->catfile(dirname(__FILE__), 'riot.js')), + return [$self->_find_app([qw(nodejs node)]), path(__FILE__)->dirname->child('riot.js'), ]; }; @@ -27,7 +26,7 @@ return unless $asset->format eq 'tag'; return $asset->content($file)->FROM_JSON($attrs) if $file = $store->load($attrs); local $CWD = $self->app->home->to_string; - local $ENV{NODE_PATH} = $self->app->home->rel_dir('node_modules'); + local $ENV{NODE_PATH} = $self->app->home->rel_file('node_modules'); $self->run([qw(riot --version)], undef, \undef) unless $self->{installed}++; $self->run($self->_riotjs, \$asset->content, \my $js); $asset->content($store->save(\$js, $attrs))->FROM_JSON($attrs); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm 2016-12-16 09:41:25.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,7 +1,6 @@ package Mojolicious::Plugin::AssetPack::Pipe::Sass; use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; use Mojolicious::Plugin::AssetPack::Util qw(checksum diag dumper load_module DEBUG); -use File::Basename 'dirname'; use Mojo::Util; my $FORMAT_RE = qr{^s[ac]ss$}; @@ -35,7 +34,7 @@ return $asset->content($file)->FROM_JSON($attrs) if $file = $store->load($attrs); return if $asset->isa('Mojolicious::Plugin::AssetPack::Asset::Null'); - $opts{include_paths}[0] = $asset->path ? dirname $asset->path : undef; + $opts{include_paths}[0] = $asset->path ? $asset->path->dirname : undef; $opts{include_paths} = [grep {$_} @{$opts{include_paths}}]; diag 'Process "%s" with checksum %s.', $asset->url, $attrs->{checksum} if DEBUG; @@ -103,13 +102,18 @@ return checksum join ':', @c; } -sub _include_path { $_[0]->url =~ m!^https?://! ? $_[0]->url : dirname $_[0]->path } +sub _include_path { + my $asset = shift; + return $asset->url if $asset->url =~ m!^https?://!; + return $asset->path->dirname if $asset->path; + return ''; +} sub _install_sass { my $self = shift; $self->run([qw(ruby -rubygems -e), 'puts Gem.user_dir'], undef, \my $base); chomp $base; - my $path = File::Spec->catfile($base, qw(bin sass)); + my $path = path($base, qw(bin sass)); return $path if -e $path; $self->app->log->warn( 'Installing sass... Please wait. (gem install --user-install sass)'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/TypeScript.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/TypeScript.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe/TypeScript.pm 2016-08-19 15:03:40.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe/TypeScript.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,7 +1,7 @@ package Mojolicious::Plugin::AssetPack::Pipe::TypeScript; use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe'; -use File::Basename 'dirname'; +use Mojo::File 'path'; use Mojolicious::Plugin::AssetPack::Util qw(diag $CWD DEBUG); has _typescript => sub { @@ -9,7 +9,7 @@ return [ $self->_find_app([qw(nodejs node)]), - Cwd::abs_path(File::Spec->catfile(dirname(__FILE__), 'typescript.js')), + path(__FILE__)->dirname->child('typescript.js')->to_abs, ]; }; @@ -29,7 +29,7 @@ $self->_install_typescript unless $self->{installed}++; local $CWD = $self->app->home->to_string; - local $ENV{NODE_PATH} = $self->app->home->rel_dir('node_modules'); + local $ENV{NODE_PATH} = $self->app->home->rel_file('node_modules'); $self->run($self->_typescript, \$asset->content, \my $js); $asset->content($store->save(\$js, $attrs))->FROM_JSON($attrs); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Pipe.pm 2016-08-19 15:03:41.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Pipe.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,11 +1,10 @@ package Mojolicious::Plugin::AssetPack::Pipe; use Mojo::Base -base; -use Mojo::Util; +use Mojo::File 'path'; use Mojolicious::Plugin::AssetPack::Asset; use Mojolicious::Plugin::AssetPack::Util qw(diag has_ro DEBUG); -use File::Basename (); -use File::Temp (); -use IPC::Run3 (); +use File::Temp (); +use IPC::Run3 (); use List::Util 'first'; $ENV{PATH} ||= ''; @@ -17,7 +16,7 @@ sub run { my ($self, $cmd, @args) = @_; - my $name = File::Basename::basename($cmd->[0]); + my $name = path($cmd->[0])->basename; local $cmd->[0] = $self->_find_app($name, $cmd->[0]); die qq(@{[ref $self]} was unable to locate the "$name" application.) unless $cmd->[0]; diag '$ %s', join ' ', @$cmd if DEBUG > 1; @@ -32,7 +31,7 @@ sub _find_app { my ($self, $apps, $path) = @_; - return $path if $path and File::Spec->file_name_is_absolute($path); + return $path if $path and path($path)->is_abs; $apps = [$apps] unless ref $apps eq 'ARRAY'; for my $name (@$apps) { @@ -42,7 +41,7 @@ return $self->{apps}{$name} if $self->{apps}{$name}; # Already found diag 'Looking for "%s" in $PATH.', $name if DEBUG > 1; - $path = first {-e} map { File::Spec->catfile($_, $name) } File::Spec->path; + $path = first {-e} map { path($_, $name) } File::Spec->path; return $self->{apps}{$name} = $path if $path; # Found in $PATH } @@ -77,7 +76,7 @@ if ($tmp) { $self->run([$self->app, @args]); - $output = Mojo::Util::slurp("$tmp"); + $output = path($tmp)->slurp; } else { $self->run([$self->app, @args], \$asset->content, \$output); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Store.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Store.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Store.pm 2016-12-23 02:10:42.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Store.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,12 +1,10 @@ package Mojolicious::Plugin::AssetPack::Store; use Mojo::Base 'Mojolicious::Static'; -use Mojo::Util 'spurt'; +use Mojo::File 'path'; use Mojo::URL; use Mojolicious::Types; use Mojolicious::Plugin::AssetPack::Asset; use Mojolicious::Plugin::AssetPack::Util qw(diag checksum has_ro DEBUG); -use File::Basename 'dirname'; -use File::Path 'make_path'; # MOJO_ASSETPACK_DB_FILE is used in tests use constant DB_FILE_NAME => $ENV{MOJO_ASSETPACK_DB_FILE} || 'assetpack.db'; @@ -87,17 +85,17 @@ sub save { my ($self, $ref, $attrs) = @_; - my $path = File::Spec->catfile($self->paths->[0], $self->_cache_path($attrs)); - my $dir = dirname $path; + my $path = path($self->paths->[0], $self->_cache_path($attrs)); + my $dir = $path->dirname; # Do not care if this fail. Can fallback to temp files. - mkdir $dir if !-d $dir and -w dirname $dir; + mkdir $dir if !-d $dir and -w $dir->dirname; diag 'Save "%s" = %s', $path, -d $dir ? 1 : 0 if DEBUG; return Mojolicious::Plugin::AssetPack::Asset->new(%$attrs, content => $$ref) unless -w $dir; $self->_db_set($attrs); - spurt $$ref, $path; + $path->spurt($$ref); return Mojolicious::Plugin::AssetPack::Asset->new(%$attrs, path => $path); } @@ -207,10 +205,10 @@ } if ($url->host ne 'local') { - $path = File::Spec->catdir($self->paths->[0], split '/', $rel); + $path = path($self->paths->[0], split '/', $rel); $self->ua->server->app->log->info(qq(Caching "$req_url" to "$path".)); - make_path(dirname $path) unless -d dirname $path; - spurt $tx->res->body, $path; + $path->dirname->make_path unless -d $path->dirname; + $path->spurt($tx->res->body); } if (my $lm = $h->last_modified) { @@ -222,7 +220,7 @@ } $attrs->{format} ||= $tx->req->url->path->[-1] =~ /\.(\w+)$/ ? $1 : undef; - @$attrs{qw(key rel url)} = ('original', $rel, $url->to_string); + @$attrs{qw(key rel url)} = ('original', $rel, $url); $self->_db_set($attrs); return Mojolicious::Plugin::AssetPack::Asset->new(%$attrs, path => $path) if $path; return Mojolicious::Plugin::AssetPack::Asset->new(%$attrs)->content($tx->res->body); @@ -230,7 +228,7 @@ sub _files { my ($self, $name, $check) = @_; - my @files = map { File::Spec->catfile($_, split '/', $name) } @{$self->paths}; + my @files = map { path($_, split '/', $name) } @{$self->paths}; return [grep $check, @files] if $check; return \@files; } @@ -269,12 +267,12 @@ # Change where assets can be found app->asset->store->paths([ - app->home->rel_dir("some/directory"), + app->home->rel_file("some/directory"), "/some/other/directory", ]); # Change where assets are stored - app->asset->store->paths->[0] = app->home->rel_dir("some/directory"); + app->asset->store->paths->[0] = app->home->rel_file("some/directory"); # Define asset app->asset->process($moniker => @assets); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Util.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Util.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack/Util.pm 2016-04-02 21:25:43.000000000 +0200 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack/Util.pm 2017-01-11 11:16:59.000000000 +0100 @@ -1,7 +1,6 @@ package Mojolicious::Plugin::AssetPack::Util; use Mojo::Base 'Exporter'; use Mojo::Util; -use File::Spec; use constant DEBUG => $ENV{MOJO_ASSETPACK_DEBUG} || 0; use constant TESTING => $ENV{HARNESS_IS_VERBOSE} || 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack.pm new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack.pm --- old/Mojolicious-Plugin-AssetPack-1.31/lib/Mojolicious/Plugin/AssetPack.pm 2017-01-04 14:19:34.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/lib/Mojolicious/Plugin/AssetPack.pm 2017-01-11 11:18:45.000000000 +0100 @@ -6,7 +6,7 @@ use Mojolicious::Plugin::AssetPack::Store; use Mojolicious::Plugin::AssetPack::Util qw(diag has_ro load_module DEBUG); -our $VERSION = '1.31'; +our $VERSION = '1.36'; my %TAG_TEMPLATE; $TAG_TEMPLATE{css} = [qw(link rel stylesheet href)]; @@ -26,7 +26,7 @@ my $self = shift; Mojolicious::Plugin::AssetPack::Store->new( classes => [@{$self->_app->static->classes}], - paths => [$self->_app->home->rel_dir('assets')], + paths => [$self->_app->home->rel_file('assets')], ua => $self->ua, ); }; @@ -130,7 +130,6 @@ sub _pipes { my ($self, $names) = @_; - unshift @$names, 'Reloader' if $ENV{MOJO_ASSETPACK_RELOADER}; # experimental $self->{pipes} = [ map { @@ -152,8 +151,7 @@ for my $asset (@$assets) { if (my $prev = $self->{by_topic}{$topic}) { - delete $self->{by_checksum}{$_->checksum} for @$prev; - delete $asset->{$_} for qw(checksum format mtime); + delete $asset->{$_} for qw(checksum format); $asset->content($self->store->asset($asset->url)); } $asset->checksum; @@ -165,7 +163,7 @@ local $pipe->{topic} = $topic; diag '%s->%s("%s")', ref $pipe, $method, $topic if DEBUG; $pipe->$method($assets); - push @{$self->{asset_paths}}, $_->path for @$assets; + push @{$self->{asset_paths}}, $_->path->to_string for grep { $_->path } @$assets; } } @@ -279,7 +277,7 @@ =head1 VERSION -1.31 +1.36 =head1 SYNOPSIS @@ -366,7 +364,7 @@ =item * MOJO_ASSETPACK_LAZY Set this environment variable if you want to delay processing the assets until -they are requested. This can be very useful while developing, and the assets +they are requested. This can be very useful while developing when the assets are changed frequently. =back diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/t/Helper.pm new/Mojolicious-Plugin-AssetPack-1.36/t/Helper.pm --- old/Mojolicious-Plugin-AssetPack-1.31/t/Helper.pm 2016-12-15 22:17:52.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/t/Helper.pm 2017-01-10 23:05:38.000000000 +0100 @@ -18,8 +18,8 @@ $ENV{MOJO_ASSETPACK_CLEANUP} //= 1; # remove generated assets $ENV{MOJO_ASSETPACK_DB_FILE} = sprintf '%s.db', basename $0; + ${$app->home} = Cwd::abs_path(dirname __FILE__); delete $app->log->{$_} for qw(handle path); - $app->home->parse(Cwd::abs_path(dirname __FILE__)); $app->routes->get('/' => 'index'); $app->plugin(AssetPack => $args); return Test::Mojo->new($app); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/t/lazy.t new/Mojolicious-Plugin-AssetPack-1.36/t/lazy.t --- old/Mojolicious-Plugin-AssetPack-1.31/t/lazy.t 2016-12-23 02:10:42.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/t/lazy.t 2017-01-11 11:16:57.000000000 +0100 @@ -22,7 +22,11 @@ ->element_exists(qq(link[href="/asset/0dfb452e32/sass-two.css"])) ->element_exists_not(qq(link[href="/asset/9f0d8f784a/sass-two.css"])); -$t->get_ok('/asset/9f0d8f784a/sass-two.css')->status_is(404); +{ + local $TODO = 'Not sure if we need to clear out old checksums'; + $t->get_ok('/asset/9f0d8f784a/sass-two.css')->status_is(404); +} + $t->get_ok('/asset/0dfb452e32/sass-two.css')->status_is(200) ->content_like(qr{body\W+background:\s*black}s); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/t/recreate.t new/Mojolicious-Plugin-AssetPack-1.36/t/recreate.t --- old/Mojolicious-Plugin-AssetPack-1.31/t/recreate.t 2016-11-14 19:55:19.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/t/recreate.t 2017-01-11 10:30:24.000000000 +0100 @@ -1,6 +1,7 @@ BEGIN { $ENV{MOJO_MODE} = 'not_development' } use lib '.'; use t::Helper; +use Mojo::File 'path'; use Mojo::Loader 'data_section'; use Mojolicious::Plugin::AssetPack::Util 'checksum'; @@ -11,16 +12,11 @@ $INC{'CSS/Minifier/XS.pm'} = 'mocked'; *CSS::Minifier::XS::minify = sub { local $_ = shift; s!\s+!!g; $_ }; -my $t = t::Helper->t(pipes => [qw(Css Combine)]); -my @assets = qw(one.css recreate.css); -my $recreate_path = File::Spec->catfile(qw(t assets recreate.css)); - -Mojo::Util::spurt ".recreate { color: #aaa }\n" => $recreate_path; - -# Add support for merging assetpack.db files -unshift @{$t->app->asset->store->paths}, - $t->app->home->parse( - File::Spec->catdir(Cwd::abs_path(File::Basename::dirname(__FILE__)), 'no-such-dir')); +my $t = t::Helper->t(pipes => [qw(Css Combine)]); +my @assets = qw(one.css recreate.css); +my $recreate = path(qw(t assets recreate.css)); + +$recreate->spurt(".recreate { color: #aaa }\n"); $t->app->asset->process('app.css' => @assets); @@ -34,7 +30,7 @@ is $t->tx->res->dom->at('link')->{href}, $link, 'same link href'; # recreate -Mojo::Util::spurt ".recreate { color: #bbb }\n" => $recreate_path; +$recreate->spurt(".recreate { color: #bbb }\n"); my $tr = t::Helper->t(pipes => [qw(Css Combine)]); $tr->app->asset->process('app.css' => @assets); $tr->get_ok('/')->status_is(200); @@ -43,7 +39,7 @@ ->content_like(qr{color:\#bbb}); # reset asset -Mojo::Util::spurt ".recreate { color: #aaa }\n" => $recreate_path; +$recreate->spurt(".recreate { color: #aaa }\n"); $ENV{MOJO_ASSETPACK_CLEANUP} = 1; done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/t/reloader-process.t new/Mojolicious-Plugin-AssetPack-1.36/t/reloader-process.t --- old/Mojolicious-Plugin-AssetPack-1.31/t/reloader-process.t 2016-12-23 03:11:14.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/t/reloader-process.t 2017-01-10 23:20:50.000000000 +0100 @@ -1,5 +1,7 @@ use lib '.'; use t::Helper; + +plan skip_all => 'TEST_RELOADER=1' unless $ENV{TEST_RELOADER} or -e '.test-everything'; plan skip_all => 'cpanm CSS::Sass' unless eval 'use CSS::Sass 3.3.0;1'; my $file = Mojo::Asset::File->new(path => 't/assets/t-reloader.scss'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-1.31/t/reloader.t new/Mojolicious-Plugin-AssetPack-1.36/t/reloader.t --- old/Mojolicious-Plugin-AssetPack-1.31/t/reloader.t 2016-12-23 03:06:50.000000000 +0100 +++ new/Mojolicious-Plugin-AssetPack-1.36/t/reloader.t 2017-01-10 23:20:50.000000000 +0100 @@ -1,12 +1,15 @@ -BEGIN { $ENV{MOJO_ASSETPACK_RELOADER} = 1 } use lib '.'; use t::Helper; +plan skip_all => 'TEST_RELOADER=1' unless $ENV{TEST_RELOADER} or -e '.test-everything'; + my $file = Mojo::Asset::File->new(path => 't/assets/t-reloader.css'); eval { $file->add_chunk("body{color:#000;}\n") } or plan skip_all => "t-reloader.css: $!"; -my $t = t::Helper->t(pipes => [qw(Css Combine)]); +my $t = t::Helper->t(pipes => [qw(Css Combine Reloader)]); my $asset = $t->app->asset->store->asset('t-reloader.css'); +ok $t->app->asset->pipe('Reloader')->enabled, 'enabled'; + $t->app->asset->process('app.css' => $asset); $t->get_ok('/')->status_is(200) ->element_exists(qq(link[href="/asset/36b3e7b800/t-reloader.css"])); @@ -22,6 +25,20 @@ $t->get_ok($t->tx->res->dom->at('link')->{href}) ->content_is("body{color:#000;}\ndiv{color:#fff;}\n"); +if (eval 'require CSS::Minifier::XS;1') { + $ENV{MOJO_MODE} = 'whatever'; + $t = t::Helper->t(pipes => [qw(Css Combine Reloader)]); + ok !$t->app->asset->pipe('Reloader')->enabled, 'disabled'; + $t->app->asset->process('app.css' => $asset); + $t->get_ok('/')->status_is(200) + ->element_exists(qq(link[href="/asset/ee9b1ee297/app.css"])); + + $t->get_ok('/mojo-assetpack-reloader-ws')->status_is(404); + $file->add_chunk("div{color:#456;}\n"); + $t->get_ok('/')->status_is(200) + ->element_exists(qq(link[href="/asset/ee9b1ee297/app.css"])); +} + unlink $file->path; done_testing;