Atompub
view release on metacpan or search on metacpan
lib/Atompub/MediaType.pm view on Meta::CPAN
141516171819202122232425262728293031323334
feed
=>
'application/atom+xml;type=feed'
,
service
=>
'application/atomsvc+xml'
,
categories
=>
'application/atomcat+xml'
,
);
__PACKAGE__->mk_accessors(
qw(type subtype parameters)
);
use
overload (
q{""}
=> \
&as_string
,
eq
=> \
&is_a
,
ne
=> \
&is_not_a
,
fallback
=> 1,
);
sub
new {
my
(
$class
,
$arg
) =
@_
;
my
$media_type
=
$ATOM_TYPE
{
$arg
} ||
$arg
or
return
;
my
(
$type
,
$subtype
,
$param
) =
split
m{[/;]},
$media_type
;
bless
{
type
=>
$type
,
subtype
=>
$subtype
,
lib/Atompub/MediaType.pm view on Meta::CPAN
717273747576777879808182838485868788899091
if
(
$test
->subtype eq
$test
->subtype_major) {
# ex. application/xml
return
0
unless
$test
->subtype_major eq
$self
->subtype_major;
}
else
{
# ex. application/atom+xml
return
0
unless
$test
->subtype eq
$self
->subtype;
}
return
1
if
!
$test
->parameters || !
$self
->parameters;
return
$test
->parameters eq
$self
->parameters;
}
sub
is_not_a {
my
(
$self
,
@args
) =
@_
;
!
$self
->is_a(
@args
);
}
1;
__END__
=head1 NAME
Atompub::MediaType - a media type object for the Atom Publishing Protocol
lib/Atompub/MediaType.pm view on Meta::CPAN
139140141142143144145146147148149150151152153154155156157158=head2 $type->parameters
=head2 $type->subtype_major
=head2 $type->extensions
=head2 $type->extension
=head2 $type->is_a
=head2 $type->is_not_a
=head2 $type->as_string
=head2 $type->without_parameters
=head1 SEE ALSO
L<Atompub>
t/03.media_type.t view on Meta::CPAN
17181920212223242526272829303132333435363738is
$png
->without_parameters,
'image/png'
;
is
$png
->as_string,
'image/png'
;
is
$png
->extensions,
'png'
;
is
$png
->extension,
'png'
;
ok
$png
->is_a(
'*/*'
);
ok
$png
->is_a(
'image/*'
);
ok
$png
->is_a(
'image/png'
);
ok
$png
->is_not_a(
'text/*'
);
ok
$png
->is_not_a(
'image/jpeg'
);
is
"$png"
,
'image/png'
;
ok
$png
eq
'*/*'
;
ok
$png
ne
'text/*'
;
my
$atom
= media_type(
'entry'
);
isa_ok
$atom
,
'Atompub::MediaType'
;
is
$atom
->type,
'application'
;
t/03.media_type.t view on Meta::CPAN
464748495051525354555657585960616263is
$atom
->extensions,
'atom'
;
is
$atom
->extension,
'atom'
;
ok
$atom
->is_a(
'*/*'
);
ok
$atom
->is_a(
'application/*'
);
ok
$atom
->is_a(
'application/xml'
);
ok
$atom
->is_a(
'application/atom+xml'
);
ok
$atom
->is_a(
'application/atom+xml;type=entry'
);
ok
$atom
->is_not_a(
'text/*'
);
ok
$atom
->is_not_a(
'application/octet-stream'
);
ok
$atom
->is_not_a(
'application/atom+xml;type=feed'
);
is
"$atom"
,
'application/atom+xml;type=entry'
;
ok
$atom
eq
'*/*'
;
ok
$atom
ne
'text/*'
;
( run in 0.404 second using v1.01-cache-2.11-cpan-55f5a4728d2 )