Data-URIID

 view release on metacpan or  search on metacpan

lib/Data/URIID/Barcode.pm  view on Meta::CPAN

Future versions of this module might improve this definition.

=back

=head2 data

    my $data = $barcode->data;

Returns the data of the barcode.

The returned value might differ from the value passed to L</new> as it might have been normalised, decoded (character set), or otherwise altered.

No options are supported. However the options C<default>, and C<no_defaults> are ignored.

=head2 type

    my $type = $barcode->type;

Returns the type of the barcode.

The returned value might differ from the value passed to L</new> as it might have been normalised, replaced with a cached reference, or otherwise altered.

lib/Data/URIID/Service.pm  view on Meta::CPAN

    }

    if ($HAVE_HTML_TreeBuilder_XPath) {
        my Data::URIID $extractor = $self->extractor;

        if (defined(my $query = $opts{query})) {
            $url = ref($url) ? $url->clone : URI->new($url);
            $url->query_form($url->query_form, %{$query});
        }

        # We cannot use decoded_content()'s charset decoding here as it's buggy for JSON (and others?) response (at least in v6.18).
        return eval {
            my $msg = $extractor->_ua->get($url, 'Accept' => 'text/html');
            return undef unless $msg->is_success;
            my $val = $msg->decoded_content(ref => 1, charset => 'none');
            my $r = HTML::TreeBuilder::XPath->new;
            $r->parse(decode($msg->content_charset, $$val));
            $r->eof;
            $r;
        };
    } else {
        return undef;
    }
}

lib/Data/URIID/Service.pm  view on Meta::CPAN

                return $data if defined $data;
            }
        }
    }

    if (defined(my $query = $opts{query})) {
        $url = ref($url) ? $url->clone : URI->new($url);
        $url->query_form($url->query_form, %{$query});
    }

    # We cannot use decoded_content()'s charset decoding here as it's buggy for JSON response (at least in v6.18).
    return eval {
        my $msg = $extractor->_ua->get($url, 'Accept' => 'application/json');
        return undef unless $msg->is_success;
        my $val = $msg->decoded_content(ref => 1, charset => 'none');
        from_json(decode($msg->content_charset, $$val));
    };
}

# Private helper:
sub _get_json_file {
    my ($self, $filename) = @_;
    my $fh = eval { open(my $fh, '<', $filename) or die $!; $fh; } // eval { open(my $fh, '<:gzip', $filename.'.gz') or die $!; $fh; };

    return undef unless $fh;



( run in 2.182 seconds using v1.01-cache-2.11-cpan-26ccb49234f )