| 1 | package Data::OpenGraph; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Data::OpenGraph::Parser; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use constant +{ | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | HAVE_LWP => eval { require LWP::UserAgent } && !$@ ? 1 : 0, | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
eval {
do {
require LWP::UserAgent
}
} and not $@
MC/DC0%0/2
eval {
do {
require LWP::UserAgent
}
} and not $@
eval {
do {
require LWP::UserAgent
}
}
not $@
Truth table33%1/3
A and not(B)
A= eval {
do {
require LWP::UserAgent
}
}B= not $@
| |||||||||||||||||||||||||||||
| 7 | 1 | }; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 12 | 2 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 13 | 2 | bless { %args }, $class; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | ▶ | sub property { | ||||||||||||||||||||||||||
|
Subroutine
property: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 17 | 2 | my ($self, $name) = @_; | |||||||||||||||||||||||||||
| 18 | 2 | return $self->{properties}->{$name}; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub parse_uri { | ||||||||||||||||||||||||||
|
Subroutine
parse_uri: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 0 | my ($class, $uri) = @_; | |||||||||||||||||||||||||||
| 23 | 0 | if (HAVE_LWP) { | |||||||||||||||||||||||||||
| 24 | 0 | my $ua = LWP::UserAgent->new(); | |||||||||||||||||||||||||||
| 25 | 0 | my $res = $ua->get( $uri ); | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | if (! $res->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | Carp::croak( "Failed to get $uri: " . $res->status_line); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 0 | return $class->parse_string( $res->decoded_content ); | |||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||
| 31 | Carp::croak( "No applicable UserAgent (such as LWP::UserAgent) found" ); | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | sub parse_string { | ||||||||||||||||||||||||||
|
Subroutine
parse_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 2 | my ($class, $string) = @_; | |||||||||||||||||||||||||||
| 37 | 2 | my $properties = Data::OpenGraph::Parser->new()->parse_string( $string ); | |||||||||||||||||||||||||||
| 38 | 2 | Data::OpenGraph->new( properties => \%$properties ); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||