API-Mathpix
view release on metacpan or search on metacpan
"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" : {
"web" : "https://github.com/eriam/API-Mathpix/issues"
},
"homepage" : "https://github.com/eriam/API-Mathpix",
"repository" : {
"url" : "git://github.com/eriam/API-Mathpix.git",
"web" : "https://github.com/eriam/API-Mathpix"
}
},
"version" : "0.01",
---
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:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: API-Mathpix
no_index:
directory:
- 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
'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);
Version 0.01
# 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;
# 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
requires 'Modern::Perl' => 0;
requires 'Algorithm::LeakyBucket' => 0;
requires 'Moose' => 0;
lib/API/Mathpix.pm view on Meta::CPAN
our $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
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
if ($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({
src => 'https://mathpix.com/examples/limit.jpg',
});
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 1.033 second using v1.01-cache-2.11-cpan-49f99fa48dc )