The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::WebDevoutCom::BrowserSupportInfo - access browser support API on http://webdevout.com

SYNOPSIS

    use strict;
    use warnings;

    use WWW::WebDevout::BrowserSupportInfo;

    my $wd = WWW::WebDevout::BrowserSupportInfo->new( long => 1 );

    $wd->fetch( 'display block' )
        or die "Error: " . $wd->error . "\n";

    print "Support for " . $wd->what;

    my $results = $wd->browser_results;
    printf "\n\t%-20s: %s", $_, $results->{ $_ }
        for sort keys %$results;

    printf "\n You can find more information on %s\n", $wd->uri_info;

    # prints this:
    Support for block
        FireFox 1.5         : Y
        FireFox 2           : Y
        Internet Explorer 6 : I;Treated like "list-item" on "li" elements
        Internet Explorer 7 : I;Treated like "list-item" on "li" elements
        Konqueror 3.5       : Y
        Opera 8             : Y
        Opera 9             : Y
        Safari 2            : 
    You can find more information on http://www.webdevout.net/browser-support-css#support-css2propsbasic-display

DESCRIPTION

The module provides access to the browser support information available though beta API from http://www.webdevout.net.

Note: the support database is incomplete and is still on beta stage of development. According to the author of http://www.webdevout.net information for Safari and Konqueror is incomplete and wrong in some cases.

CONSTRUCTOR

new

    my $wd = WWW::WebDevout::BrowserSupportInfo->new;

    my $wd = WWW::WebDevout::BrowserSupportInfo->new(
        long     => 1,
        browsers => [ qw(IE6 IE7 FX1_5 FX2) ],
        ua_args  => {
            timeout => 10,
            agent   => 'InfoUA',
        },
    );

Constructs and returns a WWW::WebDevout::BrowserSupportInfo object. Takes several arguments, all of which are optional. The possible arguments are as follows:

long

    ->new( long => 1 );

Optional. When the long agument is set to a true value, the full names of the browsers in the results will be returned, otherwise their "codes" will be used. In other words, when long option is set to a false value the keys in the results will be named according to the left side of the list below, when long is set to a true value, the keys in the results will be named according to the right side of the list below. Defaults to: 0.

        IE6     => 'Internet Explorer 6',
        IE7     => 'Internet Explorer 7',
        IE8     => 'Internet Explorer 8',
        FX1_5   => 'FireFox 1.5',
        FX2     => 'FireFox 2',
        FX3     => 'FireFox 3',
        OP8     => 'Opera 8',
        OP9     => 'Opera 9',
        KN3_5   => 'Konqueror 3.5',
        SF2     => 'Safari 2',

browsers

    ->new( browsers => [ qw( IE6 IE7 FX1_5 ) ] );

Optional. Takes an arrayref as a value. The elements in that arrayref are browser codes, for which to get the information from WebDevout. See description for long constructor's argument for possible browser codes. Defaults to: [ qw(IE6 IE7 IE8 FX1_5 FX2 FX3 OP8 OP9 KN3_5 SF2) ] (all browsers supported by WebDevout)

ua_args

    ->new(
        ua_args => {
            timeout => 10,
            agent   => 'InfoUA',
        },
    );

Optional. Takes a hashref as a value. It must contain LWP::UserAgent's constructor arguments which will be directly passed to LWP::UserAgent's constructor. Unless the timeout argument is specified it will default to 30 seconds, the rest of LWP::UserAgent's constructor arguments default to their defaults.

METHODS

fetch

    $wd->fetch('css')
        or die $wd->error;

    $wd->fetch('display block')
        or die $wd->error;
        
    my $results_ref = $wd->fetch('span')
        or die $wd->error;

Instructs the object to fetch the browser support information. Takes one argument which is the term to look up. There are no set definitions on what the term might be. The possible values would resemble something from http://www.webdevout.net/browser-support. And try to omit some punctuation, in other words if you want to look up browser support for CSS { display: block; } property/value, use display block as an argument to fetch.

Returns a hashref of results, but you don't necessarily have to keep it as it is a combination of return values of what(), browser_results() and uri_info() methods.

If an error occured during the fetching of results, fetch() will return either undef or an empty list (depending on the context) and the reason for the error will be available via error() method.

The possible results hashref is presented below, see description of the long and browsers arguments to constructor as they affect the browser keys in the results:

    $VAR1 = {
        'what' => 'block',
        'uri_info' => 'http://www.webdevout.net/browser-support-css#support-css2propsbasic-display',
        'SF2' => '',
        'FX1_5' => 'Y',
        'FX2' => 'Y',
        'IE6' => 'I;Treated like "list-item" on "li" elements',
        'IE7' => 'I;Treated like "list-item" on "li" elements',
        'OP8' => 'Y',
        'OP9' => 'Y',
        'KN3_5' => 'Y'
    };

