Hello community,
here is the log from the commit of package perl-Mojolicious-Plugin-AssetPack
for openSUSE:Factory checked in at 2015-08-10 09:16:30
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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
2015-06-11 08:22:53.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Mojolicious-Plugin-AssetPack.new/perl-Mojolicious-Plugin-AssetPack.changes
2015-08-10 09:16:32.000000000 +0200
@@ -1,0 +2,10 @@
+Sat Aug 8 08:49:11 UTC 2015 - [email protected]
+
+- updated to 0.56
+ see /usr/share/doc/packages/perl-Mojolicious-Plugin-AssetPack/Changes
+
+ 0.56 2015-08-05T10:44:15+0200
+ - Add purge() method (EXPERIMENTAL)
+ - Add support for wildcards in filenames (EXPERIMENTAL) #52
+
+-------------------------------------------------------------------
Old:
----
Mojolicious-Plugin-AssetPack-0.55.tar.gz
New:
----
Mojolicious-Plugin-AssetPack-0.56.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Mojolicious-Plugin-AssetPack.spec ++++++
--- /var/tmp/diff_new_pack.MkN9ol/_old 2015-08-10 09:16:33.000000000 +0200
+++ /var/tmp/diff_new_pack.MkN9ol/_new 2015-08-10 09:16:33.000000000 +0200
@@ -17,7 +17,7 @@
Name: perl-Mojolicious-Plugin-AssetPack
-Version: 0.55
+Version: 0.56
Release: 0
%define cpan_name Mojolicious-Plugin-AssetPack
Summary: Compress and convert css, less, sass, javascript and
coffeescript files
++++++ Mojolicious-Plugin-AssetPack-0.55.tar.gz ->
Mojolicious-Plugin-AssetPack-0.56.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/Changes
new/Mojolicious-Plugin-AssetPack-0.56/Changes
--- old/Mojolicious-Plugin-AssetPack-0.55/Changes 2015-05-25
12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/Changes 2015-08-05
10:44:15.000000000 +0200
@@ -1,5 +1,9 @@
Revision history for perl distribution Mojolicious-Plugin-AssetPack
+0.56 2015-08-05T10:44:15+0200
+ - Add purge() method (EXPERIMENTAL)
+ - Add support for wildcards in filenames (EXPERIMENTAL) #52
+
0.55 2015-05-25T12:58:04+0200
- Will not add memory asset route if not needed #56
- Make error visible regardless of page scroll position #57
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/MANIFEST
new/Mojolicious-Plugin-AssetPack-0.56/MANIFEST
--- old/Mojolicious-Plugin-AssetPack-0.55/MANIFEST 2015-05-25
12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/MANIFEST 2015-08-05
10:44:15.000000000 +0200
@@ -45,6 +45,7 @@
t/embedded-app.t
t/example-expand-src-url.t
t/example-fetch.t
+t/get-wildcard.t
t/get.t
t/Helper.pm
t/in-memory.t
@@ -59,6 +60,9 @@
t/online-google-font.t
t/online-jquery.t
t/plugin-with-assets.t
+t/public/css/1w.css
+t/public/css/2w.css
+t/public/css/5w.css
t/public/css/a.css
t/public/css/a.less
t/public/css/a.scss
@@ -85,6 +89,7 @@
t/public/sass/compass.scss
t/public/sass/x.scss
t/public/sass/y.scss
+t/purge.t
t/read-only-with-existing-assets/packed/my-plugin-existing-7c174b801d6fc968f1576055e88c18cb.css
t/read-only-with-source-assets/css/my-plugin-a.css
t/read-only-with-source-assets/css/my-plugin-b.css
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/META.json
new/Mojolicious-Plugin-AssetPack-0.56/META.json
--- old/Mojolicious-Plugin-AssetPack-0.55/META.json 2015-05-25
12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/META.json 2015-08-05
10:44:15.000000000 +0200
@@ -4,7 +4,7 @@
"Jan Henning Thorsen <[email protected]>"
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter
version 2.150001",
+ "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter
version 2.150001",
"license" : [
"artistic_2"
],
@@ -50,5 +50,5 @@
"url" :
"https://github.com/jhthorsen/mojolicious-plugin-assetpack.git"
}
},
- "version" : "0.55"
+ "version" : "0.56"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/META.yml
new/Mojolicious-Plugin-AssetPack-0.56/META.yml
--- old/Mojolicious-Plugin-AssetPack-0.55/META.yml 2015-05-25
12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/META.yml 2015-08-05
10:44:15.000000000 +0200
@@ -7,7 +7,7 @@
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version
2.150001'
+generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter
version 2.150001'
license: artistic_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -27,4 +27,4 @@
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: '0.55'
+version: '0.56'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/Makefile.PL
new/Mojolicious-Plugin-AssetPack-0.56/Makefile.PL
--- old/Mojolicious-Plugin-AssetPack-0.55/Makefile.PL 2015-05-25
12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/Makefile.PL 2015-08-05
10:44:15.000000000 +0200
@@ -26,5 +26,5 @@
'Mojolicious' => '5.41'
}
,
- test => {TESTS => (-e 'META.yml' ? 't/*.t' : 't/*.t xt/*.t')},
+ test => { TESTS => 't/*.t' },
);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/README
new/Mojolicious-Plugin-AssetPack-0.56/README
--- old/Mojolicious-Plugin-AssetPack-0.55/README 2015-05-25
12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/README 2015-08-05
10:44:15.000000000 +0200
@@ -3,7 +3,7 @@
javascript and coffeescript files
VERSION
- 0.55
+ 0.56
SYNOPSIS
Application
@@ -14,6 +14,7 @@
# define assets: $moniker => @real_assets
app->asset('app.js' => '/js/foo.js', '/js/bar.js', '/js/baz.coffee');
+ app->asset->purge; # remove old packed files
app->start;
See also Mojolicious::Plugin::AssetPack::Manual::Assets for more details
@@ -106,11 +107,6 @@
See also Mojolicious::Plugin::AssetPack::Manual::Modes.
- preprocessors
- $obj = $self->preprocessors;
-
- Holds a Mojolicious::Plugin::AssetPack::Preprocessors object.
-
out_dir
$str = $self->out_dir;
$app->plugin("AssetPack" => {out_dir => $str});
@@ -120,6 +116,11 @@
Defaults to empty string if no directory can be found, which again
results in keeping all packed files in memory.
+ preprocessors
+ $obj = $self->preprocessors;
+
+ Holds a Mojolicious::Plugin::AssetPack::Preprocessors object.
+
METHODS
add
$self->add($moniker => @real_files);
@@ -153,6 +154,16 @@
Mojolicious::Plugin::AssetPack::Preprocessor::Browserify for example
usage.
+ purge
+ $self = $self->purge({always => $bool});
+
+ Used to purge old packed files. This is useful if you want to avoid
+ filling up "out_dir" with many versions of the packed file.
+
+ "always" default to true if in "development" mode and false otherwise.
+
+ This method is EXPERIMENTAL and can change, be removed at any time.
+
register
plugin AssetPack => {
base_url => $str, # default to "/packed"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-0.55/lib/Mojolicious/Plugin/AssetPack/Manual/Assets.pod
new/Mojolicious-Plugin-AssetPack-0.56/lib/Mojolicious/Plugin/AssetPack/Manual/Assets.pod
---
old/Mojolicious-Plugin-AssetPack-0.55/lib/Mojolicious/Plugin/AssetPack/Manual/Assets.pod
2015-05-25 12:38:23.000000000 +0200
+++
new/Mojolicious-Plugin-AssetPack-0.56/lib/Mojolicious/Plugin/AssetPack/Manual/Assets.pod
2015-08-05 10:36:43.000000000 +0200
@@ -63,6 +63,25 @@
The above "/dynamic-path/foo.css" will be fetched from the current C<app>
unless a static file has the same name.
+=head2 Wildcards
+
+Assests can be brought in via wildcards:
+
+ app->asset(
+ "bundle.js" => ("/js/myapp.js", "/js/*.js")
+ );
+
+The C</js/*.js> will tell AssetPack to look in all public directories for any
+files mathing the L<wildcard expression|perlfunc/glob>. Note that since
+"myapp.js" is already defined, it will not be added again even if the wildcard
+expression match that file.
+
+If there is a need to set a load precedence, simply add the files that need
+to be loaded first into the array before the wildcard or prefix the filenames
+with a number: C<01-polyfill.js>, C<02-main.js>, ...
+
+This feature is currently EXPERIMENTAL.
+
=head1 NEXT
Now that you know how to define your assets, you can start using them in
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-0.55/lib/Mojolicious/Plugin/AssetPack.pm
new/Mojolicious-Plugin-AssetPack-0.56/lib/Mojolicious/Plugin/AssetPack.pm
--- old/Mojolicious-Plugin-AssetPack-0.55/lib/Mojolicious/Plugin/AssetPack.pm
2015-05-25 12:58:04.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-0.56/lib/Mojolicious/Plugin/AssetPack.pm
2015-08-05 10:44:15.000000000 +0200
@@ -9,10 +9,10 @@
use File::Basename ();
use File::Path ();
use File::Spec ();
-use constant NO_CACHE => $ENV{MOJO_ASSETPACK_NO_CACHE} || 0;
use constant DEBUG => $ENV{MOJO_ASSETPACK_DEBUG} || 0;
+use constant NO_CACHE => $ENV{MOJO_ASSETPACK_NO_CACHE} || 0;
-our $VERSION = '0.55';
+our $VERSION = '0.56';
has base_url => '/packed/';
has minify => 0;
@@ -28,6 +28,7 @@
sub add {
my ($self, $moniker, @files) = @_;
+ @files = $self->_expand_wildcards(@files);
return $self->tap(sub { $self->{files}{$moniker} = \@files }) if NO_CACHE;
return $self->tap(sub { $self->_assets($moniker => $self->_process($moniker,
@files)) }) if $self->minify;
return $self->tap(sub { $self->_assets($moniker =>
$self->_process_many($moniker, @files)) });
@@ -65,6 +66,28 @@
return $self;
}
+sub purge {
+ my ($self, $args) = @_;
+ my $file_re = $self->minify ? qr/^(.*?)-(\w{32})\.min\.(\w+)$/ :
qr/^(.*?)-(\w{32})\.(\w+)$/;
+ my ($PACKED, %existing);
+
+ # default to not purging, unless in development mode
+ local $args->{always} = $args->{always} // $self->_app->mode eq
'development';
+
+ return $self unless $args->{always};
+ die '$app->asset->purge() must be called AFTER $app->asset(...)' unless keys
%{$self->{assets} || {}};
+ return $self unless $self->out_dir and opendir $PACKED, $self->out_dir;
+ $existing{$_} = 1 for grep { $_ =~ $file_re } readdir $PACKED;
+ delete $existing{$_->basename} for map {@$_} values %{$self->{assets} || {}};
+
+ for my $file (keys %existing) {
+ $self->_unlink_packed($file);
+ warn "[ASSETPACK] Purged $file ($!)\n" if DEBUG;
+ }
+
+ return $self;
+}
+
sub register {
my ($self, $app, $config) = @_;
my $helper = $config->{helper} || 'asset';
@@ -151,6 +174,29 @@
return $out_dir // '';
}
+sub _expand_wildcards {
+ my $self = shift;
+ my (@files, %seen);
+
+ for my $file (@_) {
+ if (!-e $file and $file =~ /\*/) {
+ my @rel = split '/', $file;
+ my $glob = pop @rel;
+
+ for my $path (map { File::Spec->catdir($_, @rel) }
@{$self->_app->static->paths}) {
+ my $cwd =
Mojolicious::Plugin::AssetPack::Preprocessors::CWD->new($path);
+ push @files, grep { !$seen{$_} } map { join '/', @rel, $_ } sort glob
$glob;
+ }
+ }
+ else {
+ push @files, $file;
+ $seen{$file} = 1;
+ }
+ }
+
+ return @files;
+}
+
sub _find {
my $needle = pop;
my $self = shift;
@@ -309,6 +355,11 @@
return $asset;
}
+sub _unlink_packed {
+ my ($self, $file) = @_;
+ unlink File::Spec->catfile($self->out_dir, $file);
+}
+
# utils
sub _ext { local $_ = File::Basename::basename($_[0]); /\.(\w+)$/ ? $1 :
'unknown'; }
@@ -329,7 +380,7 @@
=head1 VERSION
-0.55
+0.56
=head1 SYNOPSIS
@@ -342,6 +393,7 @@
# define assets: $moniker => @real_assets
app->asset('app.js' => '/js/foo.js', '/js/bar.js', '/js/baz.coffee');
+ app->asset->purge; # remove old packed files
app->start;
See also L<Mojolicious::Plugin::AssetPack::Manual::Assets> for more
@@ -461,12 +513,6 @@
See also L<Mojolicious::Plugin::AssetPack::Manual::Modes>.
-=head2 preprocessors
-
- $obj = $self->preprocessors;
-
-Holds a L<Mojolicious::Plugin::AssetPack::Preprocessors> object.
-
=head2 out_dir
$str = $self->out_dir;
@@ -477,6 +523,12 @@
Defaults to empty string if no directory can be found, which again results in
keeping all packed files in memory.
+=head2 preprocessors
+
+ $obj = $self->preprocessors;
+
+Holds a L<Mojolicious::Plugin::AssetPack::Preprocessors> object.
+
=head1 METHODS
=head2 add
@@ -514,6 +566,18 @@
See L<Mojolicious::Plugin::AssetPack::Preprocessor::Browserify/SYNOPSIS>
for example usage.
+=head2 purge
+
+ $self = $self->purge({always => $bool});
+
+Used to purge old packed files. This is useful if you want to avoid filling up
+L</out_dir> with many versions of the packed file.
+
+C<always> default to true if in "development" L<mode|Mojolicious/mode> and
+false otherwise.
+
+This method is EXPERIMENTAL and can change, be removed at any time.
+
=head2 register
plugin AssetPack => {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/t/get-wildcard.t
new/Mojolicious-Plugin-AssetPack-0.56/t/get-wildcard.t
--- old/Mojolicious-Plugin-AssetPack-0.55/t/get-wildcard.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Mojolicious-Plugin-AssetPack-0.56/t/get-wildcard.t 2015-08-05
10:36:43.000000000 +0200
@@ -0,0 +1,24 @@
+use t::Helper;
+
+my $t = t::Helper->t({minify => 0});
+my $assetpack = $t->app->asset;
+my @data;
+
+$t->app->asset('app.css' => '/css/5w.css', '/css/*w.css');
+
+is_deeply(
+ [$assetpack->get('app.css')],
+ [
+ qw( /packed/5w-6a4be8014d0575886036b8362e385320.css
/packed/1w-09a653553edca03ad3308a868e5a06ac.css
/packed/2w-76f882600dc1f9f84a333a5979a41246.css )
+ ],
+ 'get()'
+);
+
+my $css = join "\n", $assetpack->get('app.css', {inline => 1});
+like $css, qr{\#a5a5a5.*\#a1a1a1.*\#a2a2a2}s, 'css in order';
+
+done_testing;
+
+__DATA__
+@@ css.html.ep
+%= asset 'app.css'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-0.55/t/public/css/1w.css
new/Mojolicious-Plugin-AssetPack-0.56/t/public/css/1w.css
--- old/Mojolicious-Plugin-AssetPack-0.55/t/public/css/1w.css 1970-01-01
01:00:00.000000000 +0100
+++ new/Mojolicious-Plugin-AssetPack-0.56/t/public/css/1w.css 2015-08-05
10:36:43.000000000 +0200
@@ -0,0 +1,3 @@
+body {
+ background: #a1a1a1;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-0.55/t/public/css/2w.css
new/Mojolicious-Plugin-AssetPack-0.56/t/public/css/2w.css
--- old/Mojolicious-Plugin-AssetPack-0.55/t/public/css/2w.css 1970-01-01
01:00:00.000000000 +0100
+++ new/Mojolicious-Plugin-AssetPack-0.56/t/public/css/2w.css 2015-08-05
10:36:43.000000000 +0200
@@ -0,0 +1,3 @@
+body {
+ background: #a2a2a2;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-0.55/t/public/css/5w.css
new/Mojolicious-Plugin-AssetPack-0.56/t/public/css/5w.css
--- old/Mojolicious-Plugin-AssetPack-0.55/t/public/css/5w.css 1970-01-01
01:00:00.000000000 +0100
+++ new/Mojolicious-Plugin-AssetPack-0.56/t/public/css/5w.css 2015-08-05
10:36:43.000000000 +0200
@@ -0,0 +1,3 @@
+body {
+ background: #a5a5a5;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-0.55/t/purge.t
new/Mojolicious-Plugin-AssetPack-0.56/t/purge.t
--- old/Mojolicious-Plugin-AssetPack-0.55/t/purge.t 1970-01-01
01:00:00.000000000 +0100
+++ new/Mojolicious-Plugin-AssetPack-0.56/t/purge.t 2015-08-05
10:36:41.000000000 +0200
@@ -0,0 +1,25 @@
+use t::Helper;
+no warnings 'redefine';
+
+{
+ my $t = t::Helper->t({minify => 1});
+ $t->app->asset('app.css' => '/css/c.css', '/css/d.css');
+ $t->app->asset('foo.css' => '/css/d.css', '/css/c.css');
+}
+
+{
+ my $t = t::Helper->t({minify => 1});
+ my @unlink;
+ *Mojolicious::Plugin::AssetPack::_unlink_packed = sub { push @unlink, $_[1]
};
+ eval { $t->app->asset->purge };
+ like $@, qr{AFTER}, 'need to define assets before calling purge';
+ $t->app->asset('rename.css' => '/css/1w.css');
+ $t->app->asset->purge;
+ is_deeply(
+ [sort @unlink],
+ [qw( app-3659f2c6b80de93f8373568a1ddeffaa.min.css
foo-0cbacb97f7b3f70fb6d39926d48dba68.min.css )],
+ 'unlinked old packed files'
+ )
+}
+
+done_testing;