Skip to content
Browse files

Updates based on testing. Should have written tests first!

  • Loading branch information...
1 parent 14edbd3 commit 028f05d9b9a09829251621f06c27559539fc7fba @davidlday committed
View
9 .gitignore
@@ -0,0 +1,9 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
+# I use a local build directory for dzil
+build/*
+.build
View
16 lib/Lingua/AtD.pm
@@ -1,6 +1,4 @@
package Lingua::AtD;
-
-# ABSTRACT: Provides an OO wrapper for After the Deadline grammar and spelling service.
use strict;
use warnings;
use Carp;
@@ -11,6 +9,8 @@ use Lingua::AtD::Scores;
use Lingua::AtD::Exceptions;
use URI;
+# ABSTRACT: Provides an OO wrapper for After the Deadline grammar and spelling service.
+
{
# Attributes
@@ -43,13 +43,11 @@ use URI;
my $response = $ua->post( $url, Content => [ %{$arg_ref} ] );
if ( $response->is_error() ) {
- croak(
- Lingua::AtD::HTTPException->new(
- {
- http_status => $response->status_line,
- service_url => $url,
- }
- )
+ Lingua::AtD::HTTPException->throw(
+ {
+ http_status => $response->status_line,
+ service_url => $url,
+ }
);
}
View
6 lib/Lingua/AtD/Error.pm
@@ -1,11 +1,11 @@
package Lingua::AtD::Error;
-
-# ABSTRACT: Encapsulates the Errors contained in Results.
use strict;
use warnings;
use Carp;
use Class::Std;
+# ABSTRACT: Encapsulates the Errors contained in Results.
+
{
# Attributes
@@ -23,7 +23,7 @@ use Class::Std;
$suggestions_of{$ident} = $arg_ref->{suggestions}
if ( defined( $arg_ref->{suggestions} ) );
$url_of{$ident} = $arg_ref->{url}
- if ( defined( $arg_ref->{url} ) && length( $arg_ref->{url} > 0 ) );
+ if ( defined( $arg_ref->{url} ) && length( $arg_ref->{url} ) > 0 );
return;
}
View
6 lib/Lingua/AtD/Exceptions.pm
@@ -1,6 +1,4 @@
package Lingua::AtD::Exceptions;
-
-# ABSTRACT: Exception classes for Lingua::AtD
use Exception::Class (
Lingua::AtD::URLException => {
fields => [ 'url', 'host', 'port' ],
@@ -11,10 +9,12 @@ use Exception::Class (
description => 'Indicates a problem connecting to the AtD service.',
},
Lingua::AtD::ServiceException => {
- fields => ['service_message'],
+ fields => 'service_message',
description => 'Indicates the AtD service returned an error message.',
},
);
+# ABSTRACT: Exception classes for Lingua::AtD
+
1; # Magic true value required at end of module
__END__
View
4 lib/Lingua/AtD/Metric.pm
@@ -1,11 +1,11 @@
package Lingua::AtD::Metric;
-
-# ABSTRACT: Encapsulates the Metrics contained in Scores.
use strict;
use warnings;
use Carp;
use Class::Std;
+# ABSTRACT: Encapsulates the Metrics contained in Scores.
+
{
# Attributes
View
12 lib/Lingua/AtD/Results.pm
@@ -1,6 +1,4 @@
package Lingua::AtD::Results;
-
-# ABSTRACT: Encapsulate conversion of XML from /checkDocument or /checkGrammar call to Error objects.
use strict;
use warnings;
use Carp;
@@ -9,6 +7,8 @@ use Lingua::AtD::Error;
use Lingua::AtD::Exceptions;
use Class::Std;
+# ABSTRACT: Encapsulate conversion of XML from /checkDocument or /checkGrammar call to Error objects.
+
{
# Attributes
@@ -26,11 +26,9 @@ use Class::Std;
# Check for server message.
if ( $dom->exists('/results/message') ) {
$server_message_of{$ident} = $dom->findvalue('/results/message');
- croak(
- Lingua::AtD::ServiceException->new(
- { server_message => $server_message_of{$ident} }
- )
- );
+ Lingua::AtD::ServiceException->throw(
+ { service_message => $server_message_of{$ident} }
+ );
}
foreach my $error_node ( $dom->findnodes('/results/error') ) {
View
10 lib/Lingua/AtD/Scores.pm
@@ -1,6 +1,4 @@
package Lingua::AtD::Scores;
-
-# ABSTRACT: Encapsulate conversion of XML from /stats call to Metric objects.
use strict;
use warnings;
use Carp;
@@ -9,6 +7,8 @@ use Lingua::AtD::Metric;
use Lingua::AtD::Exceptions;
use Class::Std;
+# ABSTRACT: Encapsulate conversion of XML from /stats call to Metric objects.
+
{
# Attributes
@@ -26,11 +26,9 @@ use Class::Std;
# Check for server message. Not sure if stats will do this.
if ( $dom->exists('/results/message') ) {
$server_message_of{$ident} = $dom->findvalue('/results/message');
- croak(
- Lingua::AtD::ServiceException->new(
+ Lingua::AtD::ServiceException->throw(
{ server_message => $server_message_of{$ident} }
- )
- );
+ );
}
foreach my $metric_node ( $dom->findnodes('/scores/metric') ) {

0 comments on commit 028f05d

Please sign in to comment.
Something went wrong with that request. Please try again.