aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Moral <victor@venexma.es>2014-01-29 10:56:06 +0100
committerVíctor Moral <victor@venexma.es>2014-01-29 10:56:06 +0100
commit479450e137850e2fc3a2a5a8325b14711625d801 (patch)
tree7258132553980ff699573e911b96447750670e7e
parent0d778bc05c27f9037ae1ae940c9521211367e21a (diff)
downloadcdt-479450e137850e2fc3a2a5a8325b14711625d801.tar.gz
cdt-479450e137850e2fc3a2a5a8325b14711625d801.tar.bz2
cdt-479450e137850e2fc3a2a5a8325b14711625d801.zip
- Añadidas enumeraciones para situación de elementos: local o remotos, y para
el tipo de imagen - Añadida clase para elementos de imágenes. - Añadido test para las imágenes
-rw-r--r--lib/CDT/Item/Image.pm50
-rw-r--r--lib/CDT/Types.pm9
-rw-r--r--t/item-image.t25
3 files changed, 81 insertions, 3 deletions
diff --git a/lib/CDT/Item/Image.pm b/lib/CDT/Item/Image.pm
new file mode 100644
index 0000000..c3053f5
--- /dev/null
+++ b/lib/CDT/Item/Image.pm
@@ -0,0 +1,50 @@
+package CDT::Item::Image;
+use Moose;
+use Moose::Util::TypeConstraints;
+use namespace::autoclean;
+use utf8;
+
+# extensions and roles
+extends 'CDT::Item::Base';
+
+# external modules
+use URI;
+
+# attributes
+has '+type' => (
+ default => 'image',
+);
+
+has 'source' => (
+ documentation => q(Origen: local o remoto),
+ is => 'ro',
+ isa => 'CDT::Types::Source',
+ default => 'local',
+);
+
+has 'url' => (
+ documentation => q(Dirección de la imagen),
+ is => 'ro',
+ isa => 'URI',
+);
+
+has 'format' => (
+ documentation => q(Formato de la imagen),
+ is => 'ro',
+ isa => 'CDT::Types::ImageFormat',
+);
+
+# variables
+our $VERSION = '0.1';
+
+# public methods
+
+# private methods
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+
+
diff --git a/lib/CDT/Types.pm b/lib/CDT/Types.pm
index 89c8f69..ad1ee01 100644
--- a/lib/CDT/Types.pm
+++ b/lib/CDT/Types.pm
@@ -5,9 +5,12 @@ use namespace::autoclean;
use utf8;
# custom types
-enum 'CDT::Types::Items' => [qw(text image audio video html url cdt)];
-enum 'CDT::Types::Text' => [qw(plain html markdown)];
-
+enum 'CDT::Types::Items' => [qw(text image audio video html url cdt)];
+enum 'CDT::Types::Text' => [qw(plain html markdown)];
+enum 'CDT::Types::Source' => [qw(local remote)];
+enum 'CDT::Types::ImageFormat' =>
+ [qw(jpeg png gif tiff)];
+
# variables
our $VERSION = '0.1';
diff --git a/t/item-image.t b/t/item-image.t
new file mode 100644
index 0000000..78d7c4c
--- /dev/null
+++ b/t/item-image.t
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+
+use Modern::Perl;
+use Test::More;
+use lib qw(lib);
+use utf8;
+
+# Variables
+our $VERSION = '0.1';
+
+# Test de carga de la clase
+my $class = "CDT::Item::Image";
+use_ok( $class );
+
+# Test de creación de instancias
+my $obj = new_ok( $class );
+
+cmp_ok($obj->type,'eq','image','Item is a image');
+cmp_ok($obj->source,'eq','local','Item is local by default');
+
+# Fin de test
+done_testing;
+
+1;
+