API-Mathpix

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
      "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",

META.yml  view on Meta::CPAN

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
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:

META.yml  view on Meta::CPAN

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    - 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:
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

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
        '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);

README.md  view on Meta::CPAN

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

cpanfile  view on Meta::CPAN

1
2
3
requires 'Modern::Perl'                         => 0;
requires 'Algorithm::LeakyBucket'                         => 0;
requires 'Moose'                         => 0;

lib/API/Mathpix.pm  view on Meta::CPAN

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  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

t/01-api.t  view on Meta::CPAN

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 0.589 second using v1.01-cache-2.11-cpan-87723dcf8b7 )