File-Assets

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN


    my $libscan = \&{"ExtUtils::MM_Any::libscan"};
    *{"ExtUtils::MM_Any::libscan"} = sub {
        return '' unless $libscan->(@_);
        return '' if $_[1] =~ /\.sw[p-z]$/;
        return $_[1];
    };
}

{
    map { my ($pk, $vr) = split m/\s/; build_requires $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
Test::Memory::Cycle
Directory::Scratch
Test::More
_END_

    map { my ($pk, $vr) = split m/\s/; requires $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
MIME::Types
Module::Pluggable
Path::Resource
Scalar::Util
Tie::LLHash
Digest
Digest::MD5
Digest::SHA
Carp::Clan::Share
Object::Tiny
HTML::Declare
XML::Tiny
IO::Scalar
_END_

    map { my ($pk, $vr) = split m/\s/; recommends $pk => $vr || 0 } grep { ! /^\s*#/ } split m/\n/, <<_END_;
CSS::Minifier
JavaScript::Minifier
CSS::Minifier::XS 0.3
JavaScript::Minifier::XS 0.3
_END_
}

if (-e 'inc/.author') {
    my $all_from = join '/', 'lib', split m/-/, name . '.pm';
    `perldoc -tF $all_from > README` if ! -e 'README' || (stat $all_from)[9] > (stat 'README')[9];
}


auto_install;

WriteAll;

lib/File/Assets.pm  view on Meta::CPAN

            if ($condition eq $key) {
                # Best possible match
                $result = 1;
                $best_kind = $kind;
            }
            elsif ($condition eq "*" || $condition eq "default") {
                $result = $best_kind ? -1 : 1; 
            }
        }

        my ($condition_kind, $condition_signature) = split m/:/, $condition, 2;
            
        unless (defined $result) {

            # No exact match, try to find the best fit...

            # Signature doesn't match or is not a wildcard, so move on to the next rule
            next if defined $condition_signature && $condition_signature ne '*' && $condition_signature ne $signature;

            if (length $condition_kind && $condition_kind ne '*') {
                $condition_kind = File::Assets::Kind->new($condition_kind);

lib/File/Assets/Filter.pm  view on Meta::CPAN

    }

    return $class->new(%cfg, @_);
}

sub new_parse_cfg {
    my $class = shift;
    my $cfg = shift;
    $cfg = "" unless defined $cfg;
    my %cfg;
    %cfg = map { my @itm = split m/=/, $_, 2; $itm[0], $itm[1] } split m/;/, $cfg;
    $cfg{__cfg__} = $cfg;
    return %cfg;
}

sub new {
    my $class = shift;
    my $self = $class->SUPER::new;
    local %_ = @_;

#    $self->{assets} = $_{assets};

lib/File/Assets/Filter.pm  view on Meta::CPAN

    }

    return $class->new(%cfg, @_);
}

sub new_parse_cfg {
    my $class = shift;
    my $cfg = shift;
    $cfg = "" unless defined $cfg;
    my %cfg;
    %cfg = map { my @itm = split m/=/, $_, 2; $itm[0], $itm[1] } split m/;/, $cfg;
    $cfg{__cfg__} = $cfg;
    return %cfg;
}

sub new {
    my $class = shift;
    my $self = $class->SUPER::new;
    local %_ = @_;

    $self->{assets} = $_{assets};

lib/File/Assets/Filter/Minifier/Base.pm  view on Meta::CPAN


my %minifier_package;
sub _minifier_package {
    my $class = shift;
    return $minifier_package{$class} ||= do {
        my $package = substr $class, length qq/File::Assets::Filter::Minifier::/;
        # JavaScript
        # JavaScript::XS
        # CSS
        # CSS::XS
        my @package = split m/::/, $package;
        join qw/::/, (shift @package), qw/Minifier/, @package;
    };
}

my %minifier_package_is_available;
sub _minifier_package_is_available {
    my $class = shift;
    return $minifier_package_is_available{$class} if exists $minifier_package_is_available{$class};
    my $package = $class->_minifier_package;
    return $minifier_package_is_available{$class} = eval "require $package;";

lib/File/Assets/Kind.pm  view on Meta::CPAN


use strict;
use warnings;

use Object::Tiny qw/kind type head tail/;
use Carp;

sub new {
    my $self = bless {}, shift;
    confess "Uhh, whut?" unless $self->{kind} = my $kind = shift;
    my @kind = split m/-/, $kind, 2;
    my $type = shift;
    unless ($type) {
        $type = $kind[0];
        $type = File::Assets::Util->parse_type($type);
    }
    $self->{type} = $type;
    $kind[1] = "" unless defined $kind[1];
    $self->{tail} = my $tail = $kind[1];
    $self->{head} = ($type->extensions)[0];
    

t/Test.pm  view on Meta::CPAN

        if (! ref $_[0]) {
            my $href = shift;
            my $kind;
            $kind = $1 if $href =~ s/^([\w-]+);//;
            ($kind) = $href =~ m/\.([^.]+)$/ unless $kind;
            %attributes = (%attributes, %{ shift() }) if ref $_[0] eq "HASH";
            if ($kind eq "js") {
                push @content, SCRIPT({ type => "text/javascript", src => $href, _ => "", %attributes });
            }
            elsif ($kind =~ m/^css\b/) {
                my ($type, $media) = split m/-/, $kind;
                $attributes{media} = $media if defined $media;
                push @content, LINK({ rel => "stylesheet", type => "text/css", href => $href, %attributes });
            }
        }
        elsif (ref $_[0] eq "ARRAY") {
            my ($kind, $content, $attributes) = @{ shift() };
            $attributes ||= {};
            %attributes = (%attributes, %$attributes);
            if ($kind eq "js") {
                push @content, SCRIPT({ type => "text/javascript", _ => "\n$content" });
            }
            elsif ($kind =~ m/^css\b/) {
                my ($type, $media) = split m/-/, $kind;
                push @content, STYLE({ type => "text/css", _ => "\n$content" });
            }
        }
        else {
            die "Don't understand: @_";
        }
    }
    return is($expect, join "\n", @content);
}



( run in 0.878 second using v1.01-cache-2.11-cpan-71847e10f99 )