API-Mathpix
view release on metacpan or search on metacpan
20212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
"inc"
,
"share"
,
"eg"
,
"examples"
,
"author"
,
"builder"
]
},
"prereqs"
: {
"configure"
: {
"requires"
: {
"Module::Build::Tiny"
:
"0.035"
}
},
"develop"
: {
"requires"
: {
"Test::CPAN::Meta"
:
"0"
,
"Test::MinimumVersion::Fast"
:
"0.04"
,
"Test::PAUSE::Permissions"
:
"0.04"
,
"Test::Pod"
:
"1.41"
,
"Test::Spellunker"
:
"v0.2.7"
}
},
"runtime"
: {
"requires"
: {
"Algorithm::LeakyBucket"
:
"0"
,
"Modern::Perl"
:
"0"
,
"Moose"
:
"0"
}
}
},
"provides"
: {
"API::Mathpix"
: {
"file"
:
"lib/API/Mathpix.pm"
,
"version"
:
"0.01"
}
},
"release_status"
:
"stable"
,
"resources"
: {
"bugtracker"
: {
},
"repository"
: {
}
},
"version"
:
"0.01"
,
12345678910111213141516---
abstract:
'Use the API of Mathpix'
author:
-
"Eriam Schaffter, C<< <eriam at mediavirtuel.com> >>\r"
build_requires: {}
configure_requires:
Module::Build::Tiny:
'0.035'
dynamic_config: 0
generated_by:
'Minilla/v3.0.15, CPAN::Meta::Converter version 2.150010'
license: artistic_2
meta-spec:
version:
'1.4'
name: API-Mathpix
no_index:
directory:
19202122232425262728293031323334353637383940
- inc
- share
- eg
- examples
- author
- builder
provides:
API::Mathpix:
file: lib/API/Mathpix.pm
version:
'0.01'
requires:
Algorithm::LeakyBucket:
'0'
Modern::Perl:
'0'
Moose:
'0'
resources:
bugtracker: https://github.com/eriam/API-Mathpix/issues
homepage: https://github.com/eriam/API-Mathpix
repository: git://github.com/eriam/API-Mathpix.git
version:
'0.01'
x_contributors:
-
'Eriam Schaffter <eriam@mediavirtuel.com>'
x_serialization_backend:
'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
202122232425262728293031323334353637383940414243444546
'Moose'
=>
'0.1'
,
'JSON::PP'
=>
'0.1'
,
'Algorithm::LeakyBucket'
=>
'0.08'
,
},
dist
=> {
COMPRESS
=>
'gzip -9f'
,
SUFFIX
=>
'gz'
, },
clean
=> {
FILES
=>
'API-Mathpix-*'
},
);
# Compatibility with old versions of ExtUtils::MakeMaker
unless
(
eval
{ ExtUtils::MakeMaker->VERSION(
'6.64'
); 1 }) {
my
$test_requires
=
delete
$WriteMakefileArgs
{TEST_REQUIRES} || {};
@{
$WriteMakefileArgs
{PREREQ_PM}}{
keys
%$test_requires
} =
values
%$test_requires
;
}
unless
(
eval
{ ExtUtils::MakeMaker->VERSION(
'6.55_03'
); 1 }) {
my
$build_requires
=
delete
$WriteMakefileArgs
{BUILD_REQUIRES} || {};
@{
$WriteMakefileArgs
{PREREQ_PM}}{
keys
%$build_requires
} =
values
%$build_requires
;
}
delete
$WriteMakefileArgs
{CONFIGURE_REQUIRES}
unless
eval
{ ExtUtils::MakeMaker->VERSION(
'6.52'
); 1 };
delete
$WriteMakefileArgs
{MIN_PERL_VERSION}
unless
eval
{ ExtUtils::MakeMaker->VERSION(
'6.48'
); 1 };
delete
$WriteMakefileArgs
{LICENSE}
unless
eval
{ ExtUtils::MakeMaker->VERSION(
'6.31'
); 1 };
WriteMakefile(
%WriteMakefileArgs
);
67891011121314151617181920212223242526272829Version 0.01
# SYNOPSIS
my
$mathpix
= API::Mathpix->new({
app_id
=>
$ENV
{MATHPIX_APP_ID},
app_key
=>
$ENV
{MATHPIX_APP_KEY},
});
my
$response
=
$mathpix
->process({
});
$response
->text;
# EXPORT
A list of functions that can be exported. You can
delete
this section
if
you don't export anything, such as
for
a purely object-oriented module.
# SUBROUTINES/METHODS
## process
123requires
'Modern::Perl'
=> 0;
requires
'Algorithm::LeakyBucket'
=> 0;
requires
'Moose'
=> 0;
lib/API/Mathpix.pm view on Meta::CPAN
42434445464748495051525354555657585960616263646566our
$VERSION
=
'0.01'
;
=head1 SYNOPSIS
my $mathpix = API::Mathpix->new({
app_id => $ENV{MATHPIX_APP_ID},
app_key => $ENV{MATHPIX_APP_KEY},
});
my $response = $mathpix->process({
src => 'https://mathpix.com/examples/limit.jpg',
});
print $response->text;
=head1 EXPORT
A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
=head1 SUBROUTINES/METHODS
=cut
lib/API/Mathpix.pm view on Meta::CPAN
107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
my
$headers
= [
'Content-Type'
=>
'application/json'
,
':app_id'
=>
$self
->app_id,
':app_key'
=>
$self
->app_key,
];
my
$encoded_data
= encode_json(
$opt
);
my
$r
= HTTP::Request->new(
'POST'
,
$url
,
$headers
,
$encoded_data
);
my
$response
;
if
(
$self
->_bucket->tick) {
$response
=
$self
->_ua->request(
$r
);
}
else
{
warn
'Rate limiting !'
;
}
if
(
$response
->is_success) {
my
$data
= decode_json(
$response
->decoded_content);
return
API::Mathpix::Response->new(
$data
);
}
else
{
warn
$response
->status_line;
}
}
=head1 AUTHOR
Eriam Schaffter, C<< <eriam at mediavirtuel.com> >>
=head1 BUGS & SUPPORT
8910111213141516171819202122232425262728293031if
(
$ENV
{MATHPIX_APP_ID} &&
$ENV
{MATHPIX_APP_KEY}) {
plan
tests
=> 2;
my
$mathpix
= API::Mathpix->new({
app_id
=>
$ENV
{MATHPIX_APP_ID},
app_key
=>
$ENV
{MATHPIX_APP_KEY},
});
my
$response
=
$mathpix
->process({
});
ok(
$response
->text eq
"\\( \\lim _{x \\rightarrow 3}\\left(\\frac{x^{2}+9}{x-3}\\right) \\)"
,
"Ok !"
);
$response
=
$mathpix
->process({
src
=>
't/test.png'
,
});
ok(
$response
->text eq
'\\( \\sum_{i=1}^{m} q_{i}(n)=1 \\)'
,
"Ok !"
);
}
( run in 0.589 second using v1.01-cache-2.11-cpan-87723dcf8b7 )