CSS-Prepare

 view release on metacpan or  search on metacpan

lib/CSS/Prepare.pm  view on Meta::CPAN

package CSS::Prepare;

use Modern::Perl;

use CSS::Prepare::CSSGrammar;
use CSS::Prepare::Property::Background;
use CSS::Prepare::Property::Border;
use CSS::Prepare::Property::BorderRadius;
use CSS::Prepare::Property::Color;
use CSS::Prepare::Property::Effects;
use CSS::Prepare::Property::Font;
use CSS::Prepare::Property::Formatting;
use CSS::Prepare::Property::Generated;
use CSS::Prepare::Property::Hacks;
use CSS::Prepare::Property::Margin;
use CSS::Prepare::Property::Padding;
use CSS::Prepare::Property::Tables;
use CSS::Prepare::Property::Text;
use CSS::Prepare::Property::UI;
use CSS::Prepare::Property::Values;
use CSS::Prepare::Property::Vendor;
use Digest::SHA1        qw( sha1_hex );
use FileHandle;
use File::Basename;
use File::Path;
use List::Util          qw( first );
use Storable            qw( dclone );

use version;
our $VERSION = qv( 0.9.2.4 );

use constant MAX_REDIRECT       => 3;
use constant RE_IS_URL          => qr{^ http s? : // }x;
use constant RE_MATCH_HOSTNAME  => qr{^ ( http s? : // [^/]+ ) /? .* $}x;
use constant RE_MATCH_DIRECTORY => qr{^ (.*?) (?: / [^/]* )? $}x;
use constant NOT_VENDOR_PREFIX  => qw(
        background  border   empty    font  letter
        list        margin   padding  page  table
        text        unicode  white    z
    );

my @MODULES = qw(
        Background
        Border
        BorderRadius
        Color
        Effects
        Font
        Formatting
        Hacks
        Generated
        Margin
        Padding
        Tables
        Text
        UI
        Vendor
    );



sub new {
    my $class = shift;
    my %args  = @_;
    
    my $self = {
            hacks                => 1,
            extended             => 0,
            suboptimal_threshold => 10,
            http_timeout         => 30,
            pretty               => 0,
            assets_output        => undef,
            assets_base          => undef,
            location             => undef,
            status               => \&status_to_stderr,
            %args
        };
    bless $self, $class;
    
    my %http_providers = (
            lite => 'HTTP::Lite',
            lwp  => 'LWP::UserAgent',
        );
    
    # sort to prefer HTTP::Lite over LWP::UserAgent
    HTTP:
    foreach my $provider ( sort keys %http_providers ) {
        my $module = $http_providers{ $provider };
        
        eval "require $module";
        unless ($@) {
            $self->{'http_provider'} = $provider;
            last HTTP;
        }
    }
    
    # check for ability to use plugins
    if ( $self->support_extended_syntax() ) {
        eval "use Module::Pluggable require => 1;";



( run in 0.682 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )