| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::HTTP::Spore::Middleware::Format::XML; | 
| 2 |  |  |  |  |  |  | $Net::HTTP::Spore::Middleware::Format::XML::VERSION = '0.07'; | 
| 3 |  |  |  |  |  |  | # ABSTRACT: middleware for XML format | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 1 |  |  | 1 |  | 551 | use Moose; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 6 |  |  |  |  |  |  | extends 'Net::HTTP::Spore::Middleware::Format'; | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 6736 | use XML::Simple; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | my @KnownOptIn     = qw(keyattr keeproot forcecontent contentkey noattr | 
| 11 |  |  |  |  |  |  | searchpath forcearray cache suppressempty parseropts | 
| 12 |  |  |  |  |  |  | grouptags nsexpand datahandler varattr variables | 
| 13 |  |  |  |  |  |  | normalisespace normalizespace valueattr); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | my @KnownOptOut    = qw(keyattr keeproot contentkey noattr | 
| 16 |  |  |  |  |  |  | rootname xmldecl outputfile noescape suppressempty | 
| 17 |  |  |  |  |  |  | grouptags nsexpand handler noindent attrindent nosort | 
| 18 |  |  |  |  |  |  | valueattr numericescape); | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 1 |  |  | 1 | 1 | 7 | sub accept_type  { ( 'Accept'       => 'text/xml' ); } | 
| 21 | 0 |  |  | 0 | 1 | 0 | sub content_type { ( 'Content-Type' => 'text/xml' ) } | 
| 22 | 0 |  |  | 0 | 1 | 0 | sub encode       { my $mw = $_[0]; | 
| 23 | 0 |  |  |  |  | 0 | my @args = map { $_ => $mw->{$_} } grep { $mw->{$_} } @KnownOptOut; | 
|  | 0 |  |  |  |  | 0 |  | 
|  | 0 |  |  |  |  | 0 |  | 
| 24 | 0 |  |  |  |  | 0 | XMLout( $_[1], @args ) } | 
| 25 | 1 |  |  | 1 | 1 | 2 | sub decode       { my $mw = $_[0]; | 
| 26 | 1 |  |  |  |  | 3 | my @args = map { $_ => $mw->{$_} } grep { $mw->{$_} } @KnownOptIn; | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 18 |  |  |  |  | 26 |  | 
| 27 | 1 |  |  |  |  | 4 | XMLin( $_[1], @args ) } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | 1; | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | __END__ | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =pod | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =encoding UTF-8 | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | =head1 NAME | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | Net::HTTP::Spore::Middleware::Format::XML - middleware for XML format | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =head1 VERSION | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | version 0.07 | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | my $client = Net::HTTP::Spore->new_from_spec('twitter.json'); | 
| 48 |  |  |  |  |  |  | $client->enable('Format::XML'); | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | Net::HTTP::Spore::Middleware::Format::XML is a simple middleware to handle the XML format. It will set the appropriate B<Accept> header in your request. If the request method is PUT or POST, the B<Content-Type> header will also be set to XML. | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | This middleware will also deserialize content in the response. The deserialized content will be store in the B<body> of the response. | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | =head1 EXAMPLES | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | =head1 AUTHORS | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | =over 4 | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | =item * | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | Franck Cuny <franck.cuny@gmail.com> | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | =item * | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | Ash Berlin <ash@cpan.org> | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | =item * | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | Ahmad Fatoum <athreef@cpan.org> | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | =back | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | This software is copyright (c) 2012 by Linkfluence. | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 81 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | =cut |