summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2013-11-07 12:05:17 +0000
committerGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2013-11-07 12:06:25 +0000
commitb3956bfdb7d000f127b2a70445cbf9bf2287a634 (patch)
tree33e9726005961cf9a6b9d61468c28f418f959e26 /lib
parentmigrate to Moo: bus client (diff)
downloadHomePanel-b3956bfdb7d000f127b2a70445cbf9bf2287a634.tar.gz
HomePanel-b3956bfdb7d000f127b2a70445cbf9bf2287a634.tar.bz2
HomePanel-b3956bfdb7d000f127b2a70445cbf9bf2287a634.zip
migrate to Moo: tube client
Diffstat (limited to 'lib')
-rw-r--r--lib/WebService/TFL/TubeStatus.pm11
-rw-r--r--lib/WebService/TFL/TubeStatus/Response.pm6
-rw-r--r--lib/WebService/TFL/TubeStatus/Response/Line.pm10
-rw-r--r--lib/WebService/TFL/TubeStatus/Response/LineStatus.pm7
-rw-r--r--lib/WebService/TFL/TubeStatus/Types.pm11
5 files changed, 30 insertions, 15 deletions
diff --git a/lib/WebService/TFL/TubeStatus.pm b/lib/WebService/TFL/TubeStatus.pm
index 79230ce..3b69997 100644
--- a/lib/WebService/TFL/TubeStatus.pm
+++ b/lib/WebService/TFL/TubeStatus.pm
@@ -1,7 +1,7 @@
package WebService::TFL::TubeStatus;
-use Moose;
-use Moose::Util::TypeConstraints;
-use MooseX::Types::URI 'Uri';
+use Moo;
+use Type::Utils -all;
+use Types::URI 'Uri';
use XML::LibXML;
use XML::LibXML::XPathContext;
use WebService::TFL::TubeStatus::Response;
@@ -9,8 +9,7 @@ use namespace::autoclean;
has user_agent => (
isa => duck_type(['get']),
- is => 'ro',
- lazy_build => 1,
+ is => 'lazy',
);
sub _build_user_agent {
require LWP::UserAgent;
@@ -22,7 +21,7 @@ sub _build_user_agent {
has uri => (
isa => Uri,
is => 'ro',
- coerce => 1,
+ coerce => Uri->coercion,
default => 'http://cloud.tfl.gov.uk/TrackerNet/LineStatus',
);
diff --git a/lib/WebService/TFL/TubeStatus/Response.pm b/lib/WebService/TFL/TubeStatus/Response.pm
index f8cd8bf..191abe7 100644
--- a/lib/WebService/TFL/TubeStatus/Response.pm
+++ b/lib/WebService/TFL/TubeStatus/Response.pm
@@ -1,11 +1,13 @@
package WebService::TFL::TubeStatus::Response;
-use Moose;
+use Moo;
+use WebService::TFL::TubeStatus::Types -all;
use WebService::TFL::TubeStatus::Response::Line;
+use Types::Standard -all;
use namespace::autoclean;
has lines => (
is => 'ro',
- isa => 'ArrayRef[WebService::TFL::TubeStatus::Response::Line]',
+ isa => ArrayRef[LineT],
required => 1,
);
diff --git a/lib/WebService/TFL/TubeStatus/Response/Line.pm b/lib/WebService/TFL/TubeStatus/Response/Line.pm
index 11d3538..9779443 100644
--- a/lib/WebService/TFL/TubeStatus/Response/Line.pm
+++ b/lib/WebService/TFL/TubeStatus/Response/Line.pm
@@ -1,23 +1,25 @@
package WebService::TFL::TubeStatus::Response::Line;
-use Moose;
+use Moo;
+use Types::Standard -all;
+use WebService::TFL::TubeStatus::Types -all;
use WebService::TFL::TubeStatus::Response::LineStatus;
use namespace::autoclean;
has id => (
is => 'ro',
- isa => 'Num',
+ isa => Num,
required => 1,
);
has name => (
is => 'ro',
- isa => 'Str',
+ isa => Str,
required => 1,
);
has status => (
is => 'ro',
- isa => 'WebService::TFL::TubeStatus::Response::LineStatus',
+ isa => LineStatusT,
required => 1,
);
diff --git a/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm b/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm
index e223bb6..6caa7d6 100644
--- a/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm
+++ b/lib/WebService/TFL/TubeStatus/Response/LineStatus.pm
@@ -1,16 +1,17 @@
package WebService::TFL::TubeStatus::Response::LineStatus;
-use Moose;
+use Moo;
+use Types::Standard -all;
use namespace::autoclean;
has is_active => (
is => 'ro',
- isa => 'Bool',
+ isa => Bool,
required => 1,
);
has [qw(code class description details)] => (
is => 'ro',
- isa => 'Str',
+ isa => Str,
required => 1,
);
diff --git a/lib/WebService/TFL/TubeStatus/Types.pm b/lib/WebService/TFL/TubeStatus/Types.pm
new file mode 100644
index 0000000..d1cb141
--- /dev/null
+++ b/lib/WebService/TFL/TubeStatus/Types.pm
@@ -0,0 +1,11 @@
+package WebService::TFL::TubeStatus::Types;
+use strict;
+use warnings;
+use Type::Library -base, -declare => qw(LineT LineStatusT);
+use Type::Utils -all;
+use namespace::autoclean;
+
+class_type LineT, { class => 'WebService::TFL::TubeStatus::Response::Line' };
+class_type LineStatusT, { class => 'WebService::TFL::TubeStatus::Response::LineStatus' };
+
+1;