NAME

POE::Component::WWW::WebDevout::BrowserSupportInfo - non-blocking access to browser support API on http://webdevout.net

SYNOPSIS

use strict;
use warnings;

use POE qw(Component::WWW::WebDevout::BrowserSupportInfo);

my $poco = POE::Component::WWW::WebDevout::BrowserSupportInfo->spawn(
    obj_args => { long => 1 },
);

POE::Session->create(
    package_states => [
        main => [ qw( _start  fetched ) ],
    ],
);

$poe_kernel->run;

sub _start {
    $poco->fetch( {
            what  => 'display block',
            event => 'fetched',
        }
    );
}

sub fetched {
    my $in = $_[ARG0];

    print "Support for $in->{what}\n";

    print "\t$_ => $in->{results}{ $_ }\n"
        for keys %{ $in->{results} };

    print "For more information visit: $in->{uri_info}\n";

    $poco->shutdown;
}

DESCRIPTION

The module is a non-blocking POE wrapper around WWW::WebDevout::BrowserSupportInfo which provides access to browser support API on http://webdevout.net

CONSTRUCTOR

spawn

my $poco = POE::Component::WWW::WebDevout::BrowserSupportInfo->spawn;

POE::Component::WWW::WebDevout::BrowserSupportInfo->spawn(
    alias => 'info',
    obj_args => {   # WWW::WebDevout::BrowserSupportInfo..
        long => 1,  # ... constructor options here.
    },
    options  => {   # POE::Session options here
        debug => 1,
    }
    debug => 1,
);

Constructs and returns a brand new out of the box POE::Component::WWW::WebDevout::BrowserSupportInfo object. However, you don't have to store it anywhere if you set the alias argument. Takes a number of arguments all of which are optional. The possible arguments/values are as follows:

alias

->spawn( alias => 'recent' );

Optional. Specifies the component's POE::Session alias of the component.

obj_args

->spawn(
    obj_args => {
        long => 1,
        browser => [ qw(IE6 IE7) ],
    },
);

Optional. Takes a hashref as an argument which contains WWW::WebDevout::BrowserSupportInfo constructor's arguments. See WWW::WebDevout::BrowserSupportInfo documentation for possible arguments. Defaults to: default WWW::WebDevout::BrowserSupportInfo constructor.

debug

Optional.

->spawn( debug   => 1 );

Optional. When set to a true value will make the component emit some debugging info. Defaults to false.

options

{
    options => {
        trace   => 1,
        default => 1,
    }
}

A hashref of POE Session options to pass to the component's session.

METHODS

These are the object-oriented methods of the component.

fetch

$poco->fetch( {
        what    => 'css',                 # mandatory
        event   => 'event_for_results',   # mandatory
        session => 'other_session',       # optional
    }
);

Instructs the component to fetch browser support information. Takes a hashref as an argument. See fetch event description for details.

session_id

my $info_poco_id = $poco->session_id;

Takes no arguments. Returns POE Session ID of the component.

shutdown

$poco->shutdown;

Takes no arguments. Shuts the component down.

ACCEPTED EVENTS

The interaction with the component is also possible via event based interface. The following events are accepted by the component:

fetch

$poe_kernel->post( info => fetch => {
        what    => 'css',                 # mandatory
        event   => 'event_for_results',   # mandatory
        session => 'other_session',       # optional
        _user   => 'defined',             # optional user defined arg.
    }
);

Instructs the component to fetch browser support information. Takes a hashref as an argument. The possible key/values of that hashref are as follows:

what

{ what => 'css' }
{ what => 'display block' }
{ what => 'span' }

Mandatory. Takes a scalar as a value 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. 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 a value to what.

event

{ event => 'results_event' }

Mandatory. Takes a scalar as a value, which is the name of the event to send the results to. See also OUTPUT section.

session

{ session => 'other_session_alias' }

{ session => $other_session_ID }

{ session => $other_session_ref }

Optional. Specifies an alternative POE Session to send the output to. Accepts either session alias, session ID or session reference. Defaults to the current session.

user defined arguments

{
    _user_var    => 'foos',
    _another_one => 'bars',
    _some_other  => 'beers',
}

Optional. Any keys beginning with the _ (underscore) will be present in the output intact.

OUTPUT

$VAR1 = {
    'what' => 'html',
    'uri_info' => 'http://www.webdevout.net/browser-support-html#support-html401',
    'results' => {
        'SF2' => '?',
        'FX1_5' => '91.741%',
        'FX2' => '91.741%',
        'IE6' => '80.211%',
        'IE7' => '80.802%',
        'OP8' => '85.822%',
        'OP9' => '86.361%',
        'KN3_5' => '?'
    },
    _user => 'defined',
};

# with ->spawn( obj_args => { long => 1 } );
$VAR1 = {
    'what' => 'html',
    'uri_info' => 'http://www.webdevout.net/browser-support-html#support-html401',
    'results' => {
        'Opera 9' => '86.361%',
        'Internet Explorer 6' => '80.211%',
        'FireFox 1.5' => '91.741%',
        'Safari 2' => '?',
        'FireFox 2' => '91.741%',
        'Opera 8' => '85.822%',
        'Internet Explorer 7' => '80.802%',
        'Konqueror 3.5' => '?'
    },
    _user => 'defined',
};

The event handler set up to handle the event you've specified in the event argument to fetch() event/method will receive input from the component in $_[ARG0] in a form of a hashref. The possible keys of the hashref are as follows:

what

{ what => 'html' }

The what key will contain the term, support for which we looked up. This is basically what you have supplied into what argument of the fetch() event/method.

uri_info

{ 'uri_info' => 'http://www.webdevout.net/browser-support-html#support-html401' }

The uri_info key will contain a URI pointing to the support information of the term you've looked up on http://webdevout.net.

results

'results' => {
    'Opera 9' => '86.361%',
    'Internet Explorer 6' => '80.211%',
    'FireFox 1.5' => '91.741%',
    'Safari 2' => '?',
    'FireFox 2' => '91.741%',
    'Opera 8' => '85.822%',
    'Internet Explorer 7' => '80.802%',
    'Konqueror 3.5' => '?'
}

Unless an error occurred, the results key will contain the output of WWW::WebDevout::BrowserSupportInfo's browser_results() method, which is a hashref with keys being browser names or browser codes depending on the long argument which you've might have supplied to obj_args to the component's constructor. See WWW::WebDevout::BrowserSupportInfo browser_results() method documentation for more information.

error

{ 'error' => 'No results' }

If an error occurred during the look up, or no results were returned, the error key will be present with the explanation of the error.

user defined arguments

{
    _user_var    => 'foos',
    _another_one => 'bars',
    _some_other  => 'beers',
}

Optional. Any keys beginning with the _ (underscore) will be present in the output intact.

SEE ALSO

WWW::WebDevout::BrowserSupportInfo, POE, http://webdebout.net

REPOSITORY

Fork this module on GitHub: https://github.com/zoffixznet/POE-Component-Bundle-WebDevelopment

BUGS

To report bugs or request features, please use https://github.com/zoffixznet/POE-Component-Bundle-WebDevelopment/issues

If you can't access GitHub, you can email your request to bug-POE-Component-Bundle-WebDevelopment at rt.cpan.org

AUTHOR

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

LICENSE

You can use and distribute this module under the same terms as Perl itself. See the LICENSE file included in this distribution for complete details.