error

    $wd->fetch('css')
        or die $wd->error;

If an error occured during fetch() it will return undef or an empty list (depending on a context) and the error() method would return the description of the error.

results

    $wd->fetch('css');
    my $results = $wd->results;

Takes no arguments, returns a hashref which is exactly the same as the return value of fetch() method (see above). Must be called after the call to fetch().

browser_results

    $wd->fetch('css');
    my $browser_support = $wd->browser_results;

Takes no arguments, must be called after the call to fetch(). Returns a hashref which is similiar to the return of fetch() except only the browser information will be present, i.e. the uri_info and what keys will be missing. See description of the fetch() method above for details.

what

    $wd->fetch('css');
    my $what_did_we_look_up = $wd->what; # will return 'css'

Takes no arguments, must be called after the call to fetch(). Returns the term which was last looked up, i.e. the argument which was specified to fetch().

uri_info

    $wd->fetch('css');
    my $uri_to_webdevout = $wd->uri_info;

Takes no arguments, must be called after the call to fetch(). Returns a URI to the page on http://webdevout.net which contains the information for the term you've looked up.

make_long_name

    my $ie6_name = $wd->make_long_name('IE6');
    my $fx2_name = $wd->make_long_name('FX2');

Takes the browser code as an argument and returns the full name of the browser for that code. Possible arguments are: SF2, FX1_5, FX2, IE6, IE7, OP8, OP9 and KN3_5.

browser_info

    $wd->fetch('css');

    my $ie6_css_support = $wd->browser_info('IE6');
    my $ie7_css_support = $wd->browser_info('IE7');

Must be called after a call to fetch() (see above). Takes a browser code as an argument and returns the support information for that browser in a form of a scalar. Possible arguments are: SF2, FX1_5, FX2, IE6, IE7, OP8, OP9 and KN3_5.

There is some overload magic implemented in this module. You could call browser_info() method by hash-dereferencing the WWW::WebDevout::BrowserSupportInfo object. In other words, the above code could be written as:

    $wd->fetch('css');
    my ( $ie6_css_support, $ie7_css_support ) = @$wd{ qw( IE6 IE7 ) };

Therefore, you could interpolate the results in a string:

    print "Support for IE6 is $wd->{IE6} and for IE7 it is $wd->{IE7}\n";

Important Note: While browser_info() method is NOT affected by the constructor's long argument, the overload IS. In other words, you would be doing this:

    my $wd = WWW::WebDevout::BrowserSupportInfo->new( long => 1 );
    $wd->fetch('css)';
    my $ie6_css_support = $wd->browser_info('IE6'); # note the browser code
    my $ie7_css_support = $wd->{'Internet Explorer 7'}; # note the name

ACCESSORS/MUTATORS

browsers

    my $current_browsers_ref = $wd->browsers;
    push @$current_browsers_ref, 'IE6';
    $wd->browsers( $current_browsers_ref );

Returns an arrayref of browser codes for which to lookup information for, this is basically the browsers argument to the constructor. See constructor's browsers argument for more information on possible elements of the arrayref. Takes one optional argument, which is an arrayref of browser codes to lookup the information for. See constructor's browsers argument for more information.

long

    my $are_long_names = $wd->long;
    $wd->long(1);

Returns either false or true value which indicates whether or not the browser keys in the results represent the browser codes or the full names of the browsers. Takes one optional argument which can be either true or false value, the effect of which will be the same as setting the long argument in the constructor. See constructors long argument for more information.

ua_args

    my $ua_args = $wd->ua_args;
    $ua_args->{timeout} = 100;
    $wd->ua_args( $ua_args );

Returns the currently set ua_args constructor's argument which is a hashref of LWP::UserAgent's constructor arguments. Takes one optional argument which is a hashref of LWP::UserAgent's constructor arguments. See the ua_args argument to the contructor for more information.

BE HUMAN

WebDevout is a free service, hosted on free web hosting (at least for now). Please don't abuse the service. If you have an opporunity to host the site for free on some decent server you may want to contact David Hammond via the form on http://www.webdevout.net/contact

AUTHOR

Zoffix Znet, <zoffix at cpan.org> (http://zoffix.com, http://haslayout.net)

ACKNOWLEDGEMENTS

Thanks to David Hammond for making the browser support database and providing an API for it.

BUGS

Please report any bugs or feature requests to bug-www-webdevout-browsersupportinfo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-WebDevout-BrowserSupportInfo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc WWW::WebDevout::BrowserSupportInfo

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 Zoffix Znet, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.