File Coverage

blib/lib/WWW/Wolfram/DataDrop.pm
Criterion Covered Total %
statement 11 29 37.9
branch n/a
condition n/a
subroutine 4 10 40.0
pod 0 5 0.0
total 15 44 34.0


line stmt bran cond sub pod time code
1             package WWW::Wolfram::DataDrop;
2              
3 1     1   13405 use strict;
  1         2  
  1         21  
4 1     1   3 use warnings;
  1         1  
  1         21  
5 1     1   16 use 5.008_005;
  1         5  
6             our $VERSION = '0.03';
7              
8             require Exporter;
9             our @ISA = 'Exporter';
10             our @EXPORT = qw/Databin/;
11              
12 1     1   613 use LWP::UserAgent;
  1         31534  
  1         173  
13              
14             sub Databin {
15 0     0 0   my ($id, %opts) = @_;
16 0           my $self = __PACKAGE__->new(bin => $id, %opts);
17 0           return $self;
18             }
19              
20             sub new {
21 0     0 0   my ($class, %opts) = @_;
22 0           my $self = \%opts;
23 0           my $ua_opts = delete $self->{opts};
24 0           $self->{ua} = LWP::UserAgent->new(%$ua_opts);
25 0           return bless $self, $class;
26             }
27              
28             sub add {
29 0     0 0   my ($self, %values) = @_;
30 0           $values{bin} = $self->{bin};
31 0           return $self->_send(%values);
32             }
33              
34             sub _send {
35 0     0     my ($self, %values) = @_;
36 0           my $res = $self->ua->post($self->url, [%values]);
37 0           return $res->is_success;
38             }
39              
40             sub ua {
41 0     0 0   my $self = shift;
42 0           return $self->{ua};
43             }
44              
45             sub url {
46 0     0 0   my $self = shift;
47 0           return 'https://datadrop.wolframcloud.com/api/v1.0/Add';
48             }
49              
50             1;
51             __END